Pacifica Python API Docs | dltHub

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

Last updated:

Pacifica is a decentralized exchange platform providing REST API access for trading and account management operations. The REST API base URL is https://api.pacifica.fi/api/v1 and POST requests require Ed25519 cryptographic signatures; GET requests do not require authentication..

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 add "dlt[hub]" and start loading Pacifica data in under 10 minutes.


What data can I load from Pacifica?

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

ResourceEndpointMethodData selectorDescription
orders/api/v1/orders/historyGETRetrieves historical orders for an account.
funding_rates/api/v1/funding_rate/historyGETRetrieves historical funding rates for a symbol.
api_keys/api/v1/account/api_keysGETLists API keys for the account.
markets/api/v1/marketsGETLists all perpetual futures markets.
fee_levels/api/v1/fee_levelsGETRetrieves all fee level tiers.

How do I authenticate with the Pacifica API?

POST requests require Ed25519 signature authentication. Required headers include 'account' (public key), 'signature' (Base58 encoded Ed25519), 'timestamp', and 'expiry_window', with an optional 'agent_wallet' for agent keys.

1. Get your credentials

To obtain API credentials for Pacifica, navigate to the official API Agent Keys portal at https://app.pacifica.fi/apikey. You can generate an "API Agent Key" (also known as an Agent Wallet) directly in your browser. This process involves signing a binding transaction with your main wallet, ensuring your primary private key remains secure. For higher-level rate limiting, you can also generate "API Config Keys" programmatically via the /api/v1/account/api_keys/create REST endpoint, which requires your wallet address and a cryptographic signature.

2. Add them to .dlt/secrets.toml

[sources.pacifica_source] # To use for authentication in dlt (e.g., in .dlt/secrets.toml):\nPACIFICA_ADDRESS = \"your_wallet_address\"\nPACIFICA_AGENT_PRIVATE_KEY = \"your_base58_agent_wallet_secret_key\"\nPACIFICA_RATE_LIMIT_KEY = \"your_optional_pf_api_key_for_rate_limiting\"

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 init uv add "dlt[hub]"

1. Install the dlt AI harness:

uv run dlthub 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:

uv run dlthub ai toolkit install rest-api-pipeline

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 Pacifica 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:

uv run python pacifica_pipeline.py

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

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

Inspect your pipeline and data:

uv run dlthub 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 /api/v1/account/api_keys and /api/v1/account/api_keys/create from the Pacifica 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 pacifica_source(private_key=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "https://api.pacifica.fi/api/v1", "auth": {"type": "api_key", "api_key": private_key, "name": "private_key"}, }, "resources": [ {"name": "orders", "endpoint": {"path": "api/v1/orders/history"}}, {"name": "funding_rates", "endpoint": {"path": "api/v1/funding_rate/history"}} ], } yield from rest_api_resources(config) def get_data() -> None: pipeline = dlt.pipeline( pipeline_name="pacifica_pipeline", destination="duckdb", dataset_name="pacifica_data", ) load_info = pipeline.run(pacifica_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("pacifica_pipeline").dataset() sessions_df = data.orders.df() print(sessions_df.head())

SQL (DuckDB example):

SELECT * FROM pacifica_data.orders LIMIT 10;

In a marimo or Jupyter notebook:

import dlt data = dlt.pipeline("pacifica_pipeline").dataset() data.orders.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 Pacifica 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.


Next steps

Continue your data engineering journey with the other toolkits of the dltHub AI harness:

  • data-exploration — Build custom notebooks, charts, and dashboards for deeper analysis with marimo notebooks.
  • dlthub-platform — Deploy, schedule, and monitor your pipeline in production.
uv run dlthub ai toolkit install data-exploration uv run dlthub ai toolkit install dlthub-platform

Was this page helpful?

Community Hub

Need more dlt context for Pacifica?

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

Available Pipelines