To retrieve a collection of records, send a GET request to the /items
endpoint. The collection is paginated, so make sure to iterate over all the pages if you need every record in the collection!
The following table contains the list of all the possible arguments, along with their type, description and examples values.
Pro tip: in case of any doubts you can always inspect the network calls that the CMS interface is doing, as it's using the Content Management API as well!
For Modular Content, Structured Text and Single Block fields. If set, returns full payload for nested blocks instead of IDs
Attributes to filter records
Record (or block record) IDs to fetch, comma separated. If you use this filter, you must not use filter[type]
or filter[fields]
"c89tCUarTvGKxA37acCEWA,aCiWeOsUT3mxY0KIzUfAhw"
Model ID or api_key
to filter. If you use this filter, you must not use filter[ids]
. Comma separated values are accepted, but you must not use filter[fields]
in this case
"cat,dog"
Textual query to match. You must not use filter[ids]
. If locale
is defined, search within that locale. Otherwise environment's main locale will be used.
"foo"
Same as GraphQL API records filters: you must use square brackets to indicate nesting levels. E.g. if you wanna filter by parent record in a tree of records, you must use filter[fields][parent][eq]=<ID_VALUE>
. Use snake_case for fields names. If locale
is defined, search within that locale. Otherwise environment's main locale will be used.
{ name: { eq: "Buddy" } }
When set, only valid records are included in the results.
"true"
When filter[query]
or field[fields]
is defined, filter by this locale. Default: environment's main locale
"it"
Parameters to control offset-based pagination
The (zero-based) offset of the first entity returned in the collection (defaults to 0)
200
The maximum number of entities to return (defaults to 30, maximum is 500)
Fields used to order results. You must specify also filter[type]
with one element only to be able use this option. Format: <field_name>_(ASC|DESC)
, where <field_name>
can be either the API key of a model's field, or one of the following meta columns: id
, _updated_at
, _created_at
, _status
, _published_at
, _first_published_at
, _publication_scheduled_at
, _unpublishing_scheduled_at
, _is_valid
, position
(only for sortable models). You can pass multiple comma separated rules.
"name_DESC"
Whether you want the currently published versions (published
, default) of your records, or the latest available (current
)
"current"
Returns an array of resource objects of type item.
If you don't specify any parameters, we'll simply return the first 30 records. They can be from any model in your project.
To fetch a specific page, you can use the page
object in the query params together with its offset
and limit
parameters. They will still be from any model in your project.
To get 2 records starting from position 4, we should use: ?page[limit]=2page[offset]=3
(because record counting starts from 0)
To get 2 records starting from position 4, we should use: ?page[limit]=2page[offset]=3
(because record counting starts from 0)
To get 2 records starting from position 4, we should use: ?page[limit]=2page[offset]=3
(because record counting starts from 0)
You can retrieve a list of records (or blocks) by their record IDs. They can be from the same or different models.
Filtering by 2 specific record IDs, across different models (one dog record, and one song record). Note that filter[ids]
must be comma-separated, with no spaces.
Filtering by 2 specific record IDs, across different models (one dog record, and one song record). Note that filter[ids]
must be comma-separated, with no spaces.
Filtering by 2 specific record IDs, across different models (one dog record, and one song record). Note that filter[ids]
must be comma-separated, with no spaces.
Showing two records from different models: dog and song. The returned record order is random, not the order of the record IDs you specified.
You can filter the records by one or more model types. You can use either the model's api_key
(that you define) or its unique ID (generated by DatoCMS). Multiple comma-separated values are accepted:
Filtering by the model with api_key cat
and the model with ID of dog
:
Filtering by the model with api_key cat
and the model with ID of dog
:
Filtering by the model with api_key cat
and the model with ID of dog
:
Within a specified model, you can further filter its records by their field values.
You must specify a single model using filter[type]
. You cannot filter by field value across multiple models at once.
Valid filters are documented at GraphQL API records filters, so please check there. However, you cannot use deep filtering on Modular Content and Structured Text fields at the moment.
locale
parameter if you are filtering by a localized field.order_by
parameter.In this example, we are filtering the model dog
by:
name in ['Buddy','Rex']
(matching Buddy
OR Rex
)breed eq 'mixed'
(matching exactly mixed
)_updated_at
) (and ordering the results by the same)Note the special handling of the in
filter for the name
field. Instead of a comma-separated string, it's two separate [fields][name][in][]
parameters.
Note the special handling of the in
filter for the name
field. Instead of a comma-separated string, it's two separate [fields][name][in][]
parameters.
Note the special handling of the in
filter for the name
field. Instead of a comma-separated string, it's two separate [fields][name][in][]
parameters.
You can retrieve a list of records filtered by a textual query match. It will search in block records content too. Set the nested
parameter to true
to retrieve embedded block content as well.
You can narrow your search to some models by specifying the field[type]
attribute. You can use either the model's api_key
or its unique ID. Multiple comma-separated values are accepted.
You should specify the locale
attribute, or it use the environment's default locale.
Returned records are ordered by rank.
Sometimes, you may wish to fetch a record that has embedded blocks inside Structured Text or Modular Content fields.
By default, we would return those nested blocks as references, like:
But if you add the nested=true
query parameter, we'll embed the block content inline for you.
When nested=true
, the maximum records you can request at once is limited to 30, compared to the usual 500.
1GET https://site-api.datocms.com/items?filter[ids]=FEzWmQhjQgeHsCrUtvlEMw&nested=true HTTP/1.12Authorization: Bearer YOUR-API-TOKEN3Accept: application/json4X-Api-Version: 3
1curl -g 'https://site-api.datocms.com/items?filter[ids]=FEzWmQhjQgeHsCrUtvlEMw&nested=true' \2 \3 -H "Authorization: Bearer YOUR-API-TOKEN" \4 -H "Accept: application/json" \5 -H "X-Api-Version: 3"
1await fetch(2 "https://site-api.datocms.com/items?filter[ids]=FEzWmQhjQgeHsCrUtvlEMw&nested=true",3 {4 headers: {5 Authorization: "Bearer YOUR-API-TOKEN",6 Accept: "application/json",7 "X-Api-Version": "3",8 },9 },10);
1HTTP/1.1 200 OK2Content-Type: application/json3Cache-Control: cache-control: max-age=0, private, must-revalidate4X-RateLimit-Limit: 305X-RateLimit-Remaining: 286
7{8 "data": [9 {10 "id": "FEzWmQhjQgeHsCrUtvlEMw",11 "type": "item",12 "attributes": {13 "structured_text_field": {14 "schema": "dast",15 "document": {16 "children": [17 {18 "item": {19 "type": "item",20 "attributes": {21 "button_label": "Example button",22 "button_url": "https://www.example.com"23 },24 "relationships": {25 "item_type": {26 "data": {27 "id": "SkVjHJSGR5CyK16E8TfJxg",28 "type": "item_type"29 }30 }31 },32 "id": "ahxSnFQEQ02K3TjttWAg-Q"33 },34 "type": "block"35 },36 {37 "item": {38 "type": "item",39 "attributes": {40 "nested_structured_text_field": {41 "schema": "dast",42 "document": {43 "children": [44 {45 "children": [46 {47 "type": "span",48 "value": "This is a "49 },50 {51 "marks": ["emphasis"],52 "type": "span",53 "value": "nested"54 },55 {56 "type": "span",57 "value": " structured text block inside the parent structured text field."58 }59 ],60 "type": "paragraph"61 },62 {63 "item": {64 "type": "item",65 "attributes": {66 "button_label": "And this is a button inside the nested structured text block",67 "button_url": "https://www.example2.com"68 },69 "relationships": {70 "item_type": {71 "data": {72 "id": "SkVjHJSGR5CyK16E8TfJxg",73 "type": "item_type"74 }75 }76 },77 "id": "CGqwjPDsTHKGFy1IbC0RAQ"78 },79 "type": "block"80 }81 ],82 "type": "root"83 }84 }85 },86 "relationships": {87 "item_type": {88 "data": {89 "id": "Ty4S40cbQH6_VMNnGdd9KA",90 "type": "item_type"91 }92 }93 },94 "id": "AppHB06oRBm-er3oooL_LA"95 },96 "type": "block"97 }98 ],99 "type": "root"100 }101 }102 },103 "relationships": {104 "item_type": {105 "data": {106 "id": "UVa_hHEBSeefLEUnwoQFig",107 "type": "item_type"108 }109 },110 "creator": {111 "data": {112 "id": "104280",113 "type": "account"114 }115 }116 },117 "meta": {118 "created_at": "2024-03-13T17:01:19.243+00:00",119 "updated_at": "2024-03-13T17:14:17.444+00:00",120 "published_at": "2024-03-13T17:14:17.597+00:00",121 "publication_scheduled_at": null,122 "unpublishing_scheduled_at": null,123 "first_published_at": "2024-03-13T17:01:19.326+00:00",124 "is_valid": true,125 "is_current_version_valid": true,126 "is_published_version_valid": true,127 "status": "published",128 "current_version": "DLtyHZ2MTDqYMg7g5mgYEw",129 "stage": null130 }131 }132 ],133 "meta": {134 "total_count": 1135 }136}