My Docs
My BlogPython Data StructuresRepoFamily-Promise-Docs
Web-Dev-Hub-Docs
Web-Dev-Hub-Docs
  • Home
  • Navigation
  • Tools
    • Tools
      • Docker
      • G-Cloud & Firebase
      • Heroku
      • Dropbox
      • Email
      • Tools
      • DuckDuckGo
      • Elasticsearch
      • CodeSandbox
      • Product Hunt
      • Raycast
      • Elasticsearch
      • Tools
      • Showcase
        • Utilities
        • Continued
          • Page 3:
    • Downloads
    • REPL.IT Compilations
      • Part 2
    • Past Notes
      • Command Line Reference
    • Git
    • JavaScript
      • Interview Problems
      • General JavaScript Notes
      • jQuery
      • NodeJS
        • Node argv
        • NPM
        • Express
          • ExpressJS Overview
          • Sequelize
      • Regex
      • React
        • React Examples:
        • Redux
        • Redux Docs
          • Redux Resources
        • React Notes
    • My Bash Commands
    • Learning
  • Programming Languages
    • Programming Languages
      • File System
      • Basics
      • PSEUDO Programing Languages
        • HTML
      • CSS
      • List Of Programming Languages By Type
      • Tools-Of-The-Trade
        • Linux
        • Docker
      • Git
      • Python
        • Pydrive:
        • Practice
        • Pipenv
        • Untitled
      • Bash
        • SED
      • CHEATSHEETS
      • Java
      • Html
      • Markdown
      • CSS
      • SCSS
      • C & C++
      • Ruby
      • SQL
        • PostgreSQL
      • Jest
      • JavaScript
      • Typescript
      • C++
      • Babel
    • What is a Programming Language?
  • Python
    • Python
      • Python General Notes
      • Python Quiz
      • Python Cheat Sheet
      • Python Snippets
      • Python at length
    • Install PIP
  • JavaScript
    • JavaScript
      • Jquery
      • Page 16
    • Writing Files
    • JS-Leetcode
  • Web Development Frameworks & Libraries
    • GRAPHQL
    • React
    • Jquery
      • Prac
    • GATSBY
      • Untitled
      • Building with Components
      • Plugins, Themes, & Starters
      • GraphQL Concepts
  • Productivity
    • Productivity
      • Awesome Productivity Tools for Back-to-School
  • Misc
    • Misc
      • Experiments
  • GitGateway
    • Links
    • Bookmarks
  • Websites
    • Websites
    • Not My Websites:
    • Articles
  • Backend
    • Backend
  • Networking
    • Networks
  • Resources
    • Web Dev Tutorials
      • Node
        • API Security
    • Resources
    • Video Resources
  • General Knowledge
    • General Knowledge
    • Glossary
    • Knowledge Bank
  • Finance
    • Finance
    • Finance Reference
    • Financial Trends
  • Science & Tech (Innovation)
    • Science & Tech
    • Articles
  • Reading
    • Reading
  • Social Media & Trends
    • Trends In Web Dev
    • Analytics
    • FB-Dev-Open Source
      • Content Publishing
    • IG-API
  • Docs
    • Docs
      • NodeJS
        • installed it?
        • Timers in Node.js and beyond
        • Node.js web app
        • Overview of Blocking vs Non-Blocking
        • Don't Block the Event Loop (or the Worker Pool)
  • Code Editors & Tools
    • Vscode
      • Vscode Docs
      • How To Speed Up Vscode
  • Cool Stuff
    • Cool Observable Notebooks
  • Server-Side
    • GraphQL
      • Intro
    • Rest VS GraphQl
    • REST-API
    • Public APIs
  • WEB_DEV_TOOLS
    • Web Dev Tools
    • Cloudinary
    • Postman
      • Creating an API
      • Trouble Shooting Postman
    • Netlify
      • Facebook Graph API
      • Pandoc
      • Graph API
      • Troubleshooting
      • Examples
      • HTTPS (SSL)
      • Open Authoring
      • Netlify CMS
      • Git Gateway
  • DS_ALGOS_BRAINTEASERS
    • A Quick Guide to Big-O Notation, Memoization, Tabulation, and Sorting Algorithms by Example
  • Free-Stuff
    • Free Stuff
  • Job-Search
    • Job Search
    • Outreach
  • General Comp Sci
    • Principles behind the Agile Manifesto
  • Blockchain & Crypto
    • Blockchain Basics
      • Basics:
  • Data Structures & Interviewing
    • Data Structures
    • Computational Complexity
  • REACT_REVISITED
    • Modern React with Redux
      • React-Projects
  • WEBDEV-Bootcamp-Notes
    • 🏫Lambda
      • 1.1 - User Interface and Git
      • Page 2
      • Page 1
      • Page 3
      • Page 4
      • Page 5
      • Page 6
      • Page 7
      • Page 8
      • Page 9
      • Page 10
      • Page 11
      • Page 12
      • Page 13
      • Page 14
      • Page 15
      • CS-Python-Notes
        • Python
  • Unsorted-Notes
    • Compiled-Random-Notes
    • Testing:
      • Configure Jest for Testing JavaScript Applications
      • install, configure, and script Cypress for JavaScript web applications
      • Test React Components with Jest and `react-testing-library`
      • Use testing library to evaluate any framework...
  • Medium-articles
    • My Articles
      • Python For JS Developers
      • JavaScript Programmer
      • Awesome Web Development Youtube Video Archive
      • Bash Commands That Save Me Time and Frustration
      • Git-Tricks
      • scrap
      • Medium Article
      • Everything You Need To Know About Relational Databases, SQL, PostgreSQL and Sequelize To Build…
      • Machine Learner
      • Here’s the expanded list:
      • The Complete JavaScript Reference Guide
      • This is really cool!
      • Web Development Interview Part 3💻
      • Mutability And Reference VS Privative Types in JavaScript
      • React
      • Super Simple Intro To HTML
      • Introduction to React for Complete Beginners
      • Web Developer Resource List Part 2
      • Front End Interview Questions Part 2
      • A List Of Tools For Improvement
      • Github Repositories That Will Teach You How To Code For Free!
      • Libraries
      • Machine Learner
      • Here’s the expanded list:
      • The Complete JavaScript Reference Guide
  • 🖲️AI
    • Pytorch
      • Documentation
  • 🎙️Audio
    • Audio
