Retrieve a record
Begin by reading the Introduction to records guide to familiarize yourself with field types, API response modes, and the concepts of block manipulation!
To retrieve a single record, send a GET request to the /items/:id endpoint.
Response modes: Regular vs. Nested
The GET /items/:id endpoint, just like the List all records endpoint, supports two different response modes that control how block fields are returned in the JSON payload. You can switch between them using the nested query parameter.
-
Regular mode (default): This is the most efficient mode for listing records. Any block fields (like Modular Content) will contain an array of block IDs, not the full block content. This keeps the response size small and fast.
-
Nested mode (
nested=true): This mode returns the complete content for any block fields. Instead of just IDs, the API will return full block objects, including all their attributes. This is useful when you need to display the blocks' content immediately without making additional API calls, or to read existing content and then make an update.
GET https://site-api.datocms.com/items/:item_id HTTP/1.1Authorization: Bearer YOUR-API-TOKENAccept: application/jsonX-Api-Version: 3curl -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, "has_children": true } }}Sometimes, you may wish to fetch a record that has embedded blocks inside Modular Content, Single Block or Structured Text fields.
By default, those nested blocks are returned as block IDs (ie. "dhVR2HqgRVCTGFi_0bWqLqA"), 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: 3curl -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
-- Regular mode --└ Item "FEzWmQhjQgeHsCrUtvlEMw" (item_type: "UZyfjdBES8y2W2ruMEHSoA") ├ title: "My first blog post!" └ sections └ [0]: "Mpgkz94PQsiV8vmvpIS4oA"
-- Nested mode --└ Item "FEzWmQhjQgeHsCrUtvlEMw" (item_type: "UZyfjdBES8y2W2ruMEHSoA") ├ title: "My first blog post!" └ sections └ [0] Item "Mpgkz94PQsiV8vmvpIS4oA" (item_type: "T4m4tPymSACFzsqbZS65WA") └ headline: "Welcome to the example!"TypeScript typing
Reading a record without typed schemas means every attribute comes back as unknown, and the IDE can't help you navigate it. The single biggest lever you have is passing a generated Schema.X marker as the generic on items.find. TypeScript then knows the exact shape of the returned record — its field names, types, and block structures — so reads are typed end-to-end:
import * as Schema from "./schema";
const record = await client.items.find<Schema.Article>("record-id");record.title; // typed, not unknownFor the exact type of a specific field on the returned record (to annotate a helper or intermediate variable), index ApiTypes.Item<Schema.Article>["field_api_key"] (or ApiTypes.ItemInNestedResponse<Schema.Article>["field_api_key"] when fetching with nested: true). See the full TypeScript guide for how to generate schema.ts and the complete pattern.
Query parameters
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) of your records, or the latest available (current, default)
"published"
Returns
Returns a resource object of type item.