Graph API

From Facebook Developer Wiki (FbDevWiki.com)
Jump to: navigation, search

The Graph API was launched in March 2010 with the intention of replacing the older REST API. However, there is still functionality in the REST API that does not have any similar method in the new Graph API. Facebook has declared its intention to replace the REST API with the Graph API so it's probably a good idea to use the Graph API whenever possible to help "future proof" your code.

Essentially there are three methods of using the Graph API: requesting data, posting data, and deleting data. Some data can be requested without authentication while most data is dependent on authentication, which user is authenticated, the permissions that user has given, and the permissions given by the object being queried. Posting data has similar restrictions. Deleting data is very limited and usually can only be done to content originally posted by the current application and user.

All of the data received is encoded as JSON. All of the data sent is either included as GET arguments or POST arguments (these are JSON encoded too if they're not plain strings).

The data retrieved are seen as "objects" on the "social graph". Each object has a unique id number assigned by Facebook and those unique numbers are unique across all objects ( ex. https://graph.facebook.com/19292868552 ) It's also possible that the object has a plain string name ( ex. https://graph.facebook.com/platform )

There is a Batch Request method to make multiple calls to the Graph API in a way that cuts down on back-and-forth traffic time.

The Graph API has support for JSONP through the callback variable which will allow cross-domain javascript access to Graph data.

A non-standard ways to make queries:

https://graph.facebook.com/comments/?ids=99394368305 https://graph.facebook.com/comments/?ids=http://www.ahwebdev.fr/ https://graph.facebook.com/comments/?ids=http://www.ahwebdev.fr/,99394368305


GET variables possible:

date_format
Modifies all dates and times to use the format given in this argument. Uses the same format definitions as the PHP date() function. For example date_format=U will return values in Unix timestamps.
height
used for requesting a specific size of image (usually used with width)
metadata
when metadata=1 the API will return additional meta information about the different fields
return_ssl_resources
when return_ssl_resources=1 is included in request https urls should be returned where available
width
used for requesting a specific size of image (usually used with height)


Here is a list of all the different object types:

Album
A photo album
Application
An application registered on Facebook Platform
Checkin
A checkin made through Facebook Places or the Graph API.
Comment
A comment on a Graph API object
Domain
Mapping of web domains to Facebook ID's
Event
A Facebook event
FriendList
A Facebook friend list
Group
A Facebook group
Insights
Statistics about applications, pages, or domain.
Link
A shared link
Message
A message in the new Facebook unified messaging system.
Note
A Facebook note
Page
A Facebook Page.
Photo
An individual photo within an album
Post
An individual entry in a profile's feed
Review
A review for an application
Status message
A status message on a user's wall
Subscription
A subscription to an application to get real-time updates for an Graph object type.
Thread
A message thread.
User
A user profile.
Video
An individual video
Personal tools
Namespaces
Variants
Actions
Navigation
Graph API
FQL
Toolbox