# UK VAT HMRC API (`nocodeventure/uk-vat-hmrc-api`) Actor

Supports Proof of Check. Scrapes UK VAT numbers using the official HMRC service. Validates UK VAT numbers against the official HMRC database.

- **URL**: https://apify.com/nocodeventure/uk-vat-hmrc-api.md
- **Developed by:** [No-Code Venture](https://apify.com/nocodeventure) (community)
- **Categories:** Integrations
- **Stats:** 14 total users, 4 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 results

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/running/actors-in-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 VAT Number Checker

This Apify Actor validates UK VAT numbers using the official HMRC (Her Majesty's Revenue and Customs) service at [tax.service.gov.uk](https://www.tax.service.gov.uk/check-vat-number/enter-vat-details).

### Features

- Validates UK VAT numbers against the official HMRC database
- Returns registration status (valid/invalid)
- Extracts registered business name (for valid numbers)
- Extracts registered business address (for valid numbers)
- **Proof of Check**: Optionally obtain an official HMRC proof reference for your records

### How It Works

This Actor integrates with a server-rendered VAT checker that uses a stateful, session-based HTML flow:

1. **Initialize Session**: GET request to fetch the form page and extract the CSRF token
2. **Submit VAT Number**: POST request with the VAT number and CSRF token
3. **Follow Redirect**: After receiving a 303 redirect, fetch the result page
4. **Parse Results**: Extract VAT validity and business details from the HTML response

### Input

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `vatNumbers` | String\[] | Yes | Array of UK VAT numbers to validate. Can include or exclude the 'GB' prefix (e.g., "GB123456789" or "123456789") |
| `withProof` | Boolean | No | Set to `true` to obtain an official HMRC proof of check reference. Default: `false` |
| `requesterVatNumber` | String | Conditional | Your own UK VAT number. **Required** when `withProof` is `true` |

#### Example Input (Basic)

```json
{
    "vatNumbers": ["GB123456789"]
}
```

#### Example Input (With Proof of Check)

```json
{
    "vatNumbers": ["GB727255821"],
    "withProof": true,
    "requesterVatNumber": "GB123456789"
}
```

### Output

The Actor outputs a dataset with the following fields:

| Field | Type | Description |
|-------|------|-------------|
| `vatNumber` | String | The VAT number that was checked |
| `isValid` | Boolean | Whether the VAT number is valid and registered |
| `businessName` | String | The registered business name (null if invalid) |
| `businessAddress` | String | The registered business address (null if invalid) |
| `proofReference` | String | Official HMRC proof of check reference (null if `withProof` is false or VAT is invalid) |
| `checkedAt` | String | ISO 8601 timestamp of when the check was performed |

#### Example Output (Valid VAT Number)

```json
{
    "vatNumber": "727255821",
    "isValid": true,
    "businessName": "Example Company Ltd",
    "businessAddress": "123 High Street, London, SW1A 1AA",
    "proofReference": null,
    "checkedAt": "2024-01-15T10:30:00.000Z"
}
```

#### Example Output (With Proof Reference)

```json
{
    "vatNumber": "727255821",
    "isValid": true,
    "businessName": "AMAZON EU SARL",
    "businessAddress": "HM REVENUE AND CUSTOMS, RUBY HOUSE, 8 RUBY PLACE, ABERDEEN, AB10 1ZP, GB",
    "proofReference": "EFR-XTU-JFD",
    "checkedAt": "2024-01-15T10:30:00.000Z"
}
```

#### Example Output (Invalid VAT Number)

```json
{
    "vatNumber": "000000000",
    "isValid": false,
    "businessName": null,
    "businessAddress": null,
    "proofReference": null,
    "checkedAt": "2024-01-15T10:30:00.000Z"
}
```

### Project Structure

```text
.actor/
├── actor.json           # Actor config: name, version, runtime settings
├── dataset_schema.json  # Dataset output structure definition
├── input_schema.json    # Input validation & Console form definition
└── output_schema.json   # Output template specification
src/
└── main.ts              # Actor entry point and main logic
storage/                 # Local storage (mirrors Cloud during development)
├── datasets/
├── key_value_stores/
└── request_queues/
Dockerfile               # Container image definition
```

### Technical Notes

- All requests use the same session cookies to maintain state
- When `withProof` is enabled, the Actor requests an official HMRC consultation number that can be used as proof of the VAT check

### Disclaimer

This Actor scrapes the official HMRC public VAT check service.

**Legal Notice**: This tool is provided "as is" without warranty of any kind. The information returned is for reference purposes only and should not be used as the sole basis for business decisions. Always verify VAT registration status through official channels for legal or compliance purposes. The developers assume no liability for any errors, omissions, or consequences arising from the use of this Actor.

### Resources

- [HMRC VAT Check Service](https://www.tax.service.gov.uk/check-vat-number/enter-vat-details)

# Actor input Schema

## `vatNumbers` (type: `array`):

List of UK VAT numbers to validate (max 1000). Can include or exclude the 'GB' prefix.

## `withProof` (type: `boolean`):

Enable to receive a consultation reference number as proof of your VAT check. Requires your own UK VAT number.

## `requesterVatNumber` (type: `string`):

Your own UK VAT number (required when 'Request Proof of Check' is enabled). Used to generate a proof reference.

## Actor input object example

```json
{
  "vatNumbers": [
    "GB727255821"
  ],
  "withProof": false
}
```

# Actor output Schema

## `vatResults` (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 = {
    "vatNumbers": [
        "GB727255821"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("nocodeventure/uk-vat-hmrc-api").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 = { "vatNumbers": ["GB727255821"] }

# Run the Actor and wait for it to finish
run = client.actor("nocodeventure/uk-vat-hmrc-api").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 '{
  "vatNumbers": [
    "GB727255821"
  ]
}' |
apify call nocodeventure/uk-vat-hmrc-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,nocodeventure/uk-vat-hmrc-api"
        }
    }
}
```

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/yfYB6FpGcpNazp3Wl/builds/ZNclEgzrk8Nxfu5hB/openapi.json
