Facebook Developers
DocsToolsSupportNewsApps
Log In
  • Social Plugins
  • Facebook Login
  • Open Graph
  • Facebook APIs
    • Graph API
    • FQL
    • Open Graph
    • Dialogs
    • Chat
    • Internationalization
    • Ads
  • Games
  • Payments
  • App Center
  • Promote Your App
  • iOS
  • Android
  • JavaScript
  • PHP
  • More SDKs
  • Objects
    • Achievement(Instance)
    • Album
    • Application
    • Checkin
    • Comment
    • Domain
    • Errors
    • Event
    • Field Expansion
    • FriendList
    • Group
    • Insights
    • Link
    • Message
    • Note
    • Offer
    • Order
    • Page
    • Pagination
    • Payment
    • Photo
    • Pictures
    • Post
    • Privacy Parameter
    • Publishing
    • Question
    • QuestionOption
    • Realtime Updates
    • Review
    • Search
    • Selecting Results
    • Status message
    • Thread
    • User
    • Video

Search

Facebook APIs › Graph API › Search

The Graph API Search interface has changes pending with the Q3 2013 migration. Please see the blog post for more information on what's changed. Changes listed in the blog post will go live on July 10th, 2013.

In this document:

  • Overview
  • Access Tokens
  • Search Types
  • Results
  • Searching News Feeds

Overview

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_TYPE

Access Tokens

All Graph API search queries require an access token passed in with the access_token=<token> parameter. The type of access token you need depends on the type of search you're executing.

  • Searches across page and place objects requires an app access token.
  • All other endpoints require a user access token.

Search Types

We support search for the following types of objects:

  • All public posts: https://graph.facebook.com/search?q=watermelon&type=post
    This search type does not support limit/offset paging.
  • 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.
    You can narrow your search to a specific location and distance by adding the center parameter (with latitude and longitude) and an optional distance parameter:
    https://graph.facebook.com/search?q=coffee&type=place&center=37.76,-122.427&distance=1000
  • Checkins: https://graph.facebook.com/search?type=checkin (This request returns you or your friend's latest checkins, or checkins where you or your friends have been tagged; currently, it does not accept a q= parameter.)
  • Objects with location. The following will return information about objects that have location information attached. In addition, the returned objects will be those in which you or your friend have been tagged, or those objects that were created by you or your friends. There are important behavioral differences in the results depending on the permissions your app has acquired. Please see the documentation for the location_post FQL table for more information.
    • To search for objects near a geographical location, use type=location and add the center and distance parameters: https://graph.facebook.com/search?type=location&center=37.76,-122.427&distance=1000
    • To search for objects at a particular place, use type=location and specify the ID of the place. For example for Posts at Facebook HQ, use: https://graph.facebook.com/search?type=location&place=166793820034304

Results

You can restrict the fields returned by these searches using the ?fields= URL parameter, in the same way you can when reading other objects. For example, to get only the names of events, you can do the following:

  • Event Names: https://graph.facebook.com/search?fields=name&q=conference&type=event

Some fields such as id, and start_time for events, are always returned.


Searching News Feeds

You can also search an individual user's News Feed, restricted to that user's friends, by adding a q argument to the home connection URL:

  • News Feed: https://graph.facebook.com/me/home?q=facebook

Note: /me/home retrieves an outdated view of the News Feed. This is currently a known issue and we don't have any near term plans to bring them back up into parity.

When searching for public posts or posts on the user's News Feed, you can page over the results by using the since, until and limit parameters. since and until both accept a unix timestamp. When paging back in time, you should use until in conjunction with limit where until is the unixtime value of the created_time field in the last object returned by your previous query. When paging forward in time you should set since to be the unixtime value of the created_time field in the first object returned by your previous query. Please note, you can only search about 1 to 2 weeks back in the News Feed.

Updated about a month ago
Facebook © 2013 · English (US)
AboutAdvertisingCareersPlatform PoliciesPrivacy Policy