# UK Companies House (`vermolov/companies-house`) Actor

Look up UK company profiles, officers and persons with significant control from the official Companies House Public Data API.

- **URL**: https://apify.com/vermolov/companies-house.md
- **Developed by:** [Viktor Ermolov](https://apify.com/vermolov) (community)
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.00 / 1,000 companies returned

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 (Apify actor)

Look up UK company profiles, officers (directors and secretaries) and persons with significant control (PSC) from the official [Companies House Public Data API](https://developer.company-information.service.gov.uk/).

This actor returns **only fields of the public register**, as the API returns them. It does not enrich records with emails, phone numbers, social profiles, or any other personal data from third-party sources.

> Not published on Apify Store yet. Publishing happens only after a separate signal (API key and payout KYC ready). Do not run `apify push` or paid `call-actor` runs from this repository.

### What it does

- Accepts a list of company numbers and/or names, and/or a search query.
- Resolves names through `GET /search/companies`.
- Fetches `GET /company/{company_number}` for each company.
- Optionally fetches officers (`GET /company/{company_number}/officers`) and PSCs (`GET /company/{company_number}/persons-with-significant-control`), following pagination.
- Writes one dataset item per company. PPE event `company` is charged once per successfully returned company. Failed lookups are written as error rows and are not charged.

Official API docs: [company profile](https://developer-specs.company-information.service.gov.uk/companies-house-public-data-api/reference/company-profile/company-profile), [officers](https://developer-specs.company-information.service.gov.uk/companies-house-public-data-api/reference/officers/list), [PSC list](https://developer-specs.company-information.service.gov.uk/companies-house-public-data-api/reference/persons-with-significant-control/list).

### Input

| Field | Type | Description |
| --- | --- | --- |
| `companies` | string\[] | Company numbers and/or names. Numbers are requested directly (unpadded digits are padded to 8 characters). Each name is resolved to the top search hit. |
| `searchQuery` | string | Search the register by name. Up to `maxSearchResults` matches are returned as full company records. |
| `maxSearchResults` | integer | Cap for `searchQuery` (default 20, max 200). |
| `includeOfficers` | boolean | Default `true`. |
| `includePsc` | boolean | Default `true`. |
| `companiesHouseApiKey` | secret string | **Required.** Your Companies House Public Data API key (`isSecret`). There is no environment-variable fallback: Store and local runs must pass this input field. |

You must provide `companiesHouseApiKey` and at least one of `companies` or `searchQuery`.

Register a free REST API key in the [Companies House Developer Hub](https://developer.company-information.service.gov.uk/). The API uses HTTP Basic authentication: the key is the username and the password is empty. **Never commit a key.** `.env` is gitignored. The actor does not read `COMPANIES_HOUSE_API_KEY` from the environment, so a shared actor secret cannot be used by runs that omit the input key.

Example input:

```json
{
  "companies": ["00445790", "Tesco PLC"],
  "searchQuery": "Barclays",
  "maxSearchResults": 5,
  "includeOfficers": true,
  "includePsc": true,
  "companiesHouseApiKey": "YOUR_KEY"
}
```

### Output

Successful items look like:

```json
{
  "company_number": "00445790",
  "profile": { "company_name": "TESCO PLC", "company_number": "00445790" },
  "officers": { "items": [], "total_results": 0 },
  "psc": { "items": [], "total_results": 0 }
}
```

`profile`, `officers` and `psc` are the API resources (officer and PSC pages are merged into `items`). No extra personal fields are added. A 404 on officers or PSC is treated as an empty `items` list. Lookup failures become rows with `error` and `errorMessage` (not charged).

Before a successful item is written, a defensive filter removes `date_of_birth.day` (month and year are kept) and any `usual_residential_address` / `residential_address` fields from officers and PSC items, in case the API ever returns them. Service addresses and the company `registered_office_address` are left in place.

### Rate limits and retries

Companies House allows **600 requests in any 5-minute period** per application ([rate limiting guide](https://developer-specs.company-information.service.gov.uk/guides/rateLimiting)). The actor enforces this with a sliding window before each request, and retries:

- HTTP 429: wait for `Retry-After` in full when present (delta-seconds or HTTP-date); never retry earlier. If the header is absent, wait for the remainder of the local 5-minute window, or the full 5 minutes if the local window still has capacity. If the required wait exceeds that 5-minute budget, fail the request instead of retrying early.
- HTTP 5xx: exponential backoff.
- HTTP 401 and 403: fail immediately. Do not retry.

Applications that regularly exceed or try to bypass the limit may be banned. This actor does not use multiple keys to increase throughput.

### Pricing (PPE)

The actor is designed for pay-per-event billing:

| Event | When it is charged | Price |
| --- | --- | --- |
| `company` | Once per company successfully written to the dataset | **$0.004 per company** (incubator decision). Set this price in Apify Console at publish time. |
| `apify-actor-start` | Automatic synthetic start event (do not charge in code) | Apify default $0.00005; confirm in Console at publish time. |

Event names and descriptions live in `.actor/pay_per_event.json`. Code charges `company` via `Actor.pushData(item, 'company')` after the record is written. At publish time, disable the synthetic `apify-default-dataset-item` event so successful rows are not billed twice.

### Privacy note (UK GDPR)

Companies House is required to make data about companies and their officials available for public inspection under the Companies Act 2006. This actor only requests that **public register** and returns it to you for the duration of the run. It does not keep a copy after the run's dataset is discarded, and it does not add personal data from anywhere else. Usual residential (home) addresses and full dates of birth are not published on the public register; fields such as a director's name, nationality, month and year of birth, and service address may be.

If you store, combine, or otherwise process the personal data of officers or PSCs that you receive, **you are the controller** of that processing under UK GDPR and must have a lawful basis. Companies House imposes no extra rules on how public-register information is used, and is not responsible for your use of it. You are responsible for complying with UK GDPR, copyright, and any other applicable law before you keep or publish the data.

See [Companies House data products](https://www.gov.uk/guidance/companies-house-data-products) and the [Companies House personal information charter](https://www.gov.uk/government/organisations/companies-house/about/personal-information-charter).

Retention: the actor itself does not store register data beyond the dataset of the current run. How long you keep a copy is your responsibility.

The lawful basis for the developer's own processing when the actor runs, and how to contact us about your data, are in [docs/privacy-lawful-basis.md](docs/privacy-lawful-basis.md).

### Publishing checklist

Do not publish from this repository until Арина signals that the Companies House key and payout KYC are ready. Then, in Apify Console at publish time:

1. Set the PPE event `company` to **$0.004 per company** (incubator decision).
2. At the same time, disable the synthetic `apify-default-dataset-item` event so successful rows are not billed twice (the actor already charges `company` via `Actor.pushData`).
3. Companies House API keys belong only in the secret input `companiesHouseApiKey`. Do not set a shared `COMPANIES_HOUSE_API_KEY` on the published actor — the actor will not use it, and Store users must bring their own key. Never commit a key and never put one in the Store listing.

Until that signal: no `apify push`, no Store publish, no paid Apify runs.

### Development

```bash
npm ci
npm run lint
npm test
```

Tests mock the HTTP API. They do not need a Companies House key and do not make network calls to Companies House. A live key for a manual check is not in this repository; it will be provided separately when needed.

Local actor run (optional, still uses your own key in `companiesHouseApiKey`, never commit it):

```bash
## storage/key_value_stores/default/INPUT.json
## Then: apify run
```

Do not `apify push` and do not start paid Apify runs from this repo until publication is approved.

# Actor input Schema

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

Company numbers and/or names from the UK register. Numbers are requested directly; names are resolved through the official Companies House search endpoint (top match per name).

## `searchQuery` (type: `string`):

Search the register by company name. Up to maxSearchResults matches are returned, each as a full company record.

## `maxSearchResults` (type: `integer`):

Maximum number of companies to return for searchQuery (1–200).

## `includeOfficers` (type: `boolean`):

Fetch the official officers (directors and secretaries) list for each company.

## `includePsc` (type: `boolean`):

Fetch the official persons-with-significant-control (PSC) list for each company.

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

Required. Your Companies House Public Data API key, sent as the HTTP Basic username with an empty password. There is no environment-variable fallback. Register a free key at https://developer.company-information.service.gov.uk/

## Actor input object example

```json
{
  "companies": [
    "00445790",
    "TESCO PLC"
  ],
  "maxSearchResults": 20,
  "includeOfficers": true,
  "includePsc": true
}
```

# Actor output Schema

## `overview` (type: `string`):

Default dataset items, with the overview view selected.

# 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 = {
    "companies": [
        "00445790",
        "TESCO PLC"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("vermolov/companies-house").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 = { "companies": [
        "00445790",
        "TESCO PLC",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("vermolov/companies-house").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 '{
  "companies": [
    "00445790",
    "TESCO PLC"
  ]
}' |
apify call vermolov/companies-house --silent --output-dataset

```

## MCP server setup

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

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/e3euLdD5YmiQoLU0e/builds/o6agsXQxJw95Dhe0w/openapi.json
