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 sen multiple values then they will be executed as an AND query.

ParameterFormatsDefaultAccepted values
authorString or ArrayID of the author(s) you want to filter by.
content_typeString or ArrayHandle of the content type you want to filter by.
content_type_idString or ArrayID of the content type you want to filter by.
cursorStringCursor for pagination.
limitInteger20The number of results you want in the response.
slugString or ArraySlug of the specific content object you want to retrieve.
sortString or Arraypublished_at:descYou 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.

AttributeTypeDescription
dataArraySorted array of content objects or an empty array if nothing can be found.
linksObjectA links pagination object.
metaObjectA 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
  }
}
Previous
Object Reference