# Uk Food Hygiene Ratings Scraper (`b2b_lead_generation/uk-food-hygiene-ratings-scraper`) Actor

Scrape UK Food Hygiene Rating Scheme records from the public Food Standards Agency. Search by business name, address, local authority, type, or rating, or load single venues by FHRSID. Get one flat row per result, ready to export as JSON, CSV, or Excel. Also pulls authority and business-type lists.

- **URL**: https://apify.com/b2b_lead_generation/uk-food-hygiene-ratings-scraper.md
- **Developed by:** [B2B Lead Generation](https://apify.com/b2b_lead_generation) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.99 / 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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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 Food Hygiene Ratings Scraper: FSA Ratings for Restaurants

<p align="center">
  <img src="https://imgur.com/JoDvwrS.png" alt="UK Food Hygiene Ratings Scraper" style="max-width:100%; border-radius:14px; width:680px;" />
</p>

Pull Food Hygiene Rating Scheme records for UK food businesses, published by the Food Standards Agency. One flat row per establishment, local authority, or business type. Export the dataset as JSON, CSV, or Excel.

Search by business name, address, authority, business type, and rating. Open a single establishment by FHRSID. Or download the authority list and the business type list in the same run.

### Use cases

- **Restaurant leads**: collect businesses with a name, postcode, rating, and local authority email
- **Territory lists**: filter food hygiene ratings to one local authority id
- **Rating checks**: keep only rating 5, rating 0, or Exempt
- **Reference data**: save authorities and business types before you map ids in a CRM
- **Scheduled refresh**: rerun the same search so new inspections show up in the dataset

### Input

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `mode` | string | `search` | `search` lists establishments. `detail` loads FHRS ids. `references` loads authorities, then business types. |
| `names` | array | `pizza` | Business names for search, one per line. |
| `address` | string | empty | Address, postcode, or town. Example: `london`. |
| `localAuthorityId` | integer | `0` | Authority id. `0` means any authority. |
| `businessTypeId` | integer | `0` | Business type id. `0` means any type. |
| `ratingKey` | string | empty | Optional rating filter such as `5`, `0`, or `Exempt`. |
| `fhrsIds` | array | `1714497` | Establishment ids for detail mode, one per line. |
| `maxItems` | integer | `100` | Cap on successful rows. Maximum 1000. |
| `requestDelaySecs` | number | `0.3` | Pause between API calls. Minimum 0.3 seconds. |
| `timeoutSecs` | integer | `300` | Stop the run after this many seconds and keep rows already saved. |
| `requestTimeoutSecs` | integer | `30` | Per-request timeout. |
| `proxyConfiguration` | object | `{"useApifyProxy": false}` | Optional. Leave the proxy off unless you need one. |

```json
{
  "mode": "search",
  "names": ["pizza"],
  "address": "london",
  "localAuthorityId": 0,
  "businessTypeId": 0,
  "ratingKey": "",
  "fhrsIds": ["1714497"],
  "maxItems": 100,
  "requestDelaySecs": 0.3,
  "timeoutSecs": 300,
  "requestTimeoutSecs": 30,
  "proxyConfiguration": { "useApifyProxy": false }
}
```

### What data does this actor extract?

Search and detail rows keep the establishment fields, plus `mode` and `scraped_at`.

```json
{
  "AddressLine1": "London Bridge Station",
  "AddressLine2": "2",
  "AddressLine3": "Bermondsey Street",
  "AddressLine4": "London",
  "BusinessName": "Pizza pilgrims",
  "BusinessType": "Restaurant/Cafe/Canteen",
  "BusinessTypeID": 1,
  "ChangesByServerID": 0,
  "Distance": null,
  "FHRSID": 1158712,
  "LocalAuthorityBusinessID": "194198",
  "LocalAuthorityCode": "528",
  "LocalAuthorityEmailAddress": "food@southwark.gov.uk",
  "LocalAuthorityName": "Southwark",
  "LocalAuthorityWebSite": "http://www.southwark.gov.uk/",
  "NewRatingPending": false,
  "Phone": "",
  "PostCode": "SE1 2ER",
  "RatingDate": "2024-09-04T00:00:00",
  "RatingKey": "fhrs_5_en-gb",
  "RatingValue": "5",
  "RightToReply": "",
  "SchemeType": "FHRS",
  "geocode": { "longitude": "-0.0858674", "latitude": "51.5046182" },
  "scores": { "Hygiene": 5, "Structural": 5, "ConfidenceInManagement": 5 },
  "mode": "search",
  "scraped_at": "2026-10-12T00:00:00+00:00"
}
```

A failed request is a separate row with `error`, `input`, and `status`. The run keeps going. Duplicate FHRS ids are dropped. Authority rows dedupe on `LocalAuthorityId`. Business type rows dedupe on `BusinessTypeId`.

### FAQ

**How fresh are the food hygiene ratings?**
You get the current published rating, including `RatingDate` and `NewRatingPending`. A scheduled run is the practical way to pick up newer inspections.

**What if an FHRSID does not exist?**
A missing id becomes one error row. Other ids still run.

**Can I export CSV?**
Yes. Apify datasets export to JSON, CSV, and Excel.

#### Trademark Notice

UK Food Hygiene Ratings and related names, logos, and trademarks belong to their respective owners. Their use in this documentation is solely to identify the source of the data and does not imply affiliation, sponsorship, endorsement, or partnership.

#### Disclaimer

Disclaimer: This Actor is an independent tool and is not affiliated with, endorsed by, sponsored by, or otherwise officially associated with UK Food Hygiene Ratings or its owners. All data is collected from publicly available sources. Users are responsible for complying with the source's terms of use, rate limits, and attribution or licensing requirements.

#### Is web scraping legal?

This Actor only collects publicly available data from UK Food Hygiene Ratings, without logging in or bypassing any access controls. Scraping public data is generally legal, but how you use it matters:

- **Personal data:** If the results include personal data (for example names, emails, or profile details), laws such as the GDPR in the EU and the CCPA in California may apply. Only collect and store personal data when you have a legitimate reason.
- **Copyright:** Some content (articles, images, descriptions) may be protected by copyright. Do not republish full copyrighted content without permission.
- **Terms of use:** Respect the source terms, stated rate limits, and any attribution or non-commercial-use requirements listed in Limits and terms.
- **Legal advice:** This is general information, not legal advice. If you're unsure, consult a lawyer.

To learn more, read Apify's guide: [Is web scraping legal?](https://blog.apify.com/is-web-scraping-legal/)

# Actor input Schema

## `mode` (type: `string`):

search looks up food businesses by name, address, local authority, business type, and rating. detail loads one establishment per FHRSID. references downloads the local authority list and the business type list.

## `names` (type: `array`):

Business name text for search mode, one name per line. Each name is a separate Food Hygiene Rating Scheme search. Ignored for detail and references.

## `address` (type: `string`):

Address, postcode, or town passed to the establishment search. Leave empty to skip this filter. Example: london.

## `localAuthorityId` (type: `integer`):

LocalAuthorityId from the authorities reference list. 0 means any authority. Used only in search mode.

## `businessTypeId` (type: `integer`):

BusinessTypeId from the business types reference list. 0 means any type. Used only in search mode.

## `ratingKey` (type: `string`):

Optional hygiene rating filter for search mode. Examples: 5, 0, Exempt. Leave empty to keep every rating.

## `fhrsIds` (type: `array`):

Food Hygiene Rating Scheme establishment ids for detail mode, one FHRSID per line. A missing id is saved as an error row and the run continues. Ignored for search and references.

## `maxItems` (type: `integer`):

Maximum successful records to save this run. Hard cap is 1000. Error rows do not count toward this limit.

## `requestDelaySecs` (type: `number`):

Seconds to wait between Food Standards Agency requests. Minimum is 0.3. Calls stay sequential.

## `timeoutSecs` (type: `integer`):

Stop the run after this many seconds and keep rows already collected. Default 300. Maximum 3600.

## `requestTimeoutSecs` (type: `integer`):

How long to wait for one Food Standards Agency response before treating that call as failed. Default 30 seconds.

## `proxyConfiguration` (type: `object`):

Optional proxy for api.ratings.food.gov.uk requests. Leave useApifyProxy off. The public ratings API does not need a proxy.

## Actor input object example

```json
{
  "mode": "search",
  "names": [
    "pizza",
    "cafe"
  ],
  "address": "london",
  "localAuthorityId": 0,
  "businessTypeId": 0,
  "ratingKey": "5",
  "fhrsIds": [
    "1714497",
    "1158712"
  ],
  "maxItems": 100,
  "requestDelaySecs": 0.3,
  "timeoutSecs": 300,
  "requestTimeoutSecs": 30,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `dataset` (type: `string`):

Default dataset of food hygiene rating rows.

## `datasetItems` (type: `string`):

JSON items from the default dataset.

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

Table of business name, FHRS id, postcode, rating, and mode.

# 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 = {
    "names": [
        "pizza"
    ],
    "fhrsIds": [
        "1714497"
    ],
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("b2b_lead_generation/uk-food-hygiene-ratings-scraper").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 = {
    "names": ["pizza"],
    "fhrsIds": ["1714497"],
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("b2b_lead_generation/uk-food-hygiene-ratings-scraper").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 '{
  "names": [
    "pizza"
  ],
  "fhrsIds": [
    "1714497"
  ],
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call b2b_lead_generation/uk-food-hygiene-ratings-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,b2b_lead_generation/uk-food-hygiene-ratings-scraper"
        }
    }
}
```

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/dkVsfuc1lAah4vYl0/builds/MTtVNK1JUdfSq687F/openapi.json
