REST API
Getting started
Making requests
The ChartBlocks API is hosted at https://api.chartblocks.com/v1/. The API is REST based, providing access to chart, set, data and user information.
To generate charts on-the-fly, please see the Image API.
SDK’s
To get you up and running with the API as quickly as possible we’ve implemented an SDK for PHP. Other languages will be available shortly.
Authorization
The majority of API calls must be made as an authorized user. An ACCESS_TOKEN and SECRET_KEY can be generated from your ChartBlocks profile page. Together these are used to sign requests.
Authorizing a request
We’d suggest using one our pre-built SDKs if you’re new to development, but to authenticate requests in your own clients, please read on.
Your SECRET_KEY is never sent in the request, only the ACCESS_TOKEN. The SECRET_KEY is used to generate a SIGNATURE which both authenticates the request as coming from you, and mitigates man in the middle attacks.
The signature is sent in your HTTP request using the Authorization header in the format:
Generating a signature
This snippet of psuedo code describes how to generate a signature. It should be possible to implement this in your language of choice.
The body variable is your request body. For a GET request this would be your query parameters in the format:
param1=val¶m2=val
For POST, PUT and PATCH requests this would be your request body, normally a JSON document, i.e.:
The SECRET_KEY is obtained along with the ACCESS_TOKEN from the profile page of your ChartBlocks account.
Item tokens
Charts and datasets can are assigned a token, allowing people without a ChartBlocks account to view private items providing they know the token.
To request a chart or set with a token, pass the given token as a GET parameter of t, i.e.
https://api.chartblocks.com/v1/chart/541fdd38c9a61d68707f9d86?t=c9ea94ad
Chart config
The chart config object can end up rather large, and contains enough parameters to warrant its own documentation page. Please reference the Chart Config documentation separately for more information on how to format your config object.
Resources
Chart
Chart objects contain all the information required to render a chart, along with meta information on the owner.
Create
Parameters
Parameter | Type | Description |
---|---|---|
name | String |
A reference for the chart |
isPublic | Boolean |
Whether the chart can be viewed in the public gallery Default: true |
config | Object |
The chart config (see Chart Config docs) |
Success example
Delete
Get
Parameters
Parameter | Type | Description |
---|---|---|
t | String |
Token to view chart if isn't public |
Success example
List
Parameters
Parameter | Type | Description |
---|---|---|
public | Boolean |
Show all public charts (defaults to own charts). Default: false |
sort_by | String |
Sort results by given field. Valid values: Default: updatedAt |
order | String |
Order of results Valid values: Default: asc |
limit | Number |
Maximum number of results to return per request Default: 50 |
page | Number |
Which page of results to return (coupled with limit for pagination) Default: 1 |
term | String |
Search query |
creator | String |
Filter results to a particular user (used with 'public' to get a users public charts) |
Success example
Patch
All paramters are optional and get merged against existing values server side
Parameters
Parameter | Type | Description |
---|---|---|
name | String |
A reference for the chart |
isPublic | Boolean |
Whether the chart can be viewed in the public gallery Default: true |
config | Object |
The chart config (see Chart Config docs) |
Success example
Update
Parameters
Parameter | Type | Description |
---|---|---|
name | String |
A reference for the chart |
isPublic | Boolean |
Whether the chart can be viewed in the public gallery Default: true |
config | Object |
The chart config (see Chart Config docs) |
Success example
Data
Alter data structure
Parameters
Parameter | Type | Description |
---|---|---|
method | String |
The type of change Valid values: |
index | Number |
Row/column to shift from |
Number | Number |
of row/columns to shift by |
Success example
Append data
Parameters
Parameter | Type | Description |
---|---|---|
data | Object |
The data array to append to the bottom of the set, consists of an array of objects keyed by column ID |
Success example
Get data
Parameters
Parameter | Type | Description |
---|---|---|
version | Number |
Which version of the data would you like? Default: live |
limit | Number |
How many rows to return? Default: 100 |
offset | Number |
Returns from starting at offset Default: 0 |
fromRow | Number |
As missing rows are ommitted from results, allows you to select a range of rows specifically Default: 1 |
toRow | Number |
As missing rows are omitted from results, allows you to select a range of rows specifically |
Success example
Meta
Parameters
Parameter | Type | Description |
---|---|---|
version | Number |
Which version of the data would you like meta for? Default: latest |
Success example
Save data
Parameters
Parameter | Type | Description |
---|---|---|
data | Object |
The data object to update, can be a complete set or partial, keyed by row ID and column ID |
Success example
Truncate data
Success example
Import
Import data (to new set)
Parameters
Parameter | Type | Description |
---|---|---|
name | String |
A reference for the set |
sourceName | String |
The type of import Valid values: |
sourceOptions | ObjCreateect |
Some sources have options (see Import docs) to configure the import process |
Success example
Import data (to existing set)
Parameters
Parameter | Type | Description |
---|---|---|
sourceName | String |
The type of import Valid values: |
sourceOptions | ObjCreateect |
Some sources have options (see Import docs) to configure the import process |
name | String |
A reference for the set |
Success example
Preview start
Parameters
Parameter | Type | Description |
---|---|---|
sourceName | String |
The type of import Valid values: |
sourceOptions | Object |
Some sources have options (see Import docs) to configure the import process |
Success example
Preview status
Success example
Set
Create
Parameters
Parameter | Type | Description |
---|---|---|
name | String |
A reference for the set |
sourceName | String |
The type of import Valid values: |
sourceOptions | Object |
Some sources have options (see Import docs) to configure the import process |
Success example
Delete
Get
Parameters
Parameter | Type | Description |
---|---|---|
t | String |
Token to view set if isn't public |
Success example
List
Parameters
Parameter | Type | Description |
---|---|---|
sort_by | String |
Sort results by given field. Valid values: Default: updatedAt |
order | String |
Order of results Valid values: Default: asc |
limit | Number |
Maximum number of results to return per request Default: 50 |
page | Number |
Which page of results to return (coupled with limit for pagination) Default: 1 |
term | String |
Search query |
Success example
Patch
All paramters are optional and get merged against existing values server side
Parameters
Parameter | Type | Description |
---|---|---|
name | String |
A reference for the set |
Success example
Update
Parameters
Parameter | Type | Description |
---|---|---|
name | String |
A reference for the set |
Success example
Template
Get
Success example
List
Parameters
Parameter | Type | Description |
---|---|---|
type | String |
Return templates for particular type. Valid values: Default: all |
sort_by | String |
Sort results by given field. Valid values: Default: name |
order | String |
Order of results Valid values: Default: asc |
limit | Number |
Maximum number of results to return per request Default: 50 |
page | Number |
Which page of results to return (coupled with limit for pagination) Default: 1 |
term | String |
Search query |