- Introduction
- What does Santiment offer to developers?
- GraphQL API
- Python API-wrapper library
- Santiment Queries
- Metrics Catalog
Getting started for Developers
Introduction
The Santiment API is a powerful tool designed to provide crucial data for your financial models. By leveraging this API, you can gain comprehensive insights into the cryptocurrency market, encompassing social trends, developmental metrics, and on-chain activities—all consolidated into a single platform.
What does Santiment offer to developers?
Santiment offers a robust GraphQL API, empowering developers with advanced capabilities to fetch essential crypto market data. GraphQL provides a highly flexible query language for APIs that enables more intuitive and descriptive queries compared to traditional REST API methods. With GraphQL, users can request exactly the data they need, minimizing the number of API calls and reducing bandwidth usage.
Apart from precomputed metrics, Santiment has the Santiment Queries product, which allows developers to write custom SQL to obtain the data from the database directly. These SQL queries can be executed from the Queries web page or execute the queries through the API
GraphQL API
In this example, the query fetches the daily active addresses for Bitcoin. The query is self-descriptive and easy to maintain. New members to your team can intuitively understand the query without the need to consult the documentation.
1 2 3 4 5 6 7 8 9 10 11 12
{ getMetric(metric: "daily_active_addresses"){ timeseriesData( selector: {slug: "bitcoin"} from: "2024-01-01T00:00:00Z" to: "2024-01-31T23:59:59Z" interval: "1d"){ datetime value } } }
Find more GraphQL query examples on the Common Queries page, or read How to access the API article
Python API-wrapper library
Santiment provides a Python API wrapper library that allows you to fetch metrics with a simple function call. The code shows how to translate the GraphQL query from above. The data is returned in a Pandas dataframe.
1 2 3 4 5 6
import san san.get("daily_active_addresses", slug="bitcoin", from_date="2024-01-01", to_date="2024-01-31", interval="1d")
Santiment Queries
There is also Santiment Queries, which gives direct access to the database where custom SQL queries can be run.
The query below shows how to obtain the same data as the GraphQL query and the python code above.
1 2 3 4 5 6 7 8 9 10
SELECT dt, value FROM daily_metrics_v2 WHERE asset_id = get_asset_id('bitcoin') AND metric_id = get_metric_id('daily_active_addresses') AND dt >= toDate('2024-01-01') AND dt <= toDate('2024-01-31') ORDER BY dt ASC
Visit the Santiment Queries web page, log in to your account and execute the query.
Similar to the API subscription plans, historical and realtime in SQL is also restricted based on the subscription plan.
Metrics Catalog
There are a few different ways to explore the available metrics.
- Visit the metrics' docs articles page where you can find links to the documentation articles of the metrics.
- Open the Metrics Catalog webpage that list all the metrics with information about the available assets. This page allows you to filter the metrics supported by a given asset and download the data as CSV.
- Open any chart page on Sanbase and explore the metrics on the sidebar.
- Use the GraphQL API that shows the restrictions for each subscription product -- which metrics are accessible and what are the time range restrictions for them.
Read next: How to Access the API