API Quickstart
Execution & Results
In this quickstart, we will walk through how to fetch Dune data in Python.
- 📓 You also can choose to use this Google Colab Notebook or this Hex Notebook to get started fast.
- ⌨️ For a quickstart on TypeScript, please download Dune TypeScript SDK and follow this demo project.
Prerequisites
- Python environment set up (check out Anaconda Navigator if you want somewhere to start.)
- Have a Dune API key (to obtain one follow the steps here)
Step 1: Prepare your Dune query
Have a Dune query you’d like to pull data from. Here, we’ll use this query to get the DAI token balance for vitalik.eth.
Step 2: Install Dune Python SDK
Ensure the Dune Python SDK is installed in your environment. You can install it using pip:
Step 3: Get data from Dune query
Import packages
Set up a Dune Python client
Get query result
You can choose to either get the latest query result without triggering an execution or to trigger an execution and get the result to ensure freshest data.
- To paginate query results, please visit the pagination page to get more info.
- If you are using the Python SDK:
- For higher level functions like
run_query()
, pagination is handled for you automatically behind the scene, so you will get the entire dataset as the returned result. You can pass in parameterbatch_size
to define the maximum number of rows per batch or pagination call. - For lower level functions like
get_execution_results()
, you can pass in pagination parameterslimit
andoffset
directly, as instructed here.
- For higher level functions like
Was this page helpful?