Algorand blockchain Python API Docs | dltHub
Build a Algorand blockchain-to-database pipeline in Python using dlt with AI Workbench support for Claude Code, Cursor, and Codex.
Last updated:
Algorand is a layer‑1 blockchain protocol providing REST APIs (algod and indexer) to query node state, accounts, blocks, transactions, assets, and application data. The REST API base URL is algod: <algod_host>:<algod_port>/v2 ; indexer: http://<indexer_host>:8980/v2 and All requests require an API token header (X‑Algo‑API‑Token for algod, X‑Indexer‑API‑Token for indexer)..
dlt is an open-source Python library that handles authentication, pagination, and schema evolution automatically. dlthub provides AI context files that enable code assistants to generate production-ready pipelines. Install with uv pip install "dlt[workspace]" and start loading Algorand blockchain data in under 10 minutes.
What data can I load from Algorand blockchain?
Here are some of the endpoints you can load from Algorand blockchain:
| ## Endpoints Table |
|---|
| Resource |
| ---------- |
| accounts |
| account_by_address |
| account_assets |
| transactions |
| pending_transactions |
| blocks |
| assets |
| indexer_accounts |
| indexer_transactions |
How do I authenticate with the Algorand blockchain API?
The daemon generates an API token stored in a file (algod.token or indexer.token); include it in the X‑Algo‑API‑Token (or X‑Indexer‑API‑Token) header for every request.
1. Get your credentials
- Run a local Algorand node (algod and optionally the indexer) or use a hosted provider.
- Locate the data directory (e.g., ~/node/data).
- Open the file algod.token (or indexer.token) to retrieve the token string.
- Use this token value in the X‑Algo‑API‑Token (or X‑Indexer‑API‑Token) request header.
2. Add them to .dlt/secrets.toml
[sources.algorand_blockchain_source] api_token = "your_algod_token_here"
dlt reads this automatically at runtime — never hardcode tokens in your pipeline script. For production environments, see setting up credentials with dlt for environment variable and vault-based options.
How do I set up and run the pipeline?
Set up a virtual environment and install dlt:
uv venv && source .venv/bin/activate uv pip install "dlt[workspace]"
1. Install the dlt AI Workbench:
dlt ai init --agent <your-agent> # <agent>: claude | cursor | codex
This installs project rules, a secrets management skill, appropriate ignore files, and configures the dlt MCP server for your agent. Learn more →
2. Install the rest-api-pipeline toolkit:
dlt ai toolkit rest-api-pipeline install
This loads the skills and context about dlt the agent uses to build the pipeline iteratively, efficiently, and safely. The agent uses MCP tools to inspect credentials — it never needs to read your secrets.toml directly. Learn more →
3. Start LLM-assisted coding:
Use /find-source to load data from the Algorand blockchain API into DuckDB.
The rest-api-pipeline toolkit takes over from here — it reads relevant API documentation, presents you with options for which endpoints to load, and follows a structured workflow to scaffold, debug, and validate the pipeline step by step.
4. Run the pipeline:
python algorand_blockchain_pipeline.py
If everything is configured correctly, you'll see output like this:
Pipeline algorand_blockchain_pipeline load step completed in 0.26 seconds 1 load package(s) were loaded to destination duckdb and into dataset algorand_blockchain_data The duckdb destination used duckdb:/algorand_blockchain.duckdb location to store data Load package 1749667187.541553 is LOADED and contains no failed jobs
Inspect your pipeline and data:
dlt pipeline algorand_blockchain_pipeline show
This opens the Pipeline Dashboard where you can verify pipeline state, load metrics, schema (tables, columns, types), and query the loaded data directly.
Python pipeline example
This example loads transactions and accounts from the Algorand blockchain API into DuckDB. It mirrors the endpoint and data selector configuration from the table above:
import dlt from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources @dlt.source def algorand_blockchain_source(api_token=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "algod: <algod_host>:<algod_port>/v2 ; indexer: http://<indexer_host>:8980/v2", "auth": { "type": "api_key", "api_token": api_token, }, }, "resources": [ {"name": "transactions", "endpoint": {"path": "v2/transactions", "data_selector": "transactions"}}, {"name": "accounts", "endpoint": {"path": "v2/accounts", "data_selector": "accounts"}} ], } yield from rest_api_resources(config) def get_data() -> None: pipeline = dlt.pipeline( pipeline_name="algorand_blockchain_pipeline", destination="duckdb", dataset_name="algorand_blockchain_data", ) load_info = pipeline.run(algorand_blockchain_source()) print(load_info)
To add more endpoints, append entries from the resource table to the "resources" list using the same name, path, and data_selector pattern.
How do I query the loaded data?
Once the pipeline runs, dlt creates one table per resource. You can query with Python or SQL.
Python (pandas DataFrame):
import dlt data = dlt.pipeline("algorand_blockchain_pipeline").dataset() sessions_df = data.transactions.df() print(sessions_df.head())
SQL (DuckDB example):
SELECT * FROM algorand_blockchain_data.transactions LIMIT 10;
In a marimo or Jupyter notebook:
import dlt data = dlt.pipeline("algorand_blockchain_pipeline").dataset() data.transactions.df().head()
See how to explore your data in marimo Notebooks and how to query your data in Python with dataset.
What destinations can I load Algorand blockchain data to?
dlt supports loading into any of these destinations — only the destination parameter changes:
| Destination | Example value |
|---|---|
| DuckDB (local, default) | "duckdb" |
| PostgreSQL | "postgres" |
| BigQuery | "bigquery" |
| Snowflake | "snowflake" |
| Redshift | "redshift" |
| Databricks | "databricks" |
| Filesystem (S3, GCS, Azure) | "filesystem" |
Change the destination in dlt.pipeline(destination="snowflake") and add credentials in .dlt/secrets.toml. See the full destinations list.
Troubleshooting
Authentication failures
If the X‑Algo‑API‑Token or X‑Indexer‑API‑Token header is missing or invalid, the server responds with 401 Unauthorized and an error message indicating an invalid token.
Pagination
List endpoints return next-token (or next) in the JSON payload. To retrieve subsequent pages, include the next-token value as the next query parameter in the next request.
Rate limits / service unavailable
When the node is overloaded or the service is temporarily unavailable, the API may return 503 Service Unavailable. Implement retry logic with exponential back‑off.
Archival node limits
Non‑archival nodes do not retain old blocks. Requests for very old block numbers may return 404 Not Found or an empty response. Use an archival node or the Indexer service for historical data.
Ensure that the API key is valid to avoid 401 Unauthorized errors. Also, verify endpoint paths and parameters to avoid 404 Not Found errors.
Next steps
Continue your data engineering journey with the other toolkits of the dltHub AI Workbench:
data-exploration— Build custom notebooks, charts, and dashboards for deeper analysis with marimo notebooks.dlthub-runtime— Deploy, schedule, and monitor your pipeline in production.
dlt ai toolkit data-exploration install dlt ai toolkit dlthub-runtime install
Was this page helpful?
Community Hub
Need more dlt context for Algorand blockchain?
Request dlt skills, commands, AGENT.md files, and AI-native context.