2019-09-20
This page contains a reference of all the APIs provided by Santiment.
Santiment API uses GraphQL. From the beginning we decided to use GraphQL instead of REST for a number of reasons:
Some of the APIs require to have a valid API key, belonging to an account with a paid subscription to access all the data. The API key can be generated on your Account Settings page.
After that you need to pass the API key as an additional HTTP header Authorization: Apikey <YOUR_OWN_API_KEY>
. An example how to do that using curl:
curl \
-X POST \
-H "Content-Type: application/graphql" \
-H "Authorization: Apikey <YOUR_OWN_API_KEY>"\
--data '<YOUR_OWN_QUERY>' \
https://api.santiment.net/graphql
In case something is not correct with the request, the API will return an error. The API requests should always return status code 200, even if there was an error processing the request. An error response is going to include a description of the error that occured. For example here is what will happen if the query passed to the API is not valid:
$ curl \
-X POST \
-H "Content-Type: application/graphql" \
--data '{transactionVolume' \
https://api.santiment.net/graphql | jq .
{
"errors": [
{
"message": "An unknown error occurred during parsing: no function clause matching in Absinthe.Phase.Parse.format_raw_parse_error/1"
}
]
}
If your query is missing some argument, that should be described in the error response:
$ curl \
-X POST \
-H "Content-Type: application/graphql" \
--data '{ transactionVolume(slug:"santiment", from:"2019-01-01T00:00:00Z") { datetime transactionVolume }}' \
https://api.santiment.net/graphql | jq .
{
"errors": [
{
"locations": [
{
"column": 3,
"line": 1
}
],
"message": "In argument \"to\": Expected type \"DateTime!\", found null."
}
]
}
If the query does not return status code 200, then something else is happening. Here are some of the options:
There is a live explorer, where you can run queries directly from the browser. The explorer is accessible here: https://api.santiment.net/graphiql
Here is an example of running a query and seeing the results directly in the browser:
curl
You can run requests with curl by passing the GraphQL query as the body of the request. Here is an exmaple how to run the transactionVolume
query:
curl \
-X POST \
-H "Content-Type: application/graphql" \
--data '{ getMetric(metric: "transaction_volume"){
timeseriesData(
slug:"santiment"
from:"2019-01-01T00:00:00Z"
to:"2019-03-01T00:00:00Z"
interval: "1d") {
datetime
value
}
}
}' \
https://api.santiment.net/graphql
There are some terms used in this document. Here is a list and discription of them:
slug
- An ID we use in the API to identify projects. You can find the slug of the projects by using the allProjects
API.
interval
- A representation of time intervals like 5 minutes, 2 days or 4 weeks. An interval is represented as a string starting with a number and followed by one of the suffixes:
s
- secondm
- minuteh
- hourd
- dayw
- weekNote that there is no suffix for specifying months due to months not containing a fixed amount of days.
An interval is used when fetching timeseries data. If the raw data is available at 5 minute intervals but you want to fetch it daily, interval: "1d"
should be provided as parameter..
ISO 8601 format
- The date time format used in the API. The format is <year>-<month>-<day>T<hour>:<minute>:<second>Z
. For example Jan 10th 2019 12:34:56 is 2019-01-10T12:34:56Z
API key
- Your API for accessing the premium features in the API. See the Authentication
section for more details