Content API
Endpoints
Support for other resources
At the moment you can only fetch content objects via this API, in the future we will add more endpoints to support content types and assets.
Content
Content is the core resource you will need to fetch using the API. Read the content object reference for a full breakdown of how they are returned in an API response.
Available endpoints
Retrieve a content object
Retrieves a published content object. Supply the content ID that you were given in a previous request or have copied from the Contento admin panel.
Request
GET https://app.contento.io/api/v1/content/RaDf2yMpL6 HTTP/1.1
Authorization: Bearer {token}
X-CONTENTO-SITE: {site_id}
Response
A content object with timestamps.
{
"id": "RaDf2yMpL6",
"published_at": "2022-09-27T08:54:06+00:00",
"slug": "vertical-saas",
"name": "The Growth of Vertical SaaS",
"author": {
...
},
"content_type": {
...
},
"fields": {
...
},
"created_at": "2022-09-15T13:39:40+00:00",
"updated_at": "2022-09-27T08:59:39+00:00"
}
List all content
Returns a paginated list of published content. The content objects are sorted in the list with the most recently published appearing first.
Request
GET https://app.contento.io/api/v1/content HTTP/1.1
Authorization: Bearer {token}
X-CONTENTO-SITE: {site_id}
Parameters
Query parameters can be appended to the request url to filter, limit or sort the results.
In most cases you can supply either one instance of a parameter with a single value (e.g. ?content_type=blog_post
), or supply multiple values using the array syntax (e.g. ?content_type[0]=blog_post&content_type[1]=case_study
). If you do send multiple values then they will be executed as an AND
query.
Parameter | Formats | Default | Accepted values |
---|---|---|---|
author | String or Array | ID of the author(s) you want to filter by. | |
content_type | String or Array | Handle of the content type you want to filter by. | |
content_type_id | String or Array | ID of the content type you want to filter by. | |
cursor | String | Cursor for pagination. | |
limit | Integer | 20 | The number of results you want in the response. |
slug | String or Array | Slug of the specific content object you want to retrieve. | |
sort | String or Array | published_at:desc | You must supply values in the following format: attribute:direction . The attribute used can be one of published_at , created_at , updated_at , name or slug . The direction can be either desc or asc . |
Response
This will contain an array of content objects and associated pagination data.
Attribute | Type | Description |
---|---|---|
data | Array | Sorted array of content objects or an empty array if nothing can be found. |
links | Object | A links pagination object. |
meta | Object | A meta pagination object. |
{
"data": [
{
"id": "RaDf2yMpL6",
"published_at": "2022-09-27T08:54:06+00:00",
"slug": "vertical-saas",
"name": "The Growth of Vertical SaaS",
"author": {
...
},
"content_type": {
...
},
"fields": {
...
},
"created_at": "2022-09-15T13:39:40+00:00",
"updated_at": "2022-09-27T08:59:39+00:00"
},
...
],
"links": {
"first": null,
"last": null,
"prev": null,
"next": "https://app.contento.io/api/v1/content?cursor=eyJwdWJsaXNoZWRfYXQiOiIyMDIyLTA2LTA3IDExOjU0OjMwIiwiX3BvaW50c1RvTmV4dEl0ZW1zIjp0cnVlfQ"
},
"meta": {
"path": "https://app.contento.io/api/v1/content",
"per_page": 20,
"next_cursor": "eyJwdWJsaXNoZWRfYXQiOiIyMDIyLTA2LTA3IDExOjU0OjMwIiwiX3BvaW50c1RvTmV4dEl0ZW1zIjp0cnVlfQ",
"prev_cursor": null
}
}