Iterable Python API Docs | dltHub
Build a Iterable-to-database pipeline in Python using dlt with automatic cursor support.
Last updated:
Iterable is a customer engagement platform providing REST APIs to manage users, events, campaigns, exports, lists, templates and related resources. The REST API base URL is https://api.iterable.com (US) and https://api.eu.iterable.com (EU) and All requests require an API key in the Api-Key header..
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 Iterable data in under 10 minutes.
What data can I load from Iterable?
Here are some of the endpoints you can load from Iterable:
| Resource | Endpoint | Method | Data selector | Description |
|---|---|---|---|---|
| campaigns | /api/campaigns | GET | campaigns | List campaigns metadata (paginated; response includes campaigns array). |
| templates | /api/templates | GET | templates | List project templates (paginated; response includes templates array). |
| events_by_email | /api/events/{email} | GET | events | Get user events by email (returns events array). |
| events_by_userId | /api/events/byUserId/{userId} | GET | events | Get user events by userId (returns events array). |
| lists | /api/lists | GET | lists | Get all lists in a project (response includes lists array). |
| export_data_json | /api/export/data.json | GET | Export campaign analytics as newline‑delimited JSON (each line is a JSON object). | |
| export_files | /api/export/{jobId}/files | GET | files | Get export job status and files (response includes files array). |
| channels | /api/channels | GET | channels | Get all message channels within the project (response includes channels array). |
| message_types | /api/messageTypes | GET | messageTypes | List message types in project (response includes messageTypes array). |
| users_fields | /api/users/getFields | GET | userFields | Get all user fields for the project (response includes userFields array). |
How do I authenticate with the Iterable API?
Authentication uses project‑specific API keys. Include the key in an HTTP header named Api‑Key (or Api_Key). JWT‑enabled keys are also supported for JWT flows.
1. Get your credentials
- Sign in to your Iterable account. 2) Navigate to Settings → API Keys (or Admin → API Keys). 3) Create a new key with the required permissions (server‑side or client‑side). 4) Copy the generated API key string and store it securely. Use JWT keys only if following Iterable's JWT guide.
2. Add them to .dlt/secrets.toml
[sources.iterable_source] api_key = "your_iterable_api_key_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 Iterable 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 iterable_pipeline.py
If everything is configured correctly, you'll see output like this:
Pipeline iterable_pipeline load step completed in 0.26 seconds 1 load package(s) were loaded to destination duckdb and into dataset iterable_data The duckdb destination used duckdb:/iterable.duckdb location to store data Load package 1749667187.541553 is LOADED and contains no failed jobs
Inspect your pipeline and data:
dlt pipeline iterable_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 campaigns and events_by_email from the Iterable 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 iterable_source(api_key=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "https://api.iterable.com (US) and https://api.eu.iterable.com (EU)", "auth": { "type": "api_key", "api_key": api_key, }, }, "resources": [ {"name": "campaigns", "endpoint": {"path": "api/campaigns", "data_selector": "campaigns"}}, {"name": "events_by_email", "endpoint": {"path": "api/events/{email}", "data_selector": "events"}} ], } yield from rest_api_resources(config) def get_data() -> None: pipeline = dlt.pipeline( pipeline_name="iterable_pipeline", destination="duckdb", dataset_name="iterable_data", ) load_info = pipeline.run(iterable_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("iterable_pipeline").dataset() sessions_df = data.events_by_email.df() print(sessions_df.head())
SQL (DuckDB example):
SELECT * FROM iterable_data.events_by_email LIMIT 10;
In a marimo or Jupyter notebook:
import dlt data = dlt.pipeline("iterable_pipeline").dataset() data.events_by_email.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 Iterable 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 you receive 401 Unauthorized or errors mentioning Invalid API key/BadAuthorizationHeader, verify you are using the correct project API key and providing it in the Api‑Key (or Api_Key) HTTP header. Ensure you are calling the correct data‑center base URL (api.iterable.com vs api.eu.iterable.com).
Rate limits and backoff
Many endpoints document per‑project, per‑key or per‑organization rate limits (e.g., 100 req/s for campaign/templates, 2000 req/s for events/track). When you receive 429 Rate Limit Exceeded, implement exponential backoff and retry. Export endpoints have lower limits (e.g., 1 req/s or 4 requests/minute) and concurrent export limits.
Pagination
List endpoints are paginated. Responses commonly include nextPageUrl and previousPageUrl fields. Use page and pageSize query parameters when supported. Export files pagination uses startAfter with the last file name.
Common API error responses
Iterable returns standard HTTP codes and a JSON error envelope, e.g. { "code":"<ErrorCode>", "msg":"<message>", "params":{...} }. Common codes include BadApiKey / Unauthorized (401), BadParams (400), NotFound (404), RateLimitExceeded (429), Internal server error (500). See the API reference for the full list.
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 Iterable?
Request dlt skills, commands, AGENT.md files, and AI-native context.