Show examples in:
Javascript HTTP

Content Management API > Record

Retrieve a record

Query parameters

nested boolean

For Modular Content, Structured Text and Single Block fields. If set, returns full payload for nested blocks instead of IDs

version string

Whether you want the currently published versions (published, default) of your records, or the latest available (current)

Example: "published"

Returns

Returns a resource object of type item.

Other examples

1
GET https://site-api.datocms.com/items/:item_id HTTP/1.1
2
Authorization: Bearer YOUR-API-TOKEN
3
Accept: application/json
4
X-Api-Version: 3
Terminal window
1
curl -g 'https://site-api.datocms.com/items/:item_id' \
2
\
3
-H "Authorization: Bearer YOUR-API-TOKEN" \
4
-H "Accept: application/json" \
5
-H "X-Api-Version: 3"
1
await fetch("https://site-api.datocms.com/items/:item_id", {
2
headers: {
3
Authorization: "Bearer YOUR-API-TOKEN",
4
Accept: "application/json",
5
"X-Api-Version": "3",
6
},
7
});
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
Cache-Control: cache-control: max-age=0, private, must-revalidate
4
X-RateLimit-Limit: 30
5
X-RateLimit-Remaining: 28
6
7
{
8
"data": {
9
"type": "item",
10
"id": "hWl-mnkWRYmMCSTq4z_piQ",
11
"relationships": {
12
"item_type": {
13
"data": {
14
"type": "item_type",
15
"id": "DxMaW10UQiCmZcuuA-IkkA"
16
}
17
}
18
},
19
"attributes": {
20
"title": "My first blog post!",
21
"content": "Lorem ipsum dolor sit amet...",
22
"category": "24",
23
"image": {
24
"alt": "Alt text",
25
"title": "Image title",
26
"custom_data": {},
27
"focal_point": null,
28
"upload_id": "20042921"
29
}
30
},
31
"meta": {
32
"created_at": "2020-04-21T07:57:11.124Z",
33
"updated_at": "2020-04-21T07:57:11.124Z",
34
"published_at": "2020-04-21T07:57:11.124Z",
35
"first_published_at": "2020-04-21T07:57:11.124Z",
36
"publication_scheduled_at": "2020-04-21T07:57:11.124Z",
37
"unpublishing_scheduled_at": "2020-04-21T07:57:11.124Z",
38
"status": "published",
39
"is_current_version_valid": true,
40
"is_published_version_valid": true,
41
"current_version": "4234",
42
"stage": null
43
}
44
}
45
}

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:

1
[
2
{
3
"item": "ahxSnFQEQ02K3TjttWAg-Q", "type": "block"
4
},
5
{
6
"item": "AppHB06oRBm-er3oooL_LA", "type": "block"
7
}
8
]

But if you add the nested=true query parameter, we'll embed the blocks content inline for you.

1
GET https://site-api.datocms.com/items/FEzWmQhjQgeHsCrUtvlEMw?nested=true HTTP/1.1
2
Authorization: Bearer YOUR-API-TOKEN
3
Accept: application/json
4
X-Api-Version: 3
Terminal window
1
curl -g 'https://site-api.datocms.com/items/FEzWmQhjQgeHsCrUtvlEMw?nested=true' \
2
\
3
-H "Authorization: Bearer YOUR-API-TOKEN" \
4
-H "Accept: application/json" \
5
-H "X-Api-Version: 3"
1
await fetch(
2
"https://site-api.datocms.com/items/FEzWmQhjQgeHsCrUtvlEMw?nested=true",
3
{
4
headers: {
5
Authorization: "Bearer YOUR-API-TOKEN",
6
Accept: "application/json",
7
"X-Api-Version": "3",
8
},
9
},
10
);
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
Cache-Control: cache-control: max-age=0, private, must-revalidate
4
X-RateLimit-Limit: 30
5
X-RateLimit-Remaining: 28
6
7
{
8
"data": {
9
"id": "FEzWmQhjQgeHsCrUtvlEMw",
10
"type": "item",
11
"attributes": {
12
"structured_text_field": {
13
"schema": "dast",
14
"document": {
15
"children": [
16
{
17
"item": {
18
"type": "item",
19
"attributes": {
20
"button_label": "Example button",
21
"button_url": "https://www.example.com"
22
},
23
"relationships": {
24
"item_type": {
25
"data": {
26
"id": "SkVjHJSGR5CyK16E8TfJxg",
27
"type": "item_type"
28
}
29
}
30
},
31
"id": "ahxSnFQEQ02K3TjttWAg-Q"
32
},
33
"type": "block"
34
},
35
{
36
"item": {
37
"type": "item",
38
"attributes": {
39
"nested_structured_text_field": {
40
"schema": "dast",
41
"document": {
42
"children": [
43
{
44
"children": [
45
{
46
"type": "span",
47
"value": "This is a "
48
},
49
{
50
"marks": ["emphasis"],
51
"type": "span",
52
"value": "nested"
53
},
54
{
55
"type": "span",
56
"value": " structured text block inside the parent structured text field."
57
}
58
],
59
"type": "paragraph"
60
},
61
{
62
"item": {
63
"type": "item",
64
"attributes": {
65
"button_label": "And this is a button inside the nested structured text block",
66
"button_url": "https://www.example2.com"
67
},
68
"relationships": {
69
"item_type": {
70
"data": {
71
"id": "SkVjHJSGR5CyK16E8TfJxg",
72
"type": "item_type"
73
}
74
}
75
},
76
"id": "CGqwjPDsTHKGFy1IbC0RAQ"
77
},
78
"type": "block"
79
}
80
],
81
"type": "root"
82
}
83
}
84
},
85
"relationships": {
86
"item_type": {
87
"data": {
88
"id": "Ty4S40cbQH6_VMNnGdd9KA",
89
"type": "item_type"
90
}
91
}
92
},
93
"id": "AppHB06oRBm-er3oooL_LA"
94
},
95
"type": "block"
96
}
97
],
98
"type": "root"
99
}
100
}
101
},
102
"relationships": {
103
"item_type": {
104
"data": {
105
"id": "UVa_hHEBSeefLEUnwoQFig",
106
"type": "item_type"
107
}
108
},
109
"creator": {
110
"data": {
111
"id": "104280",
112
"type": "account"
113
}
114
}
115
},
116
"meta": {
117
"created_at": "2024-03-13T17:01:19.243+00:00",
118
"updated_at": "2024-03-13T17:14:17.444+00:00",
119
"published_at": "2024-03-13T17:14:17.597+00:00",
120
"publication_scheduled_at": null,
121
"unpublishing_scheduled_at": null,
122
"first_published_at": "2024-03-13T17:01:19.326+00:00",
123
"is_valid": true,
124
"is_current_version_valid": true,
125
"is_published_version_valid": true,
126
"status": "published",
127
"current_version": "DLtyHZ2MTDqYMg7g5mgYEw",
128
"stage": null
129
}
130
}
131
}