Skip to main content

Perform a List Objects call

This section will illustrate how to perform a list objects request to determine all the objects of a given type a user has a specified relationship with.

Before You Start

  1. Deploy an instance of the OpenFGA server, and have ready the values for your setup: FGA_STORE_ID, FGA_API_URL and, if needed, FGA_API_TOKEN.
  2. You have installed the SDK.
  3. You have configured the authorization model and updated the relationship tuples.
  4. You have loaded FGA_STORE_ID and FGA_API_URL as environment variables.

Step By Step

Assume that you want to list all objects of type document that user anne has reader relationship with:

01. Configure the OpenFGA API Client

Before calling the check API, you will need to configure the API client.

// import the SDK
const { OpenFgaClient } = require('@openfga/sdk');

// Initialize the SDK with no auth - see "How to setup SDK client" for more options
const fgaClient = new OpenFgaClient({
apiUrl: process.env.FGA_API_URL, // required, e.g. https://api.fga.example
storeId: process.env.FGA_STORE_ID,
authorizationModelId: process.env.FGA_MODEL_ID, // Optional, can be overridden per request

02. Calling List Objects API

To return all documents that user user:anne has relationship reader with:

const response = await fgaClient.listObjects({
user: "user:anne",
relation: "reader",
type: "document",
}, {
authorization_model_id: "01HVMMBCMGZNT3SED4Z17ECXCA",
// response.objects = ["document:otherdoc", "document:planning"]

The result document:otherdoc and document:planning are the document objects that user:anne has reader relationship with.


The performance characteristics of the ListObjects endpoint vary drastically depending on the model complexity, number of tuples, and the relations it needs to evaluate. Relations with 'and' or 'but not' are more expensive to evaluate than relations with 'or'.

OpenFGA List Objects API

Read the List Objects API documentation and see how it works.