Whmcs Python API Docs | dltHub

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

Last updated:

WHMCS is a web hosting billing, automation and client management platform exposing an external REST-like API for performing administrative and client operations. The REST API base URL is https://<your-whmcs-installation>/includes/api.php and all requests require API authentication using an identifier and secret passed in request parameters (identifier+secret or username+password) and responsetype=json.

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


What data can I load from Whmcs?

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

ResourceEndpointMethodData selectorDescription
clientsincludes/api.php?action=GetClients&responsetype=jsonGET/POST(varies per endpoint; responses are JSON objects)List clients and basic client info
invoicesincludes/api.php?action=GetInvoices&responsetype=jsonGET/POST(varies)List invoices
ticketsincludes/api.php?action=GetTickets&responsetype=jsonGET/POST(varies)List support tickets
productsincludes/api.php?action=GetProducts&responsetype=jsonGET/POST(varies)List products and pricing
domainsincludes/api.php?action=GetTLDPricing&responsetype=jsonGET/POST(varies)Get TLD pricing and registrar info
ordersincludes/api.php?action=GetOrders&responsetype=jsonGET/POST(varies)List orders

How do I authenticate with the Whmcs API?

API authentication uses an API credential pair (identifier and secret). Include identifier and secret as POST/GET parameters named identifier and secret (or username and password for backwards compatibility) on each request; include responsetype=json to receive JSON responses.

1. Get your credentials

  1. Log in to WHMCS admin. 2) Go to Setup > Staff Management > Manage API Credentials (or Configuration > System Settings > Manage API Credentials). 3) Create an API Role with required permissions. 4) Click Generate New API Credential, select admin user and role(s), copy the generated identifier and secret and store securely.

2. Add them to .dlt/secrets.toml

[sources.whmcs_source] api_identifier = "your_identifier_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 Whmcs 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 whmcs_pipeline.py

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

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

Inspect your pipeline and data:

dlt pipeline whmcs_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 clients and invoices from the Whmcs 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 whmcs_source(api_identifier=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "https://<your-whmcs-installation>/includes/api.php", "auth": { "type": "api_key", "api_identifier": api_identifier, }, }, "resources": [ {"name": "clients", "endpoint": {"path": "includes/api.php?action=GetClients&responsetype=json"}}, {"name": "invoices", "endpoint": {"path": "includes/api.php?action=GetInvoices&responsetype=json"}} ], } yield from rest_api_resources(config) def get_data() -> None: pipeline = dlt.pipeline( pipeline_name="whmcs_pipeline", destination="duckdb", dataset_name="whmcs_data", ) load_info = pipeline.run(whmcs_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("whmcs_pipeline").dataset() sessions_df = data.clients.df() print(sessions_df.head())

SQL (DuckDB example):

SELECT * FROM whmcs_data.clients LIMIT 10;

In a marimo or Jupyter notebook:

import dlt data = dlt.pipeline("whmcs_pipeline").dataset() data.clients.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 Whmcs 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

If requests return authentication errors, verify the identifier/secret pair, ensure the admin user has API Access permission and that the API credential has appropriate roles assigned. Confirm the credential has not been revoked. If using IP restrictions check that the caller IP is allowed.

Response format and responsetype

Always include responsetype=json in requests to receive JSON. Some legacy calls return PHP arrays or NVP. Complex list responses are often nested under keys named after the resource (for example clients or invoices) — inspect the returned JSON for the exact list key.

Rate limiting and access control

WHMCS installations may enforce IP‑based access control by default. Configure allowed IPs in Setup > General Settings > Security, or use Access Key methods if IP restriction is not feasible.

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

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