DingConnect Python API Docs | dltHub
Build a DingConnect-to-database pipeline in Python using dlt with AI Workbench support for Claude Code, Cursor, and Codex.
Last updated:
DingConnect is a mobile top‑up and airtime distribution platform exposing a REST API for sending transfers, retrieving providers/products/reference data, balances and promotions. The REST API base URL is https://api.dingconnect.com and All requests require authentication — either OAuth2 Bearer tokens (recommended) or an 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 DingConnect data in under 10 minutes.
What data can I load from DingConnect?
Here are some of the endpoints you can load from DingConnect:
| Resource | Endpoint | Method | Data selector | Description |
|---|---|---|---|---|
| providers | /api/V1/GetProviders | GET | Providers | List of provider objects (reference data) |
| products | /api/V1/GetProducts | GET | Products | List of product (SKU) objects |
| regions | /api/V1/GetRegions | GET | Regions | List of regions/country groupings |
| countries | /api/V1/GetCountries | GET | Countries | List of countries (ISO codes) |
| provider_status | /api/V1/GetProviderStatus | GET | ProviderStatus | Provider operational status objects |
| currencies | /api/V1/GetCurrencies | GET | Currencies | Currency reference data |
| promotions | /api/V1/GetPromotions | GET | Promotions | Current promotions |
| error_code_descriptions | /api/V1/GetErrorCodeDescriptions | GET | ErrorCodeDescriptions | Human‑readable descriptions for error codes |
| balance | /api/V1/GetBalance | GET | Balance | Account balance summary |
| send_transfer | /api/V1/SendTransfer | POST | TransferRecord | Create/send a top‑up transfer (included because central to workflows) |
How do I authenticate with the DingConnect API?
OAuth: obtain a bearer token via client_credentials at https://idp.ding.com/connect/token and include it as Authorization: Bearer . API Key: include header api_key: <your_api_key>. Optional header X-Correlation-Id may be sent for request tracing.
1. Get your credentials
- Log in to your DingConnect account.
- Open Account Settings → Developer (or Developer tab).
- Create/register an OAuth client (client_id and client_secret) or generate an API Key.
- For OAuth, use the client credentials flow to request a token from https://idp.ding.com/connect/token; for API Key, copy the issued key.
2. Add them to .dlt/secrets.toml
[sources.ding_connect_source] # OAuth bearer token token = "eyJ..." # or API key api_key = "your_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 DingConnect 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 ding_connect_pipeline.py
If everything is configured correctly, you'll see output like this:
Pipeline ding_connect_pipeline load step completed in 0.26 seconds 1 load package(s) were loaded to destination duckdb and into dataset ding_connect_data The duckdb destination used duckdb:/ding_connect.duckdb location to store data Load package 1749667187.541553 is LOADED and contains no failed jobs
Inspect your pipeline and data:
dlt pipeline ding_connect_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 providers and products from the DingConnect 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 ding_connect_source(token (for OAuth) — also api_key supported.=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "https://api.dingconnect.com", "auth": { "type": "bearer (primary), api_key (alternative)", "token (for bearer), api_key (for api_key)": token (for OAuth) — also api_key supported., }, }, "resources": [ {"name": "providers", "endpoint": {"path": "api/V1/GetProviders", "data_selector": "Providers"}}, {"name": "products", "endpoint": {"path": "api/V1/GetProducts", "data_selector": "Products"}} ], } yield from rest_api_resources(config) def get_data() -> None: pipeline = dlt.pipeline( pipeline_name="ding_connect_pipeline", destination="duckdb", dataset_name="ding_connect_data", ) load_info = pipeline.run(ding_connect_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("ding_connect_pipeline").dataset() sessions_df = data.providers.df() print(sessions_df.head())
SQL (DuckDB example):
SELECT * FROM ding_connect_data.providers LIMIT 10;
In a marimo or Jupyter notebook:
import dlt data = dlt.pipeline("ding_connect_pipeline").dataset() data.providers.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 DingConnect 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 HTTP 401 or a ResultCode of 4 with ErrorCodes containing AuthenticationFailed/TokenExpired: verify your Authorization header (Bearer ) or api_key header. For OAuth request a new token from https://idp.ding.com/connect/token using client_credentials. Check token expiry and client credentials in Developer -> Account Settings.
Rate limits and Method usage limits
DingConnect enforces per-method limits (requests per 10 minutes). Common GET methods (GetProviders, GetProducts, GetRegions, GetCountries, GetProvidersStatus) have limits (typically 20‑50 requests/10min). Respect Retry-After header when receiving 429/503 and implement exponential backoff.
Pagination and paging quirks
Unbounded list endpoints use Skip and Take parameters. Take has a maximum of 100 and Skip a maximum of 500 (max 600 records retrievable). Responses include ThereAreMoreItems=true when more pages exist. Use Skip/Take to page and honor Cache-Control headers for reference data caching.
Webhooks and deferred sends
When using DeferTransfer (X-Options: DeferTransfer) SendTransfer responses return ProcessingState=Submitted and final result is sent to your notification endpoint. Verify webhook signature using X-Ding-Webhook-Signature, X-Ding-Webhook-Timestamp and public keys (headers include X-Ding-Webhook-Key-Id and algorithm).
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 DingConnect?
Request dlt skills, commands, AGENT.md files, and AI-native context.