Powered by GitBook
On this page
  • Overview
  • HTTP
  • Host URL
  • Access Tokens
  • Nodes
  • /me
  • Edges
  • Fields
  • Publishing, Updating, and Deleting
  • Versions
  • Facebook APIs, SDKs, and Platforms
  • Next Steps
  • Guides
  • Graph API Reference

Was this helpful?

  1. WEB_DEV_TOOLS
  2. Netlify

Graph API

PreviousPandocNextTroubleshooting

Last updated 3 years ago

Was this helpful?

Overview

The Graph API is the primary way to get data into and out of the Facebook platform. It's an HTTP-based API that apps can use to programmatically query data, post new stories, manage ads, upload photos, and perform a wide variety of other tasks.

The Graph API is named after the idea of a "social graph" — a representation of the information on Facebook. It's composed of nodes, edges, and fields. Typically you use nodes to get data about a specific object, use edges to get collections of objects on a single object, and use fields to get data about a single object or each object in a collection. Throughout our documentation, we may refer to both a node and edge as an "endpoint". For example, "send a GET request to the User endpoint".

HTTP

All data transfers conform to HTTP/1.1, and all endpoints require HTTPS. Because the Graph API is HTTP-based, it works with any language that has an HTTP library, such as cURL and urllib. This means you can use the Graph API directly in your browser. For example, requesting this URL in your browser...

... is equivalent to performing this cURL request:

curl -i -X GET "https://graph.facebook.com/facebook/picture?redirect=false"

We have also enabled the includeSubdomains HSTS directive on facebook.com, but this should not adversely affect your Graph API calls.

Host URL

Almost all requests are passed to the graph.facebook.com host URL. The single exception is video uploads, which use graph-video.facebook.com.

Access Tokens

Access tokens allow your app to access the Graph API. Almost all Graph API endpoints require an access token of some kind, so each time you access an endpoint, your request may require one. They typically perform two functions:

  • They allow your app to access a User's information without requiring the User's password. For example, your app needs a User's email to perform a function. If the User agrees to allow your app to retrieve their email address from Facebook, the User will not need to enter their Facebook password for your app to get their email address.

  • They allow us to identify your app, the User who is using your app, and the type of data the User has permitted your app to access.

