API Reference

Santiment team

2019-09-20

API Reference

This page contains a reference of all the APIs provided by Santiment.

Overview

Santiment API uses GraphQL. From the beginning we decided to use GraphQL instead of REST for a number of reasons:

Authentication

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

Errors

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:

Live API Explorer

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:

https://api.santiment.net/graphiql?query=%7B%0A%20%20transactionVolume(slug%3A%22santiment%22%2C%20from%3A%222019-01-01T00%3A00%3A00Z%22%2C%20to%3A%222019-03-01T00%3A00%3A00Z%22)%20%7B%0A%20%20%20%20datetime%0A%20%20%20%20transactionVolume%0A%20%20%7D%0A%7D

Running requests with 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

Glossary

There are some terms used in this document. Here is a list and discription of them:

Start exploring the API

Start exploring the API here