- Friends: https://graph.facebook.com/me/friends?access_token=...
- News feed: https://graph.facebook.com/me/home?access_token=...
- Profile feed (Wall): https://graph.facebook.com/me/feed?access_token=...
- Likes: https://graph.facebook.com/me/likes?access_token=...
- Movies: https://graph.facebook.com/me/movies?access_token=...
- Books: https://graph.facebook.com/me/books?access_token=...
- Notes: https://graph.facebook.com/me/notes?access_token=...
- Photo Tags: https://graph.facebook.com/me/photos?access_token=...
- Photo Albums: https://graph.facebook.com/me/albums?access_token=...
- Video Tags: https://graph.facebook.com/me/videos?access_token=...
- Video Uploads: https://graph.facebook.com/me/videos/uploaded?access_token=...
- Events: https://graph.facebook.com/me/events?access_token=...
- Groups: https://graph.facebook.com/me/groups?access_token=...
- Checkins: https://graph.facebook.com/me/checkins?access_token=...
We support different connection types for different objects. For example, you can get the list of all the people attending the Facebook Developer Garage at SXSW (ID #331218348435) by fetching https://graph.facebook.com/331218348435/attending?access_token=....
All of the different types of objects and connections we support are included in the Graph API reference documentation.
Authorization
The Graph API as such allows you to easily access all public information about an object. For example, https://graph.facebook.com/btaylor (Bret Taylor) returns all the public information about Bret. For example a user's first name, last name and profile picture are publicly available.
To get additional information about a user, you must first get their permission. At a high level, you need to get an access token for the Facebook user. After you obtain the access token for the user, you can perform authorized requests on behalf of that user by including the access token in your Graph API requests:
https://graph.facebook.com/220439?access_token=...For example https://graph.facebook.com/btaylor?access_token=... (Bret Taylor) returns additional information about Bret Taylor.
The Graph API uses OAuth 2.0 for authorization. Please read the authentication and authorization guide which provides details of Facebook's OAuth 2.0 implementation, how to request permissions from a user and obtain an access token.
Getting an access token for a user with no extended permissions allows you to access the information that the user has made available to everyone on Facebook. If you need specific information about a user, like their email address or work history, you must ask for the specific extended permissions. You can learn about permissions you need, to access each property and connection of an object from the Graph API reference documentation.
Page impersonation
You can impersonate pages administrated by your users by requesting the "manage_pages" extended permission.
Once a user has granted your application the "manage_pages" permission, the "accounts" connection will yield an additional access_token property for every page administrated by the current user. These access_tokens can be used to make calls on behalf of a page. The permissions granted by a user to your application will now also be applicable to their pages.
Authenticating as an Application
To make administrative calls that do not require an active user (for example, retrieving analytics data or test users) you need to obtain an access token for your application. Read more about how to get an application access token here.
Reading
The Graph API allows you to read properties and connections of the Facebook social graph. You can use the API to read specific fields, get pictures of any object, introspect an object for metadata and get real-time updates on any changes.
Selection
By default, most object properties are returned when you make a query. You can choose the fields (or connections) you want returned with the "fields" query parameter. For example, this URL will only return the id, name, and picture of Ben: https://graph.facebook.com/bgolub?fields=id,name,picture
You can also request multiple objects in a single query using the "ids" query parameter. For example, the URL https://graph.facebook.com?ids=arjun,vernal returns both profiles in the same response.
The "ids" query parameter also accepts URLs. This is useful for finding IDs of URLs in the Open Graph. For example: https://graph.facebook.com/?ids=http://www.imdb.com/title/tt0117500/
Additionally, there is a special identifier
me
which refers to the current user. So the URL https://graph.facebook.com/me returns the active user's profile.Pictures
You can render the current profile photo for any object by adding the suffix
/picture
to the object URL. For example, this will render your public profile photo:<img src="https://graph.facebook.com/sobachemyaso/picture"/>The same URL pattern works for all objects in the graph:
- People: http://graph.facebook.com/sobachemyaso/picture
- Events: http://graph.facebook.com/331218348435/picture
- Groups: http://graph.facebook.com/69048030774/picture
- Pages: http://graph.facebook.com/DoloresPark/picture
- Applications: http://graph.facebook.com/2318966938/picture
- Photo Albums: http://graph.facebook.com/platform/picture
You can specify the picture size you want with the
type
argument, which should be one ofsquare
(50x50),small
(50 pixels wide, variable height), andlarge
(about 200 pixels wide, variable height): http://graph.facebook.com/sobachemyaso/picture?type=large.Paging
When querying connections, there are several useful parameters that enable you to filter and page through connection data:
limit
,offset
: https://graph.facebook.com/me/likes?limit=3until
,since
(a unix timestamp or any date accepted by strtotime): https://graph.facebook.com/search?until=yesterday&q=orangeIntrospection
The Graph API supports introspection of objects, which enables you to see all of the connections an object has without knowing its type ahead of time. To get this information, add
metadata=1
to the object URL, and the resulting JSON will include ametadata
property that lists all the supported connections for the given object. For example, you can see all the connections for the Developer Garage event above by fetching https://graph.facebook.com/331218348435?metadata=1. That outputs:{ "name": "Facebook Developer Garage Austin - SXSW Edition", "metadata": { "connections": { "feed": "http://graph.facebook.com/331218348435/feed", "picture": "https://graph.facebook.com/331218348435/picture", "invited": "https://graph.facebook.com/331218348435/invited", "attending": "https://graph.facebook.com/331218348435/attending", "maybe": "https://graph.facebook.com/331218348435/maybe", "noreply": "https://graph.facebook.com/331218348435/noreply", "declined": "https://graph.facebook.com/331218348435/declined" } } }The introspection feature is a useful and extensible way to find all the things your users are connected to.
Real-Time updates
Real-time updates provide you the ability to receive updates about all of your application's users, as their data changes. With such subscriptions, you can be confident that your cached data is correct without polling Facebook's servers, increasing the reliability of your application, and the responsiveness of your user experience.
Searching
You can search over all public objects in the social graph with
https://graph.facebook.com/search
. The format is:https://graph.facebook.com/search?q=QUERY&type=OBJECT_TYPEWe support search for the following types of objects:
- All public posts: https://graph.facebook.com/search?q=watermelon&type=post
- People: https://graph.facebook.com/search?q=mark&type=user
- Pages: https://graph.facebook.com/search?q=platform&type=page
- Events: https://graph.facebook.com/search?q=conference&type=event
- Groups: https://graph.facebook.com/search?q=programming&type=group
- Places: https://graph.facebook.com/search?q=coffee&type=place¢er=37.76,122.427&distance=1000
- Checkins: https://graph.facebook.com/search?type=checkin
You can also search an individual user's News Feed, restricted to that user's friends, by adding a
q
argument to thehome
connection URL:
http://whatgetsmehot.posterous.com/facebook-connect-nightmare-before-xmas-try-in Friends: https://graph.facebook.com/me/friends?access_token=... News feed: https://graph.facebook.com/me/home?access_token=... Profile feed (Wall): https://graph.facebook.com/me/feed?access_token=... Likes: https://graph.facebook.com/me/likes?access_token=... Movies: https://graph.facebook.com/m ... Dogmeat