Nodes

A node is an individual object with a unique ID. For example, there are many User node objects, each with a unique ID representing a person on Facebook. Pages, Groups, Posts, Photos, and Comments are just some of the nodes of the Facebook Social Graph.

The following cURL example represents a call to the User node.

curl -i -X GET \
  "https://graph.facebook.com/USER-ID?access_token=ACCESS-TOKEN"

This request would return the following data by default, formatted using JSON:

{
  "name": "Your Name",
  "id": "YOUR-USER-ID"
}

Node Metadata

You can get a list of all fields, including the field name, description, and data type, of a node object, such as a User, Page, or Photo. Send a GET request to an object ID and include the metadata=1 parameter:

curl -i -X GET \
  "https://graph.facebook.com/USER-ID?
    metadata=1&access_token=ACCESS-TOKEN"

The resulting JSON response will include the metadata property that lists all the supported fields for the given node:

{
  "name": "Jane Smith",
  "metadata": {
    "fields": [
      {
        "name": "id",
        "description": "The app user's App-Scoped User ID. This ID is unique to the app and cannot be used by other apps.",
        "type": "numeric string"
      },
      {
        "name": "age_range",
        "description": "The age segment for this person expressed as a minimum and maximum age. For example, more than 18, less than 21.",
        "type": "agerange"
      },
      {
        "name": "birthday",
        "description": "The person's birthday.  This is a fixed format string, like `MM/DD/YYYY`.  However, people can control who can see the year they were born separately from the month and day so this string can be only the year (YYYY) or the month + day (MM/DD)",
        "type": "string"
      },
...

/me

The /me node is a special endpoint that translates to the object ID of the person or Page whose access token is currently being used to make the API calls. If you had a User access token, you could retrieve a User's name and ID by using:

curl -i -X GET \
  "https://graph.facebook.com/me?access_token=ACCESS-TOKEN"

Edges

An edge is a connection between two nodes. For example, a User node can have photos connected to it, and a Photo node can have comments connected to it. The following cURL example will return a list of photos a person has published to Facebook.

curl -i -X GET \
  "https://graph.facebook.com/USER-ID/photos?access_token=ACCESS-TOKEN"

Each ID returned represents a Photo node and when it was uploaded to Facebook.

    {
  "data": [
    {
      "created_time": "2017-06-06T18:04:10+0000",
      "id": "1353272134728652"
    },
    {
      "created_time": "2017-06-06T18:01:13+0000",
      "id": "1353269908062208"
    }
  ],
}

Fields

Fields are node properties. When you query a node, or an edge, it returns a set of fields by default, as the examples above show. However, you can specify which fields you want returned by using the fields parameter and listing each field. This overrides the defaults and returns only the fields you specify, and the ID of the object, which is always returned.

The following cURL request includes the fields parameter and the User's name, email, and profile picture.

curl -i -X GET \
  "https://graph.facebook.com/USER-ID?fields=id,name,email,picture&access_token=ACCESS-TOKEN"

Data Returned

{
  "id": "USER-ID",
  "name": "EXAMPLE NAME",
  "email": "EXAMPLE@EMAIL.COM",
  "picture": {
    "data": {
      "height": 50,
      "is_silhouette": false,
      "url": "URL-FOR-USER-PROFILE-PICTURE",
      "width": 50
    }
  }
}

Complex Parameters

Most parameter types are straightforward primitives such as bool, string and int, but there are also list and object types that can be specified in the request.

The list type is specified in JSON syntax, for example: ["firstitem", "seconditem", "thirditem"]

The object type is also specified in JSON syntax, for example: {"firstkey": "firstvalue", "secondKey": 123}

Publishing, Updating, and Deleting

Some nodes allow you to update fields with POST operations. For example, you could update your email field like this:

curl -i -X POST \
  "https://graph.facebook.com/USER-ID?email=YOURNEW@EMAILADDRESS.COM&access_token=ACCESS-TOKEN"

Read-After-Write

For create and update endpoints, the Graph API can immediately read a successfully published or updated object and return any fields supported by the corresponding read endpoint.

By default, an ID of the object created or updated will be returned. To include more information in the response, include the fields parameter in your request and list the fields you want returned. For example, to publish the message “Hello” to a Page's feed, you could make the following request:

curl -i - X POST "https://graph.facebook.com/PAGE-ID/feed?message=Hello&
  fields=created_time,from,id,message&access_token=ACCESS-TOKEN"

The above code example is formatted for readability.

This would return the specified fields as a JSON-formatted response, like this:

{
  "created_time": "2017-04-06T22:04:21+0000",
  "from": {
    "name": "My Facebook Page",
    "id": "PAGE-ID"
  },
  "id": "POST_ID",
  "message": "Hello",
}

Errors

You can usually delete a node, such as a Post or Photo node, by performing a DELETE operation on the object ID:

curl -i -X DELETE \
  "https://graph.facebook.com/PHOTO-ID?access_token=ACCESSS-TOKEN"

Usually you can only delete nodes that you created, but check each node's reference guide to see requirements for delete operations.

Versions

The Graph API has multiple versions with quarterly releases. You can specify the version in your calls by adding "v" and the version number to the start of the request path. For example, here's a call to version 4.0:

curl -i -X GET \
  "https://graph.facebook.com/v4.0/USER-ID/photos
    ?access_token=ACCESS-TOKEN"

If you do not include a version number we will default to the oldest available version, so it's recommended to include the version number in your requests.

Facebook APIs, SDKs, and Platforms

Next Steps

Guides

Various Guides for how to use the Facebook Graph API to send and receive data to the Facebook Social Graph.

Batch Requests

Debugging

Error Handling

The Handling Errors guide describes the recovery tactics and provides a list of error values with a map to the most common recovery tactic to use.

Graph Explorer Guide

Upload Files

The Upload Files guide describes how to upload photos and videos to the Facebook Social Graph that can then be shared in User, Group, or Page posts.

Graph API Reference

Graph API Root Nodes

Node
Description

An individual app request received by someone, sent by an app or another person

A Facebook app

Represents an async job request to Graph API

An Atlas AdSet

An Atlas Campaign

Conversion Event Node

An Atlas Publisher

An Atlas Report

An Atlas ReportRun

An Atlas ReportSchedule

An Ad Platform Tracking Connection

Represents a group of certain types of Business objects in a Business. Will be used by Measurement Hub initially with more usage coming later on.

Returns a recommendation of a single retailer for a specific brand. This endpoint returns a retailer-brand pair and an advertiser who can advertise on behalf of the producer.

A domain name that has been issued new certificates.

A canvas document

A button inside the canvas

A carousel inside a canvas

A footer of the canvas

A header inside the canvas.

A photo inside a canvas

A product list inside the canvas

A product set inside the canvas

A store locator inside the canvas

Text element of the canvas

A video inside canvas

A comment can be made on various types of content on Facebook. Most Graph API nodes have a /comments edge that lists all the comments on that object. The /comment node returns a single comment.

Commerce Merchant Settings object

Represents an order placed directly on Facebook or Instagram

Graph API Reference Conversation /conversation

Represents a destination in a catalog

A Document

Get fields and edges on an Event.

Represents a flight in a catalog

This represents a user's friend list on Facebook

A Facebook group.

Graph API Reference Group Doc /group-doc

GroupMessage

Represents a copyright on an image asset.

InstagramOembed

A lead ad form

A link shared on a wall.

Get fields and edges on a LiveEncoder.

Get fields and edges on a LiveVideo.

An ingest stream for a live video

A mailing address object

Media fingerprint

An individual message in the Facebook messaging system.

Graph API Reference Milestone /milestone

A native offer represents an Offer on Facebook. The /{offer_id} node returns a single native offer. Each native offer requires a view to be rendered to users.

This reference describes the /comments edge that is common to multiple Graph API nodes. The structure and operations are the same for each node.

This reference describes the /likes edge that is common to multiple Graph API nodes. The structure and operations are the same for each node.

Private replies for an object

First revision to publish

Graph API Reference /object/sharedposts

OembedPage

OembedPost

OembedVideo

A Data Set for Offline Conversions object

A subset of Offline Event Data Set

Get groups a Page is a member of.

Page's call-to-action

A Facebook feed story

Notification of page upcoming changes.

This object represents a single Insights metric that is tied to another particular Graph API object (Page, App, Post, etc.).

Graph API Reference Payment /payment

This represents a Photo on Facebook.

A place

The category of a place Page

A Facebook Feed story

Graph API Reference Profile /profile

A dynamically generated Post, used for Dynamic Ad Creatives

Graph API Reference Request /request

Represents settings specific to local inventory of a product catalog

Graph API Reference Test User /test-user

Graph API Reference Thread /thread

Get fields and edges on a User.

A Video

A video copyright

A video copyright rules

A playlist for videos

Embedded video poll

Represents a single poll option that may be selected by the user

Returns the account information of a WhatsApp Business Account

Returns information about a specific phone number.

Retrieves information about the message template

Graph API Root Edges

Root edges are edges that can be queried directly. They allow you to access collections of nodes that are not on a parent node.

Node
Description

Returns archived ads based on your search. By default we only return all ads that are eligible for delivery and that have the ACTIVE status.

DebugToken

Visit our to learn more.

Visit our to learn how to publish to a User's Facebook or our to publish to a Page's Facebook feed.

Refer to each endpoint's to see if it supports read-after-write and what fields are available.

If the read fails for any reason (for example, requesting a non-existent field), the Graph API will respond with a standard error response. Visit our for more information.

You can read more about versions in our and learn about all available versions in the .

Connect interfaces and develop across platforms using Facebook's various .

– Let's explore the Facebook Social Graph using the Graph Explorer tool and run a couple requests to get data.

The guide describes how to make multiple Graph API requests in one call.

The describes how to enable Debug Mode to view Graph API responses that may contain additional fields that explain potential issues with an API call.

The describes how to use the Graph Explorer tool](/tools/explorer). This tool allows you to construct, test, and debug queries and see their responses for any apps on which you have an admin, developer, or tester role.

This is a full list of the Graph API root nodes. The main difference between a root node and a non-root node is that root nodes can be queried directly, while non-root nodes can be queried via root nodes or edges. If you want to learn how to use the Graph API, read our , and if you want to know which APIs can solve some frequent issues, try our .

Get and on an Album.

This endpoint is mainly for Facebook’s Marketing Partners using .

A collaboration request is a partnership request coming from a brand or agency to a retailer or marketing partner. Used for .

Directory of retailers that use . This endpoint must be used in conjunction with the collaborative_ads_merchants field below.

https://graph.facebook.com/facebook/picture?redirect=false
access token documentation
Facebook Sharing guide
Pages API documentation
reference documentation
Handling Errors guide
Versioning guide
Graph API Changelog
APIs, SDKs, and platforms
Get Started with Graph API
Batch Requests
Debug Requests guide
Graph API Explorer guide
Using Graph API guide
Common Scenarios guide
Album
Fields
Edges
App Request
Application
Async Session
Atlas Ad Set
Atlas Campaign
Atlas FBConversion Event
Atlas Publisher
Atlas Report
Atlas Report Run
Atlas Report Schedule
Atlas Tracking Connection
Business Unit
CPASAdvertiser Partnership Recommendation
Collaborative Ads
CPASCollaboration Request
Collaborative Ads
CTCert Domain
Canvas
Canvas Button
Canvas Carousel
Canvas Footer
Canvas Header
Canvas Photo
Canvas Product List
Canvas Product Set
Canvas Store Locator
Canvas Text
Canvas Video
Collaborative Ads Directory
Collaborative Ads
Comment
Commerce Merchant Settings
Commerce Order
Conversation
Destination
Doc
Event
Flight
Friend List
Group
Group Doc
Group Message
Image Copyright
Instagram Oembed
Lead Gen Data
Link
Live Encoder
Live Video
Live Video Input Stream
Mailing Address
Media Fingerprint
Message
Milestone
Native Offer
Object Comments
Object Likes
Object Private Replies
Object Reactions
Object Sharedposts
Oembed Page
Oembed Post
Oembed Video
Offline Conversion Data Set
Offline Conversion Data Set Upload
Page
Page Call To Action
Page Post
Page Upcoming Change
Page/insights
Payment
Photo
Place
Place Topic
Post
Profile
RTBDynamic Post
Request
Store Catalog Settings
Test User
Thread
User
Video
Video Copyright
Video Copyright Rule
Video List
Video Poll
Video Poll Option
Whats App Business Account
Whats App Business Account To Number Current Status
Whats App Business HSM
Ads Archive
Debug Token