Load Alchemy data to DuckDB
Build a Alchemy to DuckDB pipeline with your coding agent. One prompt scaffolds it with the dltHub AI harness, plus the Alchemy API base URL, auth, endpoints, and incremental loading.
Alchemy provides a suite of blockchain developer tools including REST APIs for accessing blockchain data, token pricing, and NFT metadata. Everything needed to build a working Alchemy → DuckDB pipeline is on this page: the API's base URL, authentication, endpoints, pagination and incremental field — plus a prompt that hands the whole job to your coding agent.
Build your Alchemy to DuckDB pipeline
Paste this prompt into Claude, Codex, or Cursor. The agent does the rest.
PromptRunuvx dlthub-init@latestto build a pipeline from Alchemy to DuckDB and run it on dltHub
That scaffolds a dltHub workspace and installs the dltHub AI harness — the project rules, the secrets-management skill, and the dlt MCP server your agent needs to work safely. From there it reads the Alchemy API, proposes the endpoints to load, then writes, runs and validates the pipeline while you review rather than type. Credentials are inspected through MCP tools, so your agent never reads secrets.toml itself. How the LLM-native workflow works →
Prefer to write it yourself? Every fact the agent uses is below.
Alchemy API at a glance
| Base URL | https://api.alchemy.com |
| Example endpoint | GET /transfers/v1/{apiKey}/getAssetTransfers |
| Records found at | result |
| Authentication | all requests require either an API key in the URL path or an Authorization header containing a Bearer token — sent in the Authorization header, prefixed Bearer |
| Pagination | Cursor-based via pageKey, page size via pageSize or maxCount. Alchemy APIs use cursor-based pagination primarily via 'pageKey'. For some endpoints, 'maxCount' or 'pageSize' is used to set the limit. Solana-specific DAS APIs additionally support 'cursor', 'before', 'after', 'page', and 'limit' parameters. The pagination cursor returned in the response must be sent back in the subsequent request within a 10-minute TTL window. |
| API reference | https://www.alchemy.com/docs/how-to-use-api-keys-in-http-headers |
These values come from the Alchemy API reference — the authoritative source if anything here looks out of date.
How do I authenticate with the Alchemy API?
Alchemy APIs support authentication via either an API key in the request URL path or as a Bearer token in the 'Authorization' header. For the 'Authorization' header, the format is 'Bearer <API_KEY_OR_JWT>'.
1. Get your credentials
- Sign in to your Alchemy Dashboard at https://dashboard.alchemy.com.\n2. Navigate to the Apps tab and click 'Create new app' (or select an existing app).\n3. After the app is created, you will be redirected to the app details page.\n4. Copy the API key displayed in the top-right corner of the page. Note: This is often labeled as the 'HTTP' key or 'Key'.\n5. Alternatively, for granular permissions, navigate to the 'Security' menu to create and manage 'Access Keys'.
2. Add them to .dlt/secrets.toml
[sources.alchemy_source] api_key = "your_alchemy_api_key_here"
dlt reads this file automatically at runtime. With the harness, the setup-secrets skill prompts you for the values and never handles the raw credential in chat. For production, see setting up credentials with dlt.
What Alchemy data can I load into DuckDB?
These are the Alchemy endpoints dlt can load into DuckDB:
| Resource | Endpoint | Method | Data selector | Description |
|---|---|---|---|---|
| nft_metadata | /nft/v3/{apiKey}/getNFTMetadata | GET | Retrieves metadata for a specific NFT | |
| token_prices | /prices/v1/tokens/by-symbol | GET | Fetches token prices by symbol | |
| token_balances | /data/v1/{apiKey}/assets/tokens/by-address | GET | Fetches fungible token balances | |
| solana_token_accounts | /solana/v1/{apiKey}/getTokenAccounts | GET | Retrieves token accounts with pagination | |
| stellar_transactions | /stellar/v1/{apiKey}/getTransactions | GET | Returns paginated transactions |
How do I load only new Alchemy records?
The Alchemy API reference does not document a timestamp or sequence field for these endpoints, so there is nothing to advertise here as verified. Pick a field from the endpoints table above that increases with every write, then set it as the cursor_path.
{"name": "transfers_api", "endpoint": { "path": "/transfers/v1/{apiKey}/getAssetTransfers", # Replace with a field that increases on every write. "incremental": {"cursor_path": "REPLACE_ME", "initial_value": "2024-01-01T00:00:00Z"}, }}
On the first run dlt loads everything from initial_value; on every run after that it requests only what changed and appends with write_disposition="merge" if you set a primary key. See incremental loading.
What does the generated Alchemy pipeline look like?
A standard dlt REST API pipeline — the same code you would write by hand, loading v1/getNFTs and v1/getAssetTransfers from the Alchemy API into DuckDB:
import dlt from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources @dlt.source def alchemy_source(api_key=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "https://api.alchemy.com", "auth": {"type": "bearer", "token": api_key}, }, "resources": [ {"name": "transfers_api", "endpoint": {"path": "/transfers/v1/{apiKey}/getAssetTransfers", "data_selector": "result"}}, {"name": "solana_token_accounts", "endpoint": {"path": "/solana/v1/{apiKey}/getTokenAccounts", "data_selector": "result"}} ], } yield from rest_api_resources(config) def load_alchemy_to_duckdb() -> None: pipeline = dlt.pipeline( pipeline_name="alchemy_pipeline", destination="duckdb", dataset_name="alchemy_data", ) load_info = pipeline.run(alchemy_source()) print(load_info) if __name__ == "__main__": load_alchemy_to_duckdb()
Run it with python alchemy_pipeline.py. The agent iterates on this until it loads cleanly — you review and approve, rather than write it from scratch.
How do I query Alchemy data in DuckDB?
dlt creates one table per resource. Query the loaded data with Python or SQL — or ask your agent to, through the MCP server's execute_sql_query tool.
Python (pandas DataFrame):
import dlt data = dlt.pipeline("alchemy_pipeline").dataset() df = data.solana_token_accounts.df() print(df.head())
SQL:
SELECT * FROM alchemy_data.solana_token_accounts LIMIT 10;
See querying your data with dataset and exploring it in marimo notebooks.
How do I deploy the Alchemy to DuckDB pipeline in production?
The pipeline runs locally, which is ideal for prototyping and one-off analysis. When you need it on a schedule, monitored on every load, and shared with your team, deploy the same dlt code on the dltHub platform — no infrastructure to maintain. The prompt above already ends with "run it on dltHub", so your agent can take it there directly.
- Deploy & schedule — run the pipeline as a managed job with automatic retries.
- Monitor — observable job queues, alerting, and load metrics for every run.
- Transform — promote raw Alchemy loads into governed, documented models.
- Visualize & share — explore data in notebooks and publish live dashboards instead of static screenshots.
What other destinations can I load Alchemy data to?
dlt loads into any of these — only the destination argument changes:
| Destination | Example value |
|---|---|
| PostgreSQL | "postgres" |
| BigQuery | "bigquery" |
| Snowflake | "snowflake" |
| Redshift | "redshift" |
| Databricks | "databricks" |
| Filesystem (S3, GCS, Azure) | "filesystem" |
Set dlt.pipeline(destination="snowflake") and add credentials in .dlt/secrets.toml. On the dltHub platform the same pipeline runs against a managed Iceberg lakehouse. See the full destinations list.
Next steps
Was this page helpful?
Community Hub
Need more dlt context for Alchemy to DuckDB?
Request dlt skills, commands, AGENT.md files, and AI-native context.