Facebook Query Language, or FQL, enables you to use a SQL-style interface to query the data exposed by the Graph API. It provides for some advanced features not available in the Graph API, including batching multiple queries into a single call.
You can execute FQL queries by fetching https://api.facebook.com/method/fql.query?query=QUERY
. You can specify a response format as either XML or JSON with the format
query parameter.
Queries are of the form SELECT [fields] FROM [table] WHERE [conditions]
. Unlike SQL, the FQL FROM
clause can contain only a single table. You can use the IN
keyword in SELECT
or WHERE
clauses to do subqueries, but the subqueries cannot reference variables in the outer query's scope. Your query must also be indexable, meaning that it queries properties that are marked as indexable in the documentation below.
FQL can handle simple math, basic boolean operators, AND or NOT logical operators, and ORDER BY and LIMIT clauses.
For any query that takes a uid
, you can pass me()
to return the logged-in user. For example:
SELECT name FROM user WHERE uid = me()
Other functions that are available are now()
, strlen()
, substr()
and strpos()
.
Here's an example of a subquery that fetches all user information for the active user and friends:
SELECT uid, name, pic_square FROM user WHERE uid = me()
OR uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
For more information, check out the tables below, most of which have sample queries demonstrating their use.
Query this table to return information about a photo album.
Query this table to return read-only properties about an application.
An FQL table containing the requests sent via an app to a user.
Query this table to return information about a checkin. By default, this query returns the last 20 checkins and returns a maximum of 500 checkins.
Query this table to obtain comments associated with one or more [fb:comments]
The comments_info FQL table. Query this table to obtain XIDs for fb:comments objects associated with an application ID.
Query this table to return a user's friends and the Facebook Pages to which the user is connected.
Query this table to return information about a cookie.
Query this table to return the application IDs for which the specified user is listed as a developer in the Developer application.
The domain table provides a read-only mapping between domain names and ids.
Query this table to return information about the admin of a domain.
Query this table to return information about an event.
Query this table to return information about a user's status for an event or see a list of events for a user.
Query this table to return detailed information about a user's family.
Query this table to determine whether two users are linked together as friends.
Query this table either to determine which users have sent friend requests to the logged-in user or to query whether a friend request has been sent from the logged-in user to a specific user.
Query this table to return any friend lists owned by the specified user.
Query this table to determine which users are members of a friend list.
Query this table to return information about a group.
Query this table to return information about the members of a group, or retrieve a list of groups of which a user is a member
The insights table contains statistics about Applications, Pages and Domains
Query this table to return the user IDs of users who like a given Facebook object (video, note, link, photo, or album).
Query this table to return the links the current user has posted.
The link_stat table contains counts that show how users on Facebook are interacting with a given link.
The mailbox_folder table contains information about a user's mailbox folders.
Query this table to return information about messages in a thread.
Query this table to return the notes the current user has written or to return details for a particular note.
Query this table to get the notifications for the current session user, that is, any notification that appears on http://www.facebook.com/notifications.php.
Query this table to return information about a URL in the Open Graph
Query this table to return information about a Facebook Page.
Query this table to return information about which Facebook Pages the user Admins.
An FQL table that can be used to return a list of a users that are blocked from a Facebook Page.
Query this table to return information about the user who likes a Facebook Page.
Query this table to return the permissions the current user has granted to the app.
Query this table to return more descriptive information about extended permissions.
Query this table to return information about a photo.
Query this table to return information about a photo tag.
Query this table to return information about a place.
Query this table to return a user's privacy setting for a given object_id.
Query this table to return certain (typically publicly) viewable information for a profile.
Query this table to obtain reviews associated with an application, a user or both.
Query this table to determine whether two users are linked together as friends.
Query this table to return standard information about a user, for use when you need analytic information only.
Query this table to return one or more of a user's statuses.
Query this table to return posts from a user's stream or the user's profile.
Query this table to return a filter_key that can be used to query the stream FQL table, as seen through any content filters the user has available on Facebook.
Query this table to return associations between users or Facebook Pages and the items they tag in status posts.
Query this table to return information about message threads in a user's Inbox.
Query this table to return the native strings (original, untranslated text in your application interface) and the translated strings for your application.
This table can be used to access information about messages in the new Facebook messaging system.
This table can be used to access information about threads in the new Facebook messaging system.
This table should be used to access information about subscribe and unsubscribe actions performed on a thread in the new Facebook messaging system.
This table should be used to access information about the number of threads in a folder in the new Facebook messaging system.
An FQL table containing the Open Graph URLs that the current session user has Liked.
Query this table to return detailed information from a user's profile.
The video table contains information about videos.
The video_tag table contains information about users tagged in videos.