Skip to main content
The Facebook Graph API is a versioned REST API that lets your app read and write data on Facebook. It uses a nodes, edges, and fields model:
  • Nodes — individual objects such as a user, page, or photo (e.g. /me, /123456789)
  • Edges — connections between objects (e.g. /me/friends, /me/posts)
  • Fields — specific properties of a node or edge (e.g. name, email, id)
Requests are versioned (e.g. v21.0) and the SDK automatically appends the version configured in Settings.shared.graphAPIVersion.

How the SDK wraps Graph API

The SDK provides GraphRequest to build and execute API requests. You construct a request with a graph path and optional parameters, then call startWithCompletion(_:) to fire it. Results arrive in a completion handler on the main queue.
import FacebookCore

let request = GraphRequest(graphPath: "me", parameters: ["fields": "id,name,email"])
request.start { _, result, error in
    guard error == nil, let result = result as? [String: Any] else { return }
    print(result)
}

Authentication

Requests are authenticated using AccessToken.current. When a user is logged in via Facebook Login, the SDK automatically attaches the current access token to every request. You can also supply an explicit token string when constructing a GraphRequest:
let request = GraphRequest(
    graphPath: "me",
    parameters: ["fields": "id,name"],
    tokenString: myTokenString,
    version: nil,
    httpMethod: .get
)
If no token is available, the SDK falls back to a client token if one is configured in Settings.

Common use cases

  • Fetching the current user’s profile (/me)
  • Reading a user’s friends list (/me/friends)
  • Querying pages or groups the user manages (/me/accounts)
  • Publishing posts or actions on behalf of the user
  • Reading ad insights or campaign data

Next steps

Making requests

Build and execute single Graph API requests.

Batch requests

Execute multiple requests in a single network call.

Build docs developers (and LLMs) love