Get started with the Content API
Overview
Section titled “Overview”The Content API provides an interface to create and manage content and revisions.
Make a request
Section titled “Make a request”All API requests must be directed to the https://api.quantcdn.io/v1/ endpoint. The path is prefixed with the API version. If backwards-breaking changes are introduced into the API the version number will be bumped. Old versions of the API will be maintained and deprecated with plenty of notice. You will need to add specific headers to each request to ensure that the API endpoint can correctly identify you.
In curl a request will look like:
curl -H "Quant-Customer: [example-customer]" -H "Quant-Project: [example-project]" -H "Quant-Token: [project-token]" https://api.quantcdn.io/v1/pingAuthentication
Section titled “Authentication”Quant uses bearer tokens for authentication. All requests must specify the Quant-Token request header and need to send the value presented in your dashboard. If you haven’t created a project head over to your dashboard set one up to retrieve your token and start publishing!
To further identify your request you are required to add Quant-Customer and Quant-Project request headers. These will be validated against the Quant-Token to ensure that the request is valid.
Pagination
Section titled “Pagination”Requests that return multiple items will be paginated to 100 items by default. You can specify the page query parameter to iterate through the result set. You can also change the number returned by Quant with the per_page parameter.
Paginated API endpoints will return data under a records key.
Metadata
Section titled “Metadata”Paginated result sets will include metadata to help identify how many results are available for any given call. These are available in the result object as page, page_size, total_records and total_pages.
Sending content to the API
Section titled “Sending content to the API”The most common API action is sending content, either new content or a content revision. Quant supports two types of files;
- HTML (markup)[#sending-markup] as pages
- Accompanying (assets)[#sending-assets] like images, JavaScript and stylesheets
Quant is based on atomic deployments, each time a file changes Quant treats it as if a new file was submitted to the API. This allows Quant to show point in-time representations of any asset that has been sent to Quant.
Sending markup and content
Section titled “Sending markup and content”This is the main action of the Quant API and is how we register paths and content to be served from those paths. When you send markup you will need to tell Quant what URL this markup will be accessible by, if the content is published and additional metadata.
curl -X POST https://api.quantcdn.io/v1 -d @./payload.json{ "content": "<html><body><img src="/banner.jpg" /><h1>My static web page</h1></body></html>", "url": "/", "published": true, "info": { "author_name": "Joe Static", "log": "Revision log message" }}