Skip to content

Contento API

MK edited this page Jul 15, 2020 · 6 revisions

Contento comes with a REST API for fetching data to send to your users on your apps or websites. The API is accessible at https://api.mycontento.com/api/cdn* and content is delivered in JSON.

*Though we use the word "CDN" we currently don't use CDNs

Authorization

All requests coming to the API needs to have an access token. You can use put the access token in the Authorization header. To get an access token visit your site settings and click the option to "invalidate and generate a new key". Creating a new access token automatically revokes the previous ones so store this token safely and it can be used for all your apps or websites.

Rate limiting

Requests to the API have a rate-limiting of 120 requests per second. When you reach this limit you get a 429 error with a Retry-After header with information about when you retry.

Resource fetching

Currently, only basics APIs are supported.

Get site information

GET https://api.mycontento.com/api/cdn/sites/:siteid

returns

{
    "meta": {
        "type": "Site",
        "id": "5e1e03e17879c1a6072cb857", // site id
        "createdAt": "2020-01-14T18:09:37.106Z", // date resource was created
        "updatedAt": "2020-01-25T22:16:58.890Z" // date resource was updated
    },

    "name": "Example Site" // site name
}

Get all pages in a site

GET https://api.mycontento.com/api/cdn/sites/:siteid/pages

returns

{
  "meta": {
    "type": "Site",
    "id": "5e1e03e17879c1a6072cb857", // site id
    "createdAt": "2020-01-14T18:09:37.106Z", // date resource was created
    "updatedAt": "2020-01-25T22:16:58.890Z" // date resource was updated
  },

  "pages": {
    "home": {
      "meta": {
        "type": "Page",
        "id": "5e1e04117879c1a6072cb858", // page id
        "createdAt": "2020-01-14T18:10:25.437Z", // date resource was created
        "updatedAt": "2020-01-26T00:49:54.388Z" // date resource was updated
      },

      "name": "Home", // page name
      "slug": "home" // page slug
    },
    "aboutUs": {
      "meta": {
        "type": "Page",
        "id": "5e2cdec8dfd573026afc8476", // page id
        "createdAt": "2020-01-26T00:35:20.340Z", // date resource was created
        "updatedAt": "2020-01-26T00:35:20.340Z" // date resource was updated
      },
      "name": "About Us", // page name
      "slug": "aboutUs" // page slug
    }
  }
}

Get content in a page

GET https://api.mycontento.com/api/cdn/sites/:siteid/pages/:page_slug

returns

{
  "meta": {
    "type": "Page",
    "id": "5e1e04117879c1a6072cb858", // page id
    "createdAt": "2020-01-14T18:10:25.437Z", // date resource was created
    "updatedAt": "2020-01-26T00:49:54.388Z" // date resource was updated
  },

  "name": "Home", // page name
  "slug": "home", // page slug

  "contents": {
    "headerTitle": {
      "meta": {
        "type": "Content",
        "id": "5e2ce23263467903fdf7504d", // content id
        "createdAt": "2020-01-26T00:49:54.385Z", // date resource was created
        "updatedAt": "2020-01-26T00:49:54.385Z" // date resource was updated
      },

      "type": "TEXT", // content type
      "name": "Header Title", // content title 
      "slug": "headerTitle", // content slug
      "content": "This is the header title for GoSquare" // your content!
    }
  }
}

Thanks for using Contento :)