No logo available for Companies House to DuckDB connector icon

Load Companies House data to DuckDB

Build a Companies House to DuckDB pipeline with your coding agent. One prompt scaffolds it with the dltHub AI harness, plus the Companies House API base URL, auth, endpoints, and incremental loading.

SourceCompanies HouseCompanies House API DocumentationDestinationDuckDBIn-process analytical database. The default local destination for dlt pipelines.

Companies House is an executive agency that provides a REST API to retrieve real-time information about limited companies and other entities governed by the Companies Act 2006. Everything needed to build a working Companies House → DuckDB 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 Companies House to DuckDB pipeline

Paste this prompt into Claude, Codex, or Cursor. The agent does the rest.

Prompt
Run uvx dlthub-init@latest to build a pipeline from Companies House to DuckDB and run it on dltHub

That 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 Companies House 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.


Companies House API at a glance

Base URLhttps://api.company-information.service.gov.uk
Example endpointGET company/{company_number}/officers
Records found atitems
Authenticationall requests require HTTP Basic authentication using an API key — sent in the Authorization header, prefixed Bearer
PaginationOffset-based via start_index, page size via items_per_page or size. Pagination uses start_index and items_per_page rather than cursor-based or page-number-based pagination. start_index is the offset into the result set, and items_per_page sets the limit. Some search endpoints use 'size' instead of 'items_per_page' and do not use 'start_index' for every request, relying on ordered keys (e.g., 'search_above', 'search_below') instead.
API referencehttps://developer.company-information.service.gov.uk/authentication

These values come from the Companies House API reference — the authoritative source if anything here looks out of date.


How do I authenticate with the Companies House API?

The Companies House API uses HTTP Basic authentication. To authenticate, provide your API key as the username and leave the password blank, or append a colon to the API key and use the base64-encoded string in the Authorization header.

1. Get your credentials

  1. Sign in to your Companies House account at the Companies House Developer Hub (https://developer.company-information.service.gov.uk/).\n2. Navigate to the 'Your applications' section.\n3. Select 'Create an application' or choose an existing application.\n4. Select 'Create new key'.\n5. Provide a name for the key and select the 'API Key' client type.\n6. Click 'Create' to generate your unique API key. This key will be used for authentication via HTTP Basic Authentication (where the API key acts as the username and the password can be left blank).

2. Add them to .dlt/secrets.toml

[sources.companies_house_source] api_key = "your_api_key_here"

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 Companies House data can I load into DuckDB?

These are the Companies House endpoints dlt can load into DuckDB:

ResourceEndpointMethodData selectorDescription
company_officers/company/{company_number}/officersGETitemsList the company officers
filing_history/company/{company_number}/filing-historyGETitemsList the company filing history
company_psc/company/{company_number}/persons-with-significant-controlGETitemsList the company persons with significant control
company_psc_statements/company/{company_number}/persons-with-significant-control-statementsGETitemsList the company PSC statements
search_companies/search/companiesGETitemsSearch for companies

How do I load only new Companies House records?

The Companies House API reference does not document a timestamp or sequence field for these endpoints, so there is nothing to advertise here as verified. Pick a field from the endpoints table above that increases with every write, then set it as the cursor_path.

{"name": "company_officers", "endpoint": { "path": "company/{company_number}/officers", # Replace with a field that increases on every write. "incremental": {"cursor_path": "REPLACE_ME", "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 Companies House pipeline look like?

A standard dlt REST API pipeline — the same code you would write by hand, loading /company and /search from the Companies House API into DuckDB:

import dlt from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources @dlt.source def companies_house_source(api_key=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "https://api.company-information.service.gov.uk", "auth": {"type": "http_basic", "username": "REPLACE_ME", "password": api_key}, }, "resources": [ {"name": "company_officers", "endpoint": {"path": "company/{company_number}/officers", "data_selector": "items"}}, {"name": "filing_history", "endpoint": {"path": "company/{company_number}/filing-history", "data_selector": "items"}} ], } yield from rest_api_resources(config) def load_companies_house_to_duckdb() -> None: pipeline = dlt.pipeline( pipeline_name="companies_house_pipeline", destination="duckdb", dataset_name="companies_house_data", ) load_info = pipeline.run(companies_house_source()) print(load_info) if __name__ == "__main__": load_companies_house_to_duckdb()

Run it with python companies_house_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 Companies House data in DuckDB?

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("companies_house_pipeline").dataset() df = data.company_officers.df() print(df.head())

SQL:

SELECT * FROM companies_house_data.company_officers LIMIT 10;

See querying your data with dataset and exploring it in marimo notebooks.


How do I deploy the Companies House to DuckDB 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 Companies House loads into governed, documented models.
  • Visualize & share — explore data in notebooks and publish live dashboards instead of static screenshots.

Book a demo →


What other destinations can I load Companies House data to?

dlt loads into any of these — only the destination argument changes:

DestinationExample 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 Companies House to DuckDB?

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