Content API

Overview

The Content API is a read-only API built around REST principles. It will let you fetch published content from a Contento site so that you can use it in your front-end framework of choice.


Base URL

This documentation covers version 1 of the API and all requests should be made using the following base url:

https://app.contento.io/api/v1/

For example, to use the /content/{id} endpoint you would issue a request like this:

GET https://app.contento.io/api/v1/content/Zx6Wy2ejOY HTTP/1.1
Authorization: Bearer {token}
X-CONTENTO-SITE: {site_id}

Authentication

All requests must be authenticated, please read the authentication guide for more information.


Object Reference

The object reference section will give you an overview of all the objects that can appear in API responses, as well as a detailed breakdown of each attribute and what you can expect the value to be.


Request caching and rate limiting

All requests are cached for 30 seconds. At the moment this is a hard cache, in that there is no way to invalidate it. If content is updated and you make the same request within the 30-second window you will see stale content.

In addition, there is a rate limit of 600 requests per minute for all requests. This is tied to your API token and is not configurable at this time. If you need a higher limit then please contact us using the contact form on our website.


Endpoints

At the moment there are two endpoints which are limited to fetching content data only, in the future we will add assets and content types to this version of the API.

The current available endpoints are:


Next.js example

We will provide more guides, examples and starter kits as we build out the API and this documentation, but for now here is an example of how to make a single GET request to fetch one page from the API, and display the results in a React component using the Next.js framework.

import Head from 'next/head'

export async function getStaticProps() {
    const res = await fetch(process.env.CONTENTO_API_URL+'content/Zx6Wy2ejOY', {
        method: 'GET',
        headers: {
            'Content-Type': 'application/json',
            'Authorization': 'Bearer '+process.env.CONTENTO_API_KEY,
            'X-CONTENTO-SITE': process.env.CONTENTO_SITE_ID
        },
    })

    const page = await res.json()
    
    return {
        props: {
            page
        }
    }
}

export default function Index({ page }) {
    return (
        <>
            <Head>
                <title>{page.fields.meta_title.text+' - Contento'}</title>
                <meta
                    name="description"
                    content={page.fields.meta_description.text}
                />
            </Head>
            <main>
                <h1>
                    {page.name}
                </h1>
                <p>
                    {page.fields.leader_text.text}
                </p>
            </main>
        </>
    )
}
Previous
Platform