# UK Companies House Company Enricher (Official API) (`leathered_luna/uk-companies-house-enricher`) Actor

Bulk-enrich UK companies from the official Companies House Public Data API. Company-level data only — no officers, PSCs or personal details. Retries, rate-limit handling and per-row errors.

- **URL**: https://apify.com/leathered_luna/uk-companies-house-enricher.md
- **Developed by:** [SiennaWorks](https://apify.com/leathered_luna) (community)
- **Categories:** Lead generation
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.50 / 1,000 companies enriched

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## UK Companies House Company Enricher (Official API)

Bulk-enrich UK companies from the **official Companies House Public Data API**. Built for sales ops, KYB / due diligence and AI agents that need a reliable, flat company record — not a director-lead list.

### How this is different

Most Companies House Actors on Apify sell **officers, PSCs and personal details**. This one does not.

- Company-level fields only. The Actor **never calls** the officers or persons-with-significant-control endpoints.
- Recent filings **exclude** officer and PSC categories. Filing descriptions are sanitised so personal names are not interpolated.
- Charge data is **counts only** (total, outstanding, satisfied). Chargeholder names are discarded.
- One bad company does **not** fail the run. Each input row gets a clear `status` (`ok`, `not_found`, `name_low_confidence`, `rate_limited`, …).
- The official 600 requests / 5 minutes limit is honoured: the client paces requests, reads `X-Ratelimit-*` headers, and backs off on HTTP 429 and 5xx.

You supply your own free Companies House API key, so the Actor has **no API cost** to the publisher.

### What you get

For each company, a flat record including:

| Area | Fields |
|---|---|
| Identity | Company number and name, type, status, status detail, jurisdiction, Companies House URL |
| Risk flags | `is_active`, `is_proposal_to_strike_off`, `accounts_overdue`, `confirmation_statement_overdue`, `has_charges`, `charges_outstanding`, `has_insolvency_history`, `has_been_liquidated` |
| Profile | Incorporation date, company age in years, SIC codes **with official descriptions**, registered office (plus dispute / undeliverable flags) |
| Accounts & CS | Next due dates, last accounts type, overdue flags derived from official dates when needed |
| Changes | Previous names, last N **company-level** filings (accounts, confirmation statements, name/address changes, charges, insolvency, incorporation) |
| Name search | `match_confidence`, `match_type`, and alternative matches (number + name + status only) |

An example record is in [`examples/example_output.json`](examples/example_output.json).

### Input

1. Get a **free REST API key** from the [Companies House Developer Hub](https://developer.company-information.service.gov.uk). You register with an email address; the Public Data API itself is free. Paste the key into `companiesHouseApiKey` (secret field).
2. Provide company numbers, names, or a mixed list:

```json
{
    "companiesHouseApiKey": "YOUR_KEY",
    "companyNumbers": ["00445790", "00102498"],
    "companyNames": ["TESCO PLC"],
    "maxFilings": 5,
    "includeChargesSummary": true,
    "minNameMatchConfidence": 0.72
}
```

Numbers are normalised automatically (`102498` → `00102498`; prefixes such as `SC`, `NI`, `OC` are padded correctly). Name search uses the official `/search/companies` endpoint and keeps the best match only if `match_confidence` is at or above the threshold (default 0.72).

### Pricing (suggested, pay-per-event)

**$0.0025 per successfully enriched company** ($2.50 per 1,000).

- Charged only when `status` is `ok`.
- Not-found, low-confidence name matches and validation errors are still returned, free.
- Users also pay normal Apify platform usage (small: this Actor only makes official JSON API calls, no proxies or browsers). Recommended memory: 256 MB.

This sits between cheap number-only wrappers (~$0.0015/item) and officer/PSC scrapers (~$0.004+/company), and is meant to pay for reliability and derived flags rather than personal data.

Enable pay-per-event in Apify Console when publishing and register the event name `company-enriched` at $0.0025. The same definition lives in [`.actor/pay_per_event.json`](.actor/pay_per_event.json).

### Rate limits and throughput

Companies House allows **600 requests per 5 minutes per API key**. This Actor typically makes:

- 1 call for a company number (profile)
- +1 if name search is needed
- +1 for filing history (optional)
- +1 for charge counts when `has_charges` is true (optional)

So a full enrichment is usually 2–4 official calls. At the default pacing (~0.55s between calls, staying under 600/5 min) you can enrich on the order of **150–250 companies per 5 minutes**. The client will wait, not crash, if the window is nearly empty.

### Shared key vs user-supplied key

**This Actor requires a user-supplied key.** That is the recommended design.

A publisher-held shared key is technically possible as an Apify Actor secret / environment variable, but it is a poor fit here:

- The 600 / 5 minute cap is **per key**. Every customer would share one bucket, so the Actor would stall or 429 under modest concurrent use.
- Companies House may restrict applications that try to work around rate limits. A shared production key also becomes a single point of failure if it is revoked.
- Registering a publisher key requires a Companies House developer account (email at minimum). This project does not ship a key and does not sign up for one on anyone’s behalf.

User-supplied keys keep costs at zero, isolate rate limits, and keep credentials in the user’s secret input.

### Legal and data protection

- Source: official [Companies House Public Data API](https://developer.company-information.service.gov.uk). Companies House imposes no licence restrictions on use of information on the public register; you remain responsible for data protection and any third-party copyright. Do not reproduce the Crown insignia. See [public task, copyright and Crown copyright](https://www.gov.uk/government/publications/companies-house-accreditation-to-information-fair-traders-scheme/public-task-copyright-and-crown-copyright).
- This Actor is designed to avoid personal data (no officers, PSCs, dates of birth, residential addresses, or emails). Registered office addresses are company addresses as filed.
- Do not use the output to send unsolicited electronic marketing to individuals (UK PECR).

### Reliability behaviour

| Situation | Behaviour |
|---|---|
| Invalid or missing API key | The run fails immediately with a clear message. The key is never logged or stored in the dataset. |
| Unknown company number | Row status `not_found`. Other rows continue. |
| Ambiguous or weak name match | Row status `name_low_confidence`, with alternative matches. No charge. |
| HTTP 429 / 5xx | Automatic retry with backoff, honouring `X-Ratelimit-Reset` and `Retry-After`. |
| Filing history or charges fail after a good profile | Row stays `ok` with `partial_errors` listing the missing part. |
| User’s pay-per-event budget is exhausted | The Actor stops cleanly after the last charged row. |

### Local development

```bash
python -m venv .venv
source .venv/bin/activate
pip install -r requirements-dev.txt
pytest -q
```

Live API tests are skipped unless `COMPANIES_HOUSE_API_KEY` is set. Do not put a personal key in the repo or in chat. A key is not required to run the mock test suite.

### Changelog

- **0.1** — First publish-ready version: bulk number/name input, official API client with rate-limit handling, company-only output, derived overdue and risk flags, pay-per-event charge on successful rows.

# Actor input Schema

## `companiesHouseApiKey` (type: `string`):

Your free REST API key from the Companies House Developer Hub (https://developer.company-information.service.gov.uk). Stored as a secret, used only to call the official API, and never written to the dataset. Authentication is HTTP basic auth with the key as the username.

## `companyNumbers` (type: `array`):

UK company numbers to enrich, one per item. Leading zeros are optional (102498 and 00102498 are treated as the same). Scottish, Northern Irish and LLP prefixes such as SC, NI and OC are supported.

## `companyNames` (type: `array`):

Company names to look up via the official search API. The best match is returned with a match_confidence score. If the score is below the threshold, the row is marked name_low_confidence and alternative matches (company number and name only) are included — the run does not fail.

## `companies` (type: `array`):

Optional mixed list. Values that look like a UK company number are treated as numbers; everything else is searched as a name. Duplicates are ignored.

## `maxFilings` (type: `integer`):

How many recent *company-level* filings to include (accounts, confirmation statements, name and address changes, charges, insolvency, incorporation). Officer and PSC filings are always excluded. Set 0 to skip filing-history calls.

## `includeFilings` (type: `boolean`):

When enabled, the Actor makes one extra official API call per company for filing history. Officer/PSC filings and personal names are stripped.

## `includeChargesSummary` (type: `boolean`):

When a company has charges, fetch official counts only (total, outstanding, satisfied). Chargeholder names are never returned.

## `minNameMatchConfidence` (type: `number`):

Between 0 and 1. Name searches below this score are returned as name_low_confidence and are not charged. Exact normalised matches score 1.0.

## Actor input object example

```json
{
  "companyNumbers": [
    "00445790",
    "00000006"
  ],
  "companyNames": [
    "TESCO PLC"
  ],
  "maxFilings": 5,
  "includeFilings": true,
  "includeChargesSummary": true,
  "minNameMatchConfidence": 0.72
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "companyNumbers": [
        "00445790",
        "00000006"
    ],
    "companyNames": [
        "TESCO PLC"
    ],
    "maxFilings": 5,
    "minNameMatchConfidence": 0.72
};

// Run the Actor and wait for it to finish
const run = await client.actor("leathered_luna/uk-companies-house-enricher").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "companyNumbers": [
        "00445790",
        "00000006",
    ],
    "companyNames": ["TESCO PLC"],
    "maxFilings": 5,
    "minNameMatchConfidence": 0.72,
}

# Run the Actor and wait for it to finish
run = client.actor("leathered_luna/uk-companies-house-enricher").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "companyNumbers": [
    "00445790",
    "00000006"
  ],
  "companyNames": [
    "TESCO PLC"
  ],
  "maxFilings": 5,
  "minNameMatchConfidence": 0.72
}' |
apify call leathered_luna/uk-companies-house-enricher --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,leathered_luna/uk-companies-house-enricher"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/SohTuCizrSpCEAjLi/builds/zS7BVB48OO5QFwF2B/openapi.json
