Guide to getting started with the Content API
Overview
The Content API is a powerful way to access your content and all related metadata, including creator data, product data, and campaign data.
GraphQL
The Content API is based on the GraphQL query language. This allows you to create any query for data that is supported by the API and customize those queries to only receive the data your need. Additionally, strong typing and schema definition makes the API easy to use and understand. In your account, when you access the Content API, the interface provides developer data documentation as well as a query schema. Data from this API is returned in a JSON format.
Using the Content API
The API is available to all clients and can be accessed via the platform. From the main navigation menu, under the "Site" section, click on "Content API".
When you initially open the explorer, you’ll see something like this:
There are 2 buttons at the top.
- Documentation: This is what you are reading now.
- Examples: For anyone who is too impatient to read any further, here are 3 simple query examples.
The API explorer is unique to your account, if you notice the API URL in the explorer, that is specific for you.
The left panel is your working area, where you can construct, test and troubleshoot queries to the API.
The right panel is your results area. This is where you will see data responses or error messages based on your query from the left panel.
To execute a query, paste or write it into the left panel, then hit the PLAY button in between both panels.
The tabs at the top allow you to work with many queries at the same time without having to lose any work.
For convenience, you can click “COPY CURL” and this will allow you to paste a command into a standard unix/linux terminal to execute the query to our API using a generic CURL command.
API Access
The Content API is a public API meant to be used by our clients to create data driven content experiences. The API URL you see in the explorer is unique to your account. If for any reason you need to invalidate this URL and generate a new one, please contact our support team.
Note: this will disable any API calls being made to the former URL.
API Endpoint
Here is an example of the API endpoint:
https://content.creatable.io/graphql/v3/t0Fam3XO4rDP0RnQgr69sZSEeEFeg1h1
You can see there the URL is comprised of:
- The API hostname
content.creatable.io
- The
/graphql
subfolder - The version
/v3
subfolder indicating the API version you are currently using - The account specific hash
/t0Fam3XO4rDP0RnQgr69sZSEeEFeg1h1
, which represents your account
Error handling
The API explorer has built in syntax validation, so if there is every a problem with your query, the errors will be highlighted for you and provide some hints on where the problem is.
When you submit a query to the API with improper syntax, you will receive a response similar to this:
{
"errors": [
{
"message": "Syntax error while parsing GraphQL query. Invalid input '}', expected ExecutableDefinition or TypeSystemDefinition (line 8, column 5):\n }\n ^",
"locations": [
{
"line": 8,
"column": 5
}
]
}
]
}
If you have any additional problems using the Content API, please reach our to our support team and we'll be happy to help.