Sei Python API Docs | dltHub

Build a Sei-to-database pipeline in Python using dlt with AI Workbench support for Claude Code, Cursor, and Codex.

Last updated:

Sei is a high-performance Layer-1 blockchain exposing an Ethereum-compatible JSON-RPC EVM API with additional Sei-specific extensions for cross-VM and synthetic-transaction support. The REST API base URL is https://evm-rpc.sei-apis.com and Public JSON-RPC endpoints — requests use standard JSON-RPC over HTTPS (no provider-level auth required for the official public RPCs)..

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 Sei data in under 10 minutes.


What data can I load from Sei?

Here are some of the endpoints you can load from Sei:

ResourceEndpointMethodData selectorDescription
eth_blockNumberhttps://evm-rpc.sei-apis.comPOSTresultReturns latest block number (hex)
eth_getBlockByNumberhttps://evm-rpc.sei-apis.comPOSTresultReturns block object (optionally with transactions)
eth_getBlockByHashhttps://evm-rpc.sei-apis.comPOSTresultReturns block object by hash
eth_getTransactionByHashhttps://evm-rpc.sei-apis.comPOSTresultReturns transaction object
eth_getTransactionReceipthttps://evm-rpc.sei-apis.comPOSTresultReturns transaction receipt
eth_getLogshttps://evm-rpc.sei-apis.comPOSTresultReturns array of log objects matching filter
sei_getLogshttps://evm-rpc.sei-apis.comPOSTresultSei extension: like eth_getLogs but includes synthetic logs
eth_callhttps://evm-rpc.sei-apis.comPOSTresultExecutes a call without creating a transaction
eth_sendRawTransactionhttps://evm-rpc.sei-apis.comPOSTresultSubmits a signed transaction (returns tx hash)
debug_traceTransactionhttps://evm-rpc.sei-apis.comPOSTresultTraces transaction execution (debug)

How do I authenticate with the Sei API?

The official EVM RPC endpoints use standard JSON-RPC over HTTPS and do not require API keys or Bearer tokens for the public RPC URLs; include header Content-Type: application/json. Some third‑party providers may require provider‑specific keys.

1. Get your credentials

  1. If using the official public endpoints (evm-rpc.sei-apis.com) no credentials are required.
  2. If you choose a third‑party RPC provider (e.g., QuickNode, Ankr), sign into that provider, create a new Sei endpoint in their dashboard, and copy the provided endpoint URL or API key.
  3. For provider‑specific auth, follow their dashboard prompts to obtain an HTTP header or token and store it securely.

2. Add them to .dlt/secrets.toml

[sources.sei_evm_source] api_key = "your_provider_api_key_here" endpoint_url = "https://your-provider-sei-endpoint.example"

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 Sei 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 sei_evm_pipeline.py

If everything is configured correctly, you'll see output like this:

Pipeline sei_evm_pipeline load step completed in 0.26 seconds 1 load package(s) were loaded to destination duckdb and into dataset sei_evm_data The duckdb destination used duckdb:/sei_evm.duckdb location to store data Load package 1749667187.541553 is LOADED and contains no failed jobs

Inspect your pipeline and data:

dlt pipeline sei_evm_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 eth_getLogs and eth_getBlockByNumber from the Sei 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 sei_evm_source(endpoint_url=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "https://evm-rpc.sei-apis.com", "auth": { "type": "api_key_or_none", "api_key": endpoint_url, }, }, "resources": [ {"name": "eth_getLogs", "endpoint": {"path": "(JSON-RPC method) eth_getLogs — POST to base_url", "data_selector": "result"}}, {"name": "eth_getBlockByNumber", "endpoint": {"path": "(JSON-RPC method) eth_getBlockByNumber — POST to base_url", "data_selector": "result"}} ], } yield from rest_api_resources(config) def get_data() -> None: pipeline = dlt.pipeline( pipeline_name="sei_evm_pipeline", destination="duckdb", dataset_name="sei_evm_data", ) load_info = pipeline.run(sei_evm_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("sei_evm_pipeline").dataset() sessions_df = data.eth_getBlockByNumber.df() print(sessions_df.head())

SQL (DuckDB example):

SELECT * FROM sei_evm_data.eth_getBlockByNumber LIMIT 10;

In a marimo or Jupyter notebook:

import dlt data = dlt.pipeline("sei_evm_pipeline").dataset() data.eth_getBlockByNumber.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 Sei data to?

dlt supports loading into any of these destinations — only the destination parameter changes:

DestinationExample 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

Official public RPCs do not require auth; if using a third‑party provider ensure your endpoint URL or api_key is correct and sent as their required header or URL path. 401/403 typically mean invalid or missing provider credentials.

Rate limiting and quota errors

Third‑party RPC providers enforce rate limits; when rate limited you may receive HTTP 429 or provider‑specific error messages. Implement exponential backoff and retries.

JSON‑RPC errors

Sei returns standard JSON‑RPC error objects under the "error" key. Common codes documented include -32000 (Invalid input), -32001 (Resource not found), -32002 (Resource unavailable), -32003 (Transaction rejected), -32005 (Limit exceeded), -32500 (Cross‑VM error), -32501 (Synthetic tx error). Example:

{ "jsonrpc":"2.0", "id":1, "error":{ "code":-32500, "message":"Cross-VM operation failed", "data":{"details":"CosmWasm contract execution reverted" } } }

Pagination / log query limits

eth_getLogs / sei_getLogs have limits: open‑ended block range returns up to ~10,000 logs; closed block range limited to about 2,000 blocks in the docs. Split queries or narrow block ranges to avoid truncated responses.

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 Sei?

Request dlt skills, commands, AGENT.md files, and AI-native context.