Facebook Graph API
Last updated
Last updated
The Graph API Explorer tool allows you to construct and perform Graph API queries and see their responses for any apps on which you have an admin, developer, or tester role.
Test API queries with your Live app's settings, including approved login permissions, features, and settings for any added products such as Facebook Login.
Test API queries with your Developer Mode app's settings using any login permissions and features on test users or test data.
Quickly generate access tokens.
Get code samples of the queries you have run.
Generate debug information to include in support requests.
An app for which you have a role, such as an admin, developer, or tester role.
The Application dropdown menu displays all the apps on which you have an admin, developer, or tester role. Use the dropdown to select the app that you wish to test.
Whenever you request a User access token, only one permission is given by default, public_profile
. The Permission dropdown menu allows you to select User Data Permissions, such as email
and user_photos
, Events, Groups, and Pages Permissions, such as manage_pages
and ads_management
, and Other permissions, such as instagram_basic
and publish_video
permissions. This allows the current app User (which is you) to grant the app specific permissions. Only grant permissions that your app actually needs.
If your app is in development mode, you can grant your app any permission and your queries respect them. If your app is live, however, granting a permission that your app has not been approved for by the App Review process causes your query to fail whenever you submit it.
When you get an access token, it is displayed here. This is the token that is included in your Graph API query.
The current query appears here. You can edit the current query by typing in a new one, or by searching for and selecting fields in the field viewer after executing the query. You can also use the dropdown menus to switch between operation methods, and target different versions of the Graph API.
If you click the star icon at the end of the field, the query is saved as a favorite. You can view your favorite queries by clicking the book icon.
When you submit a GET
query on a node, the field viewer displays the name of the node and the fields returned by the Graph API. You can modify your query by searching for and selecting new fields, clicking the plus icon, and choosing from available fields, or unchecking unnecessary fields. These actions dynamically update your query in the query string field.
The response to your last submitted query appears here.
If your query keeps failing and you can't figure out why, and you decide to contact Developer Support, click this button to copy your query and response details to your clipboard. You can submit this information with your support request to help us figure out what's going on.
Click the Save Session button to save the state of your query, with the access token removed. Include the link to this session if you decide to contact Developer Support.
Try executing the default query that appears when you first load the Graph API Explorer. If you haven't already, open the Graph API Explorer in a new window, select the app you want to test from the application dropdown menu, and get a User access token.
The default query appears in the query string field:
The default query is requesting the id
and name
fields on the /me
node, which is a special node that maps to either the /User
or /Page
node identified by the token. Since your are using a User access token, this maps to your User node.
The id
and name
fields are publicly available and can be returned if the User has granted your app the default
or public_profile
permissions. These permissions are pre-approved for all apps (you can confirm this by clicking the information icon in the Access Token Field), so you don't have to grant your app any additional permissions for the query to work. Click Get Access Token and confirm that you want to grant your app access to your publicly available User information.
Submit your query, and you should see your app-scoped User ID and name appear in the response window.Open the Graph API Explorer
The Token dropdown menu allows you to get and exchange App, User, and Page access tokens for the currently selected app. You can also use it to uninstall your app from your User node, which destroys the current access token.
Click the information icon to see information about the current token, including the app that it's tied to, and any login permissions that have been granted by the User who is using the app (which is you).
If you are happy with your query, click the Get Code button to generate sample code based on the query. Typically you won't be able to copy and paste the sample code directly in your code base, but it gives you a useful starting point.