Query Parameters

Learn about Directus query parameters - fields, filter, search, sort, limit, offset, page, aggregate, groupBy, deep, alias, and export. Understand how to customize your API requests and retrieve specific data from your collections.

Most Directus API endpoints can use global query parameters to alter the data that is returned.

Fields

Specify which fields are returned. This parameter also supports dot notation to request nested relational fields, and wildcards (*) to include all fields at a specific depth.

{
  "fields": ["first_name", "last_name", { "avatar": ["description"] }]
}
Examples
ValueDescription
first_name,last_nameReturn only the first_name and last_name fields.
title,author.nameReturn title and the related author item's name field.
*Return all fields.
*.*Return all fields and all immediately related fields.
*,images.*Return all fields and all fields within the images relationship.
Wildcards and performance While wildcards are very useful, we recommend only requesting specific fields in production. By only requesting the fields you need, you can speed up the request, and reduce the overall output size.

Many to Any Fields

As Many to Any (M2A) fields have nested data from multiple collections, you are not always able to fetch the same field from every related collection. In M2A fields, you can use the following syntax to specify what fields to fetch from which related nested collection type: ?fields=m2a-field:collection-scope.field

Example
In an posts collection there is a Many to Any field called sections that points to headings, paragraphs, and videos. Different fields should be fetched from each related collection.
import { createDirectus, rest, readItems } from "@directus/sdk";
const directus = createDirectus("https://directus.example.com").with(rest());

const result = await directus.request(
readItems("posts", {
filter: {
  title: {
    _eq: "Hello",
  },
},
}),
);
Large limits and performance
Depending on the size of your collection, fetching the maximum amount of items may result in degraded performance or timeouts.The maximum number of items that can be requested on the API can be configured using the QUERY_LIMIT_MAX environment variable. This cannot be overridden by changing the value of limit.
Example
Only get 3 related posts, with only the top rated comment nested:
{
"deep": {
"related_posts": {
  "_limit": 3,
  "comments": {
    "_sort": "rating",
    "_limit": 1
  }
}
}
}
Aliases in combination with other features
Aliases support being used in combination with:
  1. functions, e.g. alias[release_year]=year(released)
  2. in the deep query parameter, e.g. deep[author][_alias][birthyear]=year(birthday)
Note that it is not possible to use aliases on relational fields e.g. alias[author_name]=author.name and not possible to have . in the alias name itself e.g. alias[not.possible]=field.
Reserved version keys The keys published and draft are reserved. Use published (or main for backward compatibility) to explicitly fetch the published base item. Use draft to fetch the global draft version.
Wildcard Only
The backlink parameter only affects *.* wildcard field expansion. Explicitly specified field names are not filtered. For example: fields=author.articles will still include the reverse relation even when backlink=false.
Example
Red lines mark the response when backlink is set to true while green marks when backlinks is set to false. The articles collection consists of a many-to-one relation to Users called author and a many-to-many relation to Tags called tags.
GET /items/articles?fields=*.*.*&backlink=true / false
{
"data": [
{
  "id": 1,
  "title": "My first Article",
  "author": {
    "id": 2,
    "name": "Nils",
    "articles": [
      {         "id": 1,         "title": "My first Article",         "author": {           "id": 2,           "name": "Nils",           "articles": [1]         },         "tags": [           {             "id": 3,             "articles_id": 1,             "tags_id": 4          }         ]       }       1    ]
  },
  "tags": [
    {
      "id": 3,
      "articles_id": {         "id": 1,         "title": "My first Article",         "author": {           "id": 2,           "name": "Nils",           "articles": [1]         },          "tags": [           {             "id": 3,             "articles_id": 1,             "tags_id": 4          }         ]       },       "articles_id": 1,       "tags_id": {
        "id": 4,
        "tag": "Tag1",
        "articles": [
          {             "id": 3,             "articles_id": 1,             "tags_id": 4          }           3        ]
      }
    }
  ]
}
]
}

Get once-a-month release notes & real‑world code tips...no fluff. 🐰