Sorry, no results found for "".
For Modular Content, Structured Text and Single Block fields. If set, returns full payload for nested blocks instead of IDs
Whether you want the currently published versions (published
, default) of your records, or the latest available (current
)
"published"
Returns a resource object of type item.
GET https://site-api.datocms.com/items/:item_id HTTP/1.1Authorization: Bearer YOUR-API-TOKENAccept: application/jsonX-Api-Version: 3
curl -g 'https://site-api.datocms.com/items/:item_id' \ \ -H "Authorization: Bearer YOUR-API-TOKEN" \ -H "Accept: application/json" \ -H "X-Api-Version: 3"
await fetch("https://site-api.datocms.com/items/:item_id", { headers: { Authorization: "Bearer YOUR-API-TOKEN", Accept: "application/json", "X-Api-Version": "3", },});
HTTP/1.1 200 OKContent-Type: application/jsonCache-Control: cache-control: max-age=0, private, must-revalidateX-RateLimit-Limit: 30X-RateLimit-Remaining: 28
{ "data": { "type": "item", "id": "hWl-mnkWRYmMCSTq4z_piQ", "relationships": { "item_type": { "data": { "type": "item_type", "id": "DxMaW10UQiCmZcuuA-IkkA" } } }, "attributes": { "title": "My first blog post!", "content": "Lorem ipsum dolor sit amet...", "category": "24", "image": { "alt": "Alt text", "title": "Image title", "custom_data": {}, "focal_point": null, "upload_id": "20042921" } }, "meta": { "created_at": "2020-04-21T07:57:11.124Z", "updated_at": "2020-04-21T07:57:11.124Z", "published_at": "2020-04-21T07:57:11.124Z", "first_published_at": "2020-04-21T07:57:11.124Z", "publication_scheduled_at": "2020-04-21T07:57:11.124Z", "unpublishing_scheduled_at": "2020-04-21T07:57:11.124Z", "status": "published", "is_current_version_valid": true, "is_published_version_valid": true, "current_version": "4234", "stage": null } }}
Sometimes, you may wish to fetch a record that has embedded blocks inside Structured Text or Modular Content fields.
By default, those nested blocks are returned as references, like:
[ { "item": "ahxSnFQEQ02K3TjttWAg-Q", "type": "block" }, { "item": "AppHB06oRBm-er3oooL_LA", "type": "block" }]
But if you add the nested=true
query parameter, we'll embed the blocks content inline for you.
GET https://site-api.datocms.com/items/FEzWmQhjQgeHsCrUtvlEMw?nested=true HTTP/1.1Authorization: Bearer YOUR-API-TOKENAccept: application/jsonX-Api-Version: 3
curl -g 'https://site-api.datocms.com/items/FEzWmQhjQgeHsCrUtvlEMw?nested=true' \ \ -H "Authorization: Bearer YOUR-API-TOKEN" \ -H "Accept: application/json" \ -H "X-Api-Version: 3"
await fetch( "https://site-api.datocms.com/items/FEzWmQhjQgeHsCrUtvlEMw?nested=true", { headers: { Authorization: "Bearer YOUR-API-TOKEN", Accept: "application/json", "X-Api-Version": "3", }, },);
HTTP/1.1 200 OKContent-Type: application/jsonCache-Control: cache-control: max-age=0, private, must-revalidateX-RateLimit-Limit: 30X-RateLimit-Remaining: 28
{ "data": { "id": "FEzWmQhjQgeHsCrUtvlEMw", "type": "item", "attributes": { "structured_text_field": { "schema": "dast", "document": { "children": [ { "item": { "type": "item", "attributes": { "button_label": "Example button", "button_url": "https://www.example.com" }, "relationships": { "item_type": { "data": { "id": "SkVjHJSGR5CyK16E8TfJxg", "type": "item_type" } } }, "id": "ahxSnFQEQ02K3TjttWAg-Q" }, "type": "block" }, { "item": { "type": "item", "attributes": { "nested_structured_text_field": { "schema": "dast", "document": { "children": [ { "children": [ { "type": "span", "value": "This is a " }, { "marks": ["emphasis"], "type": "span", "value": "nested" }, { "type": "span", "value": " structured text block inside the parent structured text field." } ], "type": "paragraph" }, { "item": { "type": "item", "attributes": { "button_label": "And this is a button inside the nested structured text block", "button_url": "https://www.example2.com" }, "relationships": { "item_type": { "data": { "id": "SkVjHJSGR5CyK16E8TfJxg", "type": "item_type" } } }, "id": "CGqwjPDsTHKGFy1IbC0RAQ" }, "type": "block" } ], "type": "root" } } }, "relationships": { "item_type": { "data": { "id": "Ty4S40cbQH6_VMNnGdd9KA", "type": "item_type" } } }, "id": "AppHB06oRBm-er3oooL_LA" }, "type": "block" } ], "type": "root" } } }, "relationships": { "item_type": { "data": { "id": "UVa_hHEBSeefLEUnwoQFig", "type": "item_type" } }, "creator": { "data": { "id": "104280", "type": "account" } } }, "meta": { "created_at": "2024-03-13T17:01:19.243+00:00", "updated_at": "2024-03-13T17:14:17.444+00:00", "published_at": "2024-03-13T17:14:17.597+00:00", "publication_scheduled_at": null, "unpublishing_scheduled_at": null, "first_published_at": "2024-03-13T17:01:19.326+00:00", "is_valid": true, "is_current_version_valid": true, "is_published_version_valid": true, "status": "published", "current_version": "DLtyHZ2MTDqYMg7g5mgYEw", "stage": null } }}