# REST API
The REST API allows accessing the content-types through API endpoints. Strapi automatically creates API endpoints when a content-type is created. API parameters can be used when querying API endpoints to refine the results.
✏️ NOTE
The REST API by default does not populate any relations, media fields, components, or dynamic zones. Use the populate
parameter to populate specific fields.
# Endpoints
For each Content-Type, the following endpoints are automatically generated:
Examples:
✏️ NOTE
Components don't have API endpoints.
# Requests
Requests return a response as an object which usually includes the following keys:
data
: the response data itself, which could be:- a single entry, as an object with the following keys:
id
(number)attributes
(object)meta
(object)
- a list of entries, as an array of objects
- a custom response
- a single entry, as an object with the following keys:
meta
(object): information about pagination, publication state, available locales, etc.error
(object, optional): information about any error thrown by the request
✏️ NOTE
Some plugins (including Users & Permissions and Upload) may not follow this response format.
# Get entries
Returns entries matching the query filters (see API parameters documentation).
Example request
GET http://localhost:1337/api/restaurants
Example response
{
"data": [
{
"id": 1,
"attributes": {
"title": "Restaurant A",
"description": "Restaurant A's description"
},
"meta": {
"availableLocales": []
}
},
{
"id": 2,
"attributes": {
"title": "Restaurant B",
"description": "Restaurant B's description"
},
"meta": {
"availableLocales": []
}
},
],
"meta": {}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Get an entry
Returns an entry by id
.
Example request
GET http://localhost:1337/api/restaurants/1
Example response
{
"data": {
"id": 1,
"attributes": {
"title": "Restaurant A",
"description": "Restaurant A's description"
},
"meta": {
"availableLocales": []
}
},
"meta": {}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
# Create an entry
Creates an entry and returns its value.
If the Internationalization (i18n) plugin is installed, it's possible to use POST requests to the REST API to create localized entries.
Example request
POST http://localhost:1337/api/restaurants
{
"data": {
"title": "Hello",
"relation": 2,
"relations": [2, 4],
"link": {
"id": 1,
"type": "abc"
}
}
}
2
3
4
5
6
7
8
9
10
11
Example response
{
"data": {
"id": 1,
"attributes": { … },
"meta": {}
},
"meta": {}
}
2
3
4
5
6
7
8
# Update an entry
Partially updates an entry by id
and returns its value.
Fields that aren't sent in the query are not changed in the database. Send a null
value to clear fields.
Example request
PUT http://localhost:1337/api/restaurants/1
{
"data": {
"title": "Hello",
"relation": 2,
"relations": [2, 4],
}
}
2
3
4
5
6
7
Example response
{
"data": {
"id": 1,
"attributes": {},
"meta": {}
},
"meta": {}
}
2
3
4
5
6
7
8
✏️ NOTE
Even with the Internationalization (i18n) plugin installed, it's currently not possible to update the locale of an entry.
# Delete an entry
Deletes an entry by id
and returns its value.
Example request
DELETE http://localhost:1337/api/restaurants/1
Example response
{
"data": {
"id": 1,
"attributes": {},
"meta": {}
},
"meta": {}
}
2
3
4
5
6
7
8