First Look: Getting Data from the Facebook Stream API
April 27th, 2009
| By Karl Bunyan | 7 Comments » |
The new stream APIs that Facebook announced today appear to offer a rich level of data interaction between Facebook, applications, and external sites. So how does it actually work, and how do you go about implementing it?
The first step is to persuade your users to grant extended permissions to your application. Previously the extended permissions covered more abstract topics such as allowing an application to access a user’s data online (which may mean little to most users) or to allow e-mails to be sent (which users may be reluctant to grant). The stream, however, offers a lot more benefit to the end user and so could bring this feature of the Facebook Platform into more regular use.
Getting the special permission to be able to read a user’s stream data is as simple as persuading them to click on a link. The FBML tag is as follows:
<fb:prompt-permission perms=”read_stream”>Grant permission to read from my stream</fb:prompt-permission>
and can be styled as the developer wishes i.e. as a button, or possibly even a graphic. This pops up the dialogue box below, which not only describes what this means to the user but has a helpful illustration of the direction data moves in, and some example posts from the user’s own feed:

Although ideally (from a developer’s point of view) this would be the default setting and all applications could read from the stream once authorized – it is a possibility that this will be the case in the future – if given sufficient incentive to click on the link, users who start this process shouldn’t be too confused as to what they’re agreeing to.
Now you have all the permissions you need to read the stream, what can you pull back? So far, it looks like very little is off-limits. Not only links, posts and status messages are available but also feed stories from other applications – the first time this kind of cross-application data-sharing has been possible. I generated a story using the Living Social “Top 5″ application and immediately this item appeared in my stream.get API request, complete with links to all of the media in the story, it’s text, the name of the application and comments and “likes” from friends. In theory, I could take this feed story and re-present it in my own application, styled in a way of my own choosing.
As well as just pulling back all the most recent data, the stream can be queried on a number of data levels:
- The user the feed item belongs to.
- The user, or even Facebook Page, that generated the content. (The stream contains user and Page information and treats them equally.)
- The type of content, which may be an application story or link. Stories from only particular sources can be retrieved, allowing the generation of filters by application or content type
- Date and time information. Stream items can be queried between particular dates, or just retrieve the top 20, 50 or more
Once the call is made a large set of data is returned, including:
- The user the story appeared to
- The story content including links to files, attachments and images
- The publisher of the content (whether user or Page)
- Comments attached to the story (although only a selection are shown)
- The number of “likes”
There are a host of other data points transferred and this is certainly more complex than many of Facebook’s other feeds, although the documentation is relatively complete already. The data above, and more, could be put to a number of users including creating more subtle or sophisticated filters than Facebook offers, showing general feed content in applications, filtering the stream by application type, and of course to display the Facebook stream on external sites or in external desktop applications. The potential is here not just for existing Connect sites and Facebook applications but for a whole new set of applications to be developed.

Twitter
Facebook









Strategic Facebook Platform Ecosystem Overview and Guide For Agencies & Brands
French / Français
Spanish / Español
Italian / Italiano
Track Facebook's International Growth in 95 Global Markets with our Monthly Reports and Analysis


April 27th, 2009 at 11:41 am
Another good step forward from Facebook. It seems that their efforts have really been increasing producing so many new features each month that it is hard to keep up with them all.
April 27th, 2009 at 1:49 pm
While I’m please to see them moving to a new, more open platform from a developers point of view, I’m not sure how I feel about it as a user
April 28th, 2009 at 8:56 am
with this new functionality, does it give developers the chance to recreate the old news feed that the majority of people miss? if someone can create a news feed with the old look and containing things like tagged pictures, profile picture updates, new friend updates etc, i can see it being very popular!
April 28th, 2009 at 3:32 pm
We are now supporting the Stream API in FriendBinder: http://blog.friendbinder.com/2009/04/facebook-stream-api-support-in.html So you can read Facebook with Twitter and a bunch of other sites.
May 26th, 2009 at 7:08 am
Can we easily get a friends stream?
June 3rd, 2009 at 3:05 pm
As a developer, it is a nice feature and therefore I can incorporate some contents into my site. But as a user, I do not know how much information will be passed to the site using this feature.
January 31st, 2010 at 9:08 pm
easy to get user info