You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docusaurus/docs/dev-docs/api/rest.md
+64-8
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
---
2
-
title: REST API
2
+
title: REST API
3
3
description: Interact with your Content-Types using the REST API endpoints Strapi generates for you.
4
+
displayed_sidebar: restApiSidebar
4
5
5
6
---
6
7
@@ -104,10 +105,18 @@ Requests return a response as an object which usually includes the following key
104
105
Some plugins (including Users & Permissions and Upload) may not follow this response format.
105
106
:::
106
107
108
+
<SideBySideContainer>
109
+
110
+
<SideBySideColumn>
111
+
107
112
### Get entries
108
113
109
114
Returns entries matching the query filters (see [API parameters](/dev-docs/api/rest/parameters) documentation).
110
115
116
+
</SideBySideColumn>
117
+
118
+
<SideBySideColumn>
119
+
111
120
<ApiCall>
112
121
113
122
<Request>
@@ -151,11 +160,22 @@ Returns entries matching the query filters (see [API parameters](/dev-docs/api/r
151
160
152
161
</ApiCall>
153
162
163
+
</SideBySideColumn>
164
+
165
+
</SideBySideContainer>
166
+
167
+
<SideBySideContainer>
168
+
169
+
<SideBySideColumn>
154
170
155
171
### Get an entry
156
172
157
173
Returns an entry by `id`.
158
174
175
+
</SideBySideColumn>
176
+
177
+
<SideBySideColumn>
178
+
159
179
<ApiCall>
160
180
161
181
<Requesttitle="Example request">
@@ -187,12 +207,28 @@ Returns an entry by `id`.
187
207
188
208
</ApiCall>
189
209
210
+
</SideBySideColumn>
211
+
212
+
</SideBySideContainer>
213
+
214
+
<SideBySideContainer>
215
+
216
+
<SideBySideColumn>
217
+
190
218
### Create an entry
191
219
192
220
Creates an entry and returns its value.
193
221
194
222
If the [Internationalization (i18n) plugin](/dev-docs/plugins/i18n.md) is installed, it's possible to use POST requests to the REST API to [create localized entries](/dev-docs/plugins/i18n.md#creating-a-new-localized-entry).
195
223
224
+
:::note
225
+
While creating an entry, you can define its relations and their order (see [Managing relations through the REST API](/dev-docs/api/rest/relations.md) for more details).
226
+
:::
227
+
228
+
</SideBySideColumn>
229
+
230
+
<SideBySideColumn>
231
+
196
232
<ApiCall>
197
233
198
234
<Requesttitle="Example request">
@@ -232,16 +268,29 @@ If the [Internationalization (i18n) plugin](/dev-docs/plugins/i18n.md) is instal
232
268
233
269
</ApiCall>
234
270
235
-
:::note
236
-
While creating an entry, you can define its relations and their order (see [Managing relations through the REST API](/dev-docs/api/rest/relations.md) for more details).
237
-
:::
271
+
</SideBySideColumn>
272
+
</SideBySideContainer>
273
+
274
+
275
+
<SideBySideContainer>
276
+
277
+
<SideBySideColumn>
238
278
239
279
### Update an entry
240
280
241
281
Partially updates an entry by `id` and returns its value.
242
282
243
283
Fields that aren't sent in the query are not changed in the database. Send a `null` value to clear fields.
244
284
285
+
:::note NOTES
286
+
* Even with the [Internationalization (i18n) plugin](/dev-docs/plugins/i18n) installed, it's currently not possible to [update the locale of an entry](/dev-docs/plugins/i18n#updating-an-entry).
287
+
* While updating an entry, you can define its relations and their order (see [Managing relations through the REST API](/dev-docs/api/rest/relations.md) for more details).
288
+
:::
289
+
290
+
</SideBySideColumn>
291
+
292
+
<SideBySideColumn>
293
+
245
294
<ApiCall>
246
295
247
296
<Requesttitle="Example request">
@@ -277,15 +326,19 @@ Fields that aren't sent in the query are not changed in the database. Send a `nu
277
326
278
327
</ApiCall>
279
328
280
-
:::note NOTES
281
-
* Even with the [Internationalization (i18n) plugin](/dev-docs/plugins/i18n) installed, it's currently not possible to [update the locale of an entry](/dev-docs/plugins/i18n#updating-an-entry).
282
-
* While updating an entry, you can define its relations and their order (see [Managing relations through the REST API](/dev-docs/api/rest/relations.md) for more details).
283
-
:::
329
+
</SideBySideColumn>
330
+
</SideBySideContainer >
331
+
332
+
<SideBySideContainer>
333
+
334
+
<SideBySideColumn>
284
335
285
336
### Delete an entry
286
337
287
338
Deletes an entry by `id` and returns its value.
339
+
</SideBySideColumn>
288
340
341
+
<SideBySideColumn>
289
342
<ApiCall>
290
343
291
344
<Requesttitle="Example request">
@@ -310,3 +363,6 @@ Deletes an entry by `id` and returns its value.
By default, the filters can only be used from `find` endpoints generated by the Content-type Builder and the CLI.
174
-
:::
205
+
</SideBySideColumn>
206
+
</SideBySideContainer>
207
+
208
+
<SideBySideContainer>
209
+
<SideBySideColumn>
175
210
176
211
### Complex filtering
177
212
178
213
Complex filtering is combining multiple filters using advanced methods such as combining `$and` & `$or`. This allows for more flexibility to request exactly the data needed.
179
214
215
+
</SideBySideColumn>
216
+
217
+
<SideBySideColumn>
218
+
219
+
<br />
180
220
<ApiCall>
181
221
<Requesttitle="Find books with 2 possible dates and a specific author">
Deep filtering is filtering on a relation's fields.
257
303
304
+
<br />
305
+
306
+
:::caution
307
+
308
+
- Querying your API with deep filters may cause performance issues. If one of your deep filtering queries is too slow, we recommend building a custom route with an optimized version of the query.
309
+
- Deep filtering isn't available for polymorphic relations (eg: Dynamic Zones & Media Fields).
310
+
311
+
:::
312
+
313
+
:::note
314
+
315
+
- Relations, media fields, components, and dynamic zones are not populated by default. Use the `populate` parameter to populate these data structures (see [`populate` documentation](/dev-docs/api/rest/populate-select#population))
316
+
- It is not possible to filter on dynamic zones or media fields.
317
+
318
+
:::
319
+
320
+
</SideBySideColumn>
321
+
322
+
<SideBySideColumn>
323
+
324
+
<br />
325
+
258
326
<ApiCall>
259
327
<Requesttitle="Find restaurants owned by a chef who belongs to a 5-star restaurant">
- Querying your API with deep filters may cause performance issues. If one of your deep filtering queries is too slow, we recommend building a custom route with an optimized version of the query.
325
-
- Deep filtering isn't available for polymorphic relations (eg: Dynamic Zones & Media Fields).
326
-
327
-
:::
328
-
329
-
:::note
330
-
331
-
- Relations, media fields, components, and dynamic zones are not populated by default. Use the `populate` parameter to populate these data structures (see [population documentation](/dev-docs/api/rest/populate-select#population))
332
-
- It is not possible to filter on dynamic zones or media fields
-[Localization should be enabled for the content-type](/user-docs/content-type-builder/creating-new-content-type.md#creating-a-new-content-type).
342
400
:::
343
401
344
-
The `locale` API parameter can be used to [get entries from a specific locale](/dev-docs/plugins/i18n.md#getting-localized-entries-with-the-locale-parameter).
402
+
The `locale` API parameter can be used to get entries from a specific locale (see [i18n plugin documentation](/dev-docs/plugins/i18n.md#getting-localized-entries-with-the-locale-parameter)).
403
+
404
+
<SideBySideContainer>
405
+
<SideBySideColumn>
345
406
346
407
## Publication State
347
408
@@ -354,6 +415,12 @@ Queries can accept a `publicationState` parameter to fetch entries based on thei
354
415
-`live`: returns only published entries (default)
355
416
-`preview`: returns both draft entries & published entries
356
417
418
+
</SideBySideColumn>
419
+
420
+
<SideBySideColumn>
421
+
422
+
<br /><br />
423
+
357
424
<ApiCall>
358
425
<Requesttitle="Get both published and draft articles">
|`sort`| String or Array |[Sort the response](/dev-docs/api/rest/sort-pagination.md#sorting)|
19
-
|`filters`| Object |[Filter the response](/dev-docs/api/rest/filters-locale-publication#filtering)|
20
18
|`populate`| String or Object |[Populate relations, components, or dynamic zones](/dev-docs/api/rest/populate-select#population)|
21
19
|`fields`| Array |[Select only specific fields to display](/dev-docs/api/rest/populate-select#field-selection)|
22
-
|`pagination`| Object |[Page through entries](/dev-docs/api/rest/sort-pagination.md#pagination)|
23
-
|`publicationState`| String |[Select the Draft & Publish state](/dev-docs/api/rest/filters-locale-publication#publication-state)<br/><br/>Only accepts the following values:<ul><li>`live`(default)</li><li>`preview`</li></ul> |
20
+
|`filters`| Object |[Filter the response](/dev-docs/api/rest/filters-locale-publication#filtering)|
24
21
|`locale`| String or Array |[Select one or multiple locales](/dev-docs/api/rest/filters-locale-publication#locale)|
22
+
|`publicationState`| String |[Select the Draft & Publish state](/dev-docs/api/rest/filters-locale-publication#publication-state)<br/><br/>Only accepts the following values:<ul><li>`live`(default)</li><li>`preview`</li></ul> |
23
+
|`sort`| String or Array |[Sort the response](/dev-docs/api/rest/sort-pagination.md#sorting)|
24
+
|`pagination`| Object |[Page through entries](/dev-docs/api/rest/sort-pagination.md#pagination)|
25
25
26
-
Query parameters use the LHS bracket syntax (i.e. they are encoded using square brackets `[]`)
26
+
Query parameters use the [LHS bracket syntax](https://christiangiacomi.com/posts/rest-design-principles/#lhs-brackets) (i.e. they are encoded using square brackets `[]`).
27
27
28
28
:::tip
29
29
A wide range of REST API parameters can be used and combined to query your content, which can result in long and complex query URLs.<br/>👉 You can use Strapi's [interactive query builder](/dev-docs/api/rest/interactive-query-builder) tool to build query URLs more conveniently. 🤗
0 commit comments