Skip to content

GraphQL fundamentals🔗

The Cryptosense v2 API uses GraphQL. Some familiarity with this query language is recommended to make the best use of the API but is not mandatory to complete the API tutorials.

You can use any HTTP client you’d like to send queries. Below is an example with curl that retrieves the name of the user:

Bash
$ export CS_API_KEY=<your API key>
$ curl \
    --request POST \
    --header "API-KEY: $CS_API_KEY" \
    --header 'Content-Type: application/json' \
    --data '{"query": "query {viewer {name}}"}' \
    https://analyzer.cryptosense.com/api/v2
{"data":{"viewer":{"name":"<your username>"}}}

And here is the same query in Python:

Python
import json
import os

import requests

cs_api_key = os.getenv("CS_API_KEY")
query = """
  query {
    viewer {
      name
    }
  }
"""
response = requests.post(
    "https://analyzer.cryptosense.com/api/v2",
    data=json.dumps({"query": query}),
    headers={"API-KEY": cs_api_key, "Content-Type": "application/json"},
)
print(json.dumps(response.json()))

Note

Throughout this guide, we will assume you have chosen any suitable client and only show you the queries and responses.