Skip to main content

REST API parameters

API parameters can be used with the REST API to filter, sort, and paginate results and to select fields and relations to populate. Additionally, specific parameters related to optional Strapi features can be used, like the publication state and locale of a content-type.

The following API parameters are available:

OperatorTypeDescription
sortString or ArraySort the response
filtersObjectFilter the response
populateString or ObjectPopulate relations, components, or dynamic zones
fieldsArraySelect only specific fields to display
paginationObjectPage through entries
publicationStateStringSelect the Draft & Publish state

Only accepts the following values:
  • live
  • preview
localeString or ArraySelect one or multiple locales

Query parameters use the LHS bracket syntax (i.e. they are encoded using square brackets [])

tip

Strapi takes advantage of the ability of the qs library to parse nested objects to create more complex queries. Use qs directly to generate complex queries instead of creating them manually.

Example using qs:

In the following example, the qs library is used to build the following URL: /api/books?sort[0]=title%3Aasc&filters[title][$eq]=hello&populate=%2A&fields[0]=title&pagination[pageSize]=10&pagination[page]=1&publicationState=live&locale[0]=en

const qs = require('qs');
const query = qs.stringify({
sort: ['title:asc'],
filters: {
title: {
$eq: 'hello',
},
},
populate: '*',
fields: ['title'],
pagination: {
pageSize: 10,
page: 1,
},
publicationState: 'live',
locale: ['en'],
}, {
encodeValuesOnly: true, // prettify URL
});

await request(`/api/books?${query}`);