Explorer API User Tutorial
1. Introduction
In this tutorial, we will cover
a sample query to find mints and burns for Tether (USDT) on EVM chains
how to use the Allium Explorer API to execute this query
how to use the API to fetch results in your developer environment
convert the fetched results into a Pandas data frame in Jupyter Notebook
2. Creating Query
The following query can be used to find mints and burns for Tether (USDT) on EVM chains since the start of 2023. To make queries run faster, we have selected a subset of popular stablecoins.
3. Using SQL as a query parameter
Allium Explorer queries support the use of parameters, as shown below.
One trick is to just create a singular parameter as the query body and use the Explorer API to insert any SQL you’d like in your developer environment. This is what this will look like:
Tip: If you don’t want to pass in SQL as a parameter, you can just copy the above SQL into the app’s query editor instead! Proceed to Save your query and Copy the query ID under the three dots in the top corner.
4. Execute the query in Jupyter
First set up the following cells with your API key, the Query ID you copied, and the SQL text:
Allium Explorer exposes the following endpoints through a REST API to fetch and poll your query run.
POST /api/v1/explorer/queries/{query_id}/run-async: Execute the query asynchronously. This creates a query run ID for you to poll the status and results from
GET /api/v1/explorer/query-runs/{run_id}/status: Get the status of a query run as an enumeration of created | queued | running | success | failed | canceled
GET /api/v1/explorer/query-runs/{run_id}/results: Get the results of a query run with status success.
The typical flow would be to
Create a query run, and get the run_id
Poll the query run status using the run_id in a while loop
When the query run status is success, get the results
Allium Explorer exposes the following endpoints through a REST API to fetch and poll your query run.
Here’s what this would look like in Jupyter:
Create a query run, and get the run_id
Poll the query run status using the run_id in a while loop
When the query run status is success, get the results
5. Get the results into a Pandas Dataframe
The results data is now in a list-of-dictionaries form. This can be loaded into a Pandas dataframe, as demonstrated below.
Resources
The notebook used in the above example can be found at: https://github.com/garlicshank/allium-api-examples/blob/main/notebooks/tether-mints-evm.ipynb
Questions?
If any questions remain after this guide on how to get started, connect to our APIs, or retrieve specific data you have in mind, feel free to reach out to support@allium.so at any time.
Last updated