“There are two important themes behind everything we're delivering today.” says Bret Taylor, head of Facebook’s platform products in the facebook developer blog, about the recent announcements at the f8 conference in San Francisco. Facebook introduced Open Graph protocol, and the Graph API as the next evolution in the Facebook platform.
First, the Web is moving to a model based on the connections between people and all the things they care about. Second, this connections-based Web is well on its way to being built and providing value to both users and developers — the underlying graph of connections just needs to be mapped in a way that makes it easy to use and interoperable.
Facebook introduced three new components of Facebook Platform two of which the Open Graph protocol, and the Graph API. The API provides access to Facebook objects like people, photos, events etc. and the connections between them like friends, tags, shared content etc. via a uniform and consistent URI to access the representation. Every object can be accessed using the the URL https://graph.facebook.com/ID, where ID stands for the unique ID for the object in the social graph. Every connection (CONNECTION_TYPE) that the facebook object supports can be examined using the URL https://graph.facebook.com/ID/CONNECTION_TYPE.
Excerpted from the Graph API page are some examples of URI’s for accessing facebook obects (resources) using their identifiers. At a high level they demonstrate how one would use the API.
All objects in Facebook can be accessed in the same way:
- Pages: https://graph.facebook.com/cocacola (Coca-Cola page)
- Events: https://graph.facebook.com/251906384206 (Facebook Developer Garage Austin)
- Groups: https://graph.facebook.com/2204501798 (Emacs users group)
- Applications: https://graph.facebook.com/2439131959 (the Graffiti app)
[…]
All of the objects in the Facebook social graph are connected to each other via relationships. Bret Taylor is a fan of the Coca-Cola page, and Bret Taylor and Arjun Banker are friends. We call those relationships connections in our API. You can examine the connections between objects using the URL structure
https://graph.facebook.com/ID/CONNECTION_TYPE
. The connections supported for people and pages include:
The URI’s also have a special identifier me
which refers to the current user. The Graph API uses OAuth 2.0 for authorization (the authentication guide has details of the Facebook's OAuth 2.0 implementation).
OAuth 2.0 is a simpler version of OAuth that leverages SSL for API communication instead of relying on complex URL signature schemes and token exchanges. At a high level, using OAuth 2.0 entails getting an access token for a Facebook user via a redirect to Facebook. After you obtain the access token for a user, you can perform authorized requests on behalf of that user by including the access token in your Graph API requests:
Reactions from the web have been positive in general. In a post entitled “Uncomplicated Hypermedia”, Subbu Allamaraju says,
It is a pleasure to read the Facebook Graph API. It avoided many of the traps that web services offered by the other major players in the industry suffer from. Facebook’s API is simple, consistent and inter-connected. It is true to the spirit of the web.
He points to how the protocol and the graph API leverages the power of hypermedia that proves that building simple representations of linked resources; in this case the Facebook object graph; doesn’t have to be that complicated, for e.g. some of the API’s available on the web use separate services for different types of resources while some are based on AtomPub protocol and extensions like GData or OData.
Ars Technica welcomes the announcement as a move towards open standards.
Facebook's move towards open standards and an improved API was driven internally by some key people that have joined the company over the past year. Facebook employs well-known standardista David Recordon, one of the authors of OAuth and Atom Activity Extensions. The FriendFeed engineers who joined Facebook through an acquisition last year have also been instrumental in moving forward Facebook's development platform.
At the O’Riely Radar, David Recordon, now an employee of Facebook, states why these API’s will be good for the open web and highlights the changes he’s excited about; features like the realtime api, support for OAuth 2.0, and no longer needing the 24-hour caching limit for developers. He says,
It's easy as a technologist to think about openness solely in terms of technology, but openness is broader than that. Openness of technology means that others can build using the same tools that you do. Openness of data means that developers can build innovative products based on APIs that weren't previously possible. And openness between people is what happens when when all of these things come together to give people better ways to share information.
According to an article in ReadWriteWeb this could potentially have a huge impact on the semantic web.
One of the most exciting parts of the Facebook announcement to me personally is the possible breakthrough in semanticizing the Web.
For more information on how to leverage the API be sure to check out the developer API documentation.