Cpanel Python API Docs | dltHub
Build a Cpanel-to-database pipeline in Python using dlt with AI Workbench support for Claude Code, Cursor, and Codex.
Last updated:
cPanel is a web hosting control panel platform that exposes account and server administration functionality via UAPI, cPanel API 2, and WHM REST endpoints. The REST API base URL is For UAPI: https://{cpanel-hostname}:2083/execute For cPanel API 2 via WHM API: https://{whm-hostname}:2087/json-api/cpanel (WHM proxy) and direct cPanel API 2 URLs use cPanel ports 2082/2083 with /json-api/cpanel For WHM API 1 endpoints (server-level): https://{whm-hostname}:2087/json-api (or /execute paths in OpenAPI spec) and Supports HTTP Basic (username:password), WHM API tokens, and API Tokens/Access Hashes depending on API..
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 Cpanel data in under 10 minutes.
What data can I load from Cpanel?
Here are some of the endpoints you can load from Cpanel:
| Resource | Endpoint | Method | Data selector | Description |
|---|---|---|---|---|
| uapi_execute | /execute/{Module}/{function} | GET | result.data | Execute a UAPI function on cPanel; response wraps function result in result object with data key |
| whm_cpanel_proxy | /json-api/cpanel (via WHM) | GET | data | Run cPanel API/call UAPI via WHM API (query params: cpanel_jsonapi_user, cpanel_jsonapi_module, cpanel_jsonapi_func) |
| whm_run_remote | /execute_remote_whmapi1_with_password | GET | data | Execute remote WHM API1 function; response data contains function output |
| uapi_integration_fetch_url | /execute/Integration/fetch_url | GET | result.data | Example UAPI endpoint returning result.data with apiversion/module/func metadata |
| api2_listredirects | /json-api/cpanel?cpanel_jsonapi_module=Mime&cpanel_jsonapi_func=listredirects | GET | data (within metadata/data) | cPanel API2 endpoint to list MIME redirects (via WHM/cPanel URL format) |
| whm_api_general | /execute/{...} (WHM OpenAPI paths) | GET | data or result depending on method | WHM OpenAPI exposes many GET endpoints; responses include data and metadata wrappers |
How do I authenticate with the Cpanel API?
The APIs accept authentication via an Authorization HTTP header (Basic base64(user:pass)) for username/password auth; WHM API tokens are sent as Authorization: WHM root:APITOKEN or via header Authorization: Bearer for some interfaces; Access Hashes and API tokens are documented in the Guide to API Authentication. Use TLS and the correct port (2083 for cPanel, 2087 for WHM).
1. Get your credentials
- Log into WHM as root or a reseller. 2) In WHM search for "Manage API Tokens" or "API Tokens". 3) Create a new token, name it, set desired privileges, and copy the token value. 4) Store it securely; use it in requests as the Authorization header or as specified (WHM: Authorization: WHM root:API_TOKEN) or use Basic auth with username:password over TLS if necessary.
2. Add them to .dlt/secrets.toml
[sources.cpanel_source] api_token = "your_api_token_here" username = "your_username_here" password = "your_password_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 Cpanel 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 cpanel_pipeline.py
If everything is configured correctly, you'll see output like this:
Pipeline cpanel_pipeline load step completed in 0.26 seconds 1 load package(s) were loaded to destination duckdb and into dataset cpanel_data The duckdb destination used duckdb:/cpanel.duckdb location to store data Load package 1749667187.541553 is LOADED and contains no failed jobs
Inspect your pipeline and data:
dlt pipeline cpanel_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 uapi_execute and whm_cpanel_proxy from the Cpanel 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 cpanel_source(api_token=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "For UAPI: https://{cpanel-hostname}:2083/execute For cPanel API 2 via WHM API: https://{whm-hostname}:2087/json-api/cpanel (WHM proxy) and direct cPanel API 2 URLs use cPanel ports 2082/2083 with /json-api/cpanel For WHM API 1 endpoints (server-level): https://{whm-hostname}:2087/json-api (or /execute paths in OpenAPI spec)", "auth": { "type": "http_basic (for username/password) or bearer (for token usage) — prefer bearer for API tokens", "api_token": api_token, }, }, "resources": [ {"name": "uapi_execute", "endpoint": {"path": "execute/{Module}/{function}", "data_selector": "result.data"}}, {"name": "whm_cpanel_proxy", "endpoint": {"path": "json-api/cpanel", "data_selector": "data"}} ], } yield from rest_api_resources(config) def get_data() -> None: pipeline = dlt.pipeline( pipeline_name="cpanel_pipeline", destination="duckdb", dataset_name="cpanel_data", ) load_info = pipeline.run(cpanel_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("cpanel_pipeline").dataset() sessions_df = data.uapi_execute.df() print(sessions_df.head())
SQL (DuckDB example):
SELECT * FROM cpanel_data.uapi_execute LIMIT 10;
In a marimo or Jupyter notebook:
import dlt data = dlt.pipeline("cpanel_pipeline").dataset() data.uapi_execute.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 Cpanel 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
Ensure you use the correct port and TLS (2087 for WHM, 2083 for cPanel). For Basic auth include Authorization: Basic <base64(user:pass)>; for WHM API tokens use the token header format (Authorization: WHM root:API_TOKEN) or Bearer where indicated. Incorrect port or missing/invalid token returns Permission denied or Authentication failed.
Permission denied / Function not found
Calls to the wrong API type or port (e.g., using WHM ports for UAPI) return "Function not found" or "Permission denied". Confirm API version params (cpanel_jsonapi_apiversion) and that the authenticated user has the required role/permissions.
Pagination and data selector quirks
UAPI responses wrap results in a top-level JSON with keys: apiversion, func, module, and result. The actual records are inside result.data. WHM API endpoints typically return an envelope with data and metadata; the records are in the data key. For cPanel API 2 via json-api endpoints the response often embeds results under data (or within the cpanelresult object in legacy outputs); always inspect the function's example response for the exact path prior to parsing.
Common API errors: Authentication failed (401/Permission denied), Function not found (404 or descriptive error), Invalid parameters (400), TLS/port mismatch causing Permission denied.
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 Cpanel?
Request dlt skills, commands, AGENT.md files, and AI-native context.