Load Stripe - Main API data to PostgreSQL
Build a Stripe - Main API to PostgreSQL pipeline with your coding agent. One prompt scaffolds it with the dltHub AI harness, plus the Stripe - Main API API base URL, auth, endpoints, and incremental loading.
Stripe is a payments platform with a REST API for managing payment, billing, customer, and other financial resources. Everything needed to build a working Stripe - Main API → PostgreSQL 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 Stripe - Main API to PostgreSQL pipeline
Paste this prompt into Claude, Codex, or Cursor. The agent does the rest.
uvx dlthub-init@latest to build a pipeline from Stripe - Main API to PostgreSQL and run it on dltHubThat 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 Stripe - Main API 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.
Stripe - Main API API at a glance
| Base URL | https://api.stripe.com/v1 |
| Example endpoint | GET charges |
| Records found at | data |
| Authentication | Bearer secret API key — sent in the Authorization header, prefixed Bearer |
| Pagination | Cursor-based via starting_after, next cursor at has_more, page size via limit (default 10, max 100). Stripe list endpoints use cursor-based pagination. Responses contain a data array and a boolean has_more. For the next page, if has_more is true, send starting_after equal to the ID of the last object in the current page; do not send it on the first request. starting_after and ending_before are mutually exclusive. Results are returned in reverse chronological order, so this supports incremental traversal using object creation order, but the cursor itself is an object ID—not a timestamp. The API uses HTTP Basic authentication with the secret key as the username (for example curl -u 'sk_test_...:'); the base URL is https://api.stripe.com/v1. The documented pagination page-size parameter is limit, accepted range 1–100. Stripe does not document a separate next-page-token request parameter; the response indicator is has_more and the next cursor is derived from the final object's ID. |
| Incremental field | created |
| Record id | id |
| API reference | https://docs.stripe.com/api/authentication |
These values come from the Stripe - Main API API reference — the authoritative source if anything here looks out of date.
How do I authenticate with the Stripe - Main API API?
Send the secret key in the HTTP Authorization header as Authorization: Bearer <SECRET_KEY>. Stripe documents HTTP Basic Auth as the primary method, with the API key as the username and no password, but explicitly supports bearer authentication as an alternative. Requests must use HTTPS; no additional required header was specified.
1. Get your credentials
- Sign in to the Stripe Dashboard at https://dashboard.stripe.com/ and select the intended account and environment (sandbox/test mode or live mode). 2. Open Developers > API keys (the API keys page), where Stripe lets you create, reveal, expire, and rotate keys for the account or sandbox you’re viewing. 3. For a server-side integration, create or reveal a secret key, or preferably create a restricted API key and grant only the read permissions required by the dlt source. Stripe’s unrestricted secret keys begin with sk_test_ in test mode or sk_live_ in live mode; restricted keys use rk_ prefixes. 4. Copy the secret value when shown and store it immediately in a secrets manager or environment variable; Stripe displays a newly created secret key only once. 5. Configure the dlt source with the key as a bearer credential. For raw REST requests, send Authorization: Bearer <STRIPE_SECRET_KEY> to https://api.stripe.com/v1/.... Stripe’s normal authentication mechanism is HTTP Basic Auth with the API key as the username, but bearer authentication is explicitly supported when needed. Never expose a secret/restricted key in client-side code, logs, or version control; rotate it if exposed.
2. Add them to .dlt/secrets.toml
[sources.stripe_main_api_source] api_key = "sk_test_REPLACE_WITH_STRIPE_SECRET_KEY"
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 Stripe - Main API data can I load into PostgreSQL?
These are the Stripe - Main API endpoints dlt can load into PostgreSQL:
| Resource | Endpoint | Method | Data selector | Description |
|---|---|---|---|---|
| charges | charges | GET | data | List charges; supports limit, starting_after, ending_before, and created[gt/gte/lt/lte]. |
| customers | customers | GET | data | List customers; supports cursor pagination, limit, and created[gt/gte/lt/lte]. |
| products | products | GET | data | List products; supports cursor pagination, limit, and created[gt/gte/lt/lte]. |
| prices | prices | GET | data | List prices; supports cursor pagination, limit, and created[gt/gte/lt/lte]. |
| files | files | GET | data | List files; supports cursor pagination, limit, and created[gt/gte/lt/lte]. |
| pagination | pagination | GET | data | Generic Stripe v1 list-pagination reference/example; not a record resource. |
How do I load only new Stripe - Main API records?
Stripe - Main API exposes created on charges, so dlt can request only the records that changed since the last run. Set it as the cursor_path and dlt tracks the high-water mark for you between runs.
{"name": "charges", "endpoint": { "path": "charges", "data_selector": "data", "incremental": {"cursor_path": "created", "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 Stripe - Main API pipeline look like?
A standard dlt REST API pipeline — the same code you would write by hand, loading customers and charges from the Stripe - Main API API into PostgreSQL:
import dlt from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources @dlt.source def stripe_main_api_source(api_key=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "https://api.stripe.com/v1", "auth": {"type": "bearer", "token": api_key}, }, "resources": [ {"name": "charges", "endpoint": {"path": "charges", "data_selector": "data"}}, {"name": "customers", "endpoint": {"path": "customers", "data_selector": "data"}} ], } yield from rest_api_resources(config) def load_stripe_main_api_to_postgres() -> None: pipeline = dlt.pipeline( pipeline_name="stripe_main_api_pipeline", destination="postgres", dataset_name="stripe_main_api_data", ) load_info = pipeline.run(stripe_main_api_source()) print(load_info) if __name__ == "__main__": load_stripe_main_api_to_postgres()
Run it with uv run python stripe_main_api_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 Stripe - Main API data in PostgreSQL?
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("stripe_main_api_pipeline").dataset() df = data.charges.df() print(df.head())
SQL:
SELECT * FROM stripe_main_api_data.charges LIMIT 10;
See querying your data with dataset and exploring it in marimo notebooks.
How do I deploy the Stripe - Main API to PostgreSQL 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 Stripe - Main API 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 Stripe - Main API 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 Stripe - Main API to PostgreSQL?
Request dlt skills, commands, AGENT.md files, and AI-native context.