Overview
The Food Standards Agency (FSA), established in 2001, serves as a non-ministerial government department responsible for food safety and food hygiene across England, Wales, and Northern Ireland. Its mission involves protecting public health and consumer interests in relation to food. To achieve this, the FSA makes a significant amount of its data publicly accessible through various APIs, primarily catering to developers and technical buyers who require official, up-to-date information on food safety standards and incidents.
The FSA's API offerings are best for applications requiring integration of official food hygiene ratings for businesses, comprehensive allergen and intolerance data, and real-time information on food incidents such as product recalls or contamination alerts. These resources empower developers to build tools that enhance public transparency, support consumer choices, and facilitate data-driven analysis of food safety trends. For example, a mobile application could display hygiene ratings for restaurants nearby, or a supply chain management system could automatically flag businesses with recent food incident reports. All APIs provided by the FSA are free to use, aligning with the agency's commitment to public service and data transparency, and operate under UK government data standards.
Developers interacting with FSA APIs benefit from direct access to structured data. The FSA API reference documentation outlines endpoints, parameters, and response formats, generally requiring no authentication for public data access. This approach simplifies integration for a wide range of uses, from consumer-facing apps to academic research projects. The data covers a broad spectrum, including detailed inspection results for food businesses, advisory information on common allergens, and incident reports crucial for public health monitoring.
Key features
- Food Hygiene Rating Scheme API: Provides access to hygiene ratings for food businesses across England, Wales, and Northern Ireland. This includes details like inspection dates, business types, and scores on structural compliance, hygiene practices, and confidence in management. This API is essential for applications that help consumers make informed decisions about where to eat or shop for food.
- Allergy and Intolerance API: Offers data related to food allergens and intolerances, including regulatory guidance and information on specific allergenic ingredients. This utility assists developers in creating tools that support individuals with dietary restrictions or food businesses in ensuring compliance with allergen labeling requirements.
- Food Incidents API: Delivers information on food hazards, product recalls, and other food-related incidents. This API is critical for real-time monitoring and allows integration into systems that alert consumers or businesses about potential food safety risks, helping to mitigate public health threats.
- Public Health Data Analysis: The structured and accessible nature of the data supports analytical applications, enabling researchers and policymakers to identify trends in food safety, assess the effectiveness of interventions, and inform future regulatory strategies based on the FSA's data and research initiatives.
- Open Data Policy: Adherence to an open data policy means all APIs are freely available, promoting transparency and widespread use of public sector information without licensing costs.
Pricing
All APIs provided by the Food Standards Agency are free to use. There are no subscription fees, usage-based charges, or tiered plans for accessing the public datasets. This model supports the FSA's public service mandate to ensure transparency and broad access to crucial food safety information.
| Service Tier | Cost | Notes |
|---|---|---|
| Standard Access | Free | Access to all public Food Standards Agency APIs, including Food Hygiene Rating Scheme, Allergy and Intolerance, and Food Incidents APIs. No authentication generally required for public data. |
For detailed information on data access and terms of use, refer to the Food Standards Agency's data portal.
Common integrations
- Consumer-facing applications: Mobile apps and websites displaying hygiene ratings for local restaurants, takeaways, and food shops, integrating data from the Food Hygiene Rating Scheme API.
- E-commerce platforms: Integrating allergen information into product listings using the Allergy and Intolerance API to help consumers with specific dietary needs make informed purchasing decisions.
- Business intelligence dashboards: Tools for local authorities or food businesses to monitor hygiene compliance trends and food incident reports by pulling data from relevant FSA APIs.
- Supply chain management systems: Automated alerts for food businesses regarding product recalls or specific food incidents by integrating with the Food Incidents API.
- Government data aggregation: Platforms like Data.gov.uk integrating FSA datasets to provide a centralized hub for public sector information in the UK.
Alternatives
- Local Authority Websites (UK): While less programmatic, individual local council websites in the UK often publish local food hygiene inspection results directly.
- Data.gov.uk: A broader portal for UK government open data, which may link to or host some FSA datasets, though not always with direct API access for all data points.
- Open Food Facts: A collaborative, open database of food products from around the world. It provides extensive nutritional information and food characteristics, often crowdsourced, offering a different scope than the regulatory focus of the FSA.
Getting started
To access data from the Food Standards Agency's Food Hygiene Rating Scheme API, you can make a simple HTTP GET request. This example demonstrates how to retrieve a list of all authorities registered with the scheme using Python's requests library. No API key or authentication is typically required for public endpoints.
import requests
import json
# Define the base URL for the Food Hygiene Rating Scheme API
BASE_URL = "https://api.ratings.food.gov.uk/Authorities"
# Define headers, including the API version requested by the FSA for their APIs
# More details on required headers are available in the official API documentation.
HEADERS = {
"x-api-version": "2"
}
try:
# Make the GET request to retrieve the list of authorities
response = requests.get(BASE_URL, headers=HEADERS)
# Raise an HTTPError for bad responses (4xx or 5xx)
response.raise_for_status()
# Parse the JSON response
authorities_data = response.json()
# Print the first few authorities to verify
print("Successfully retrieved authorities. First 5:")
for i, authority in enumerate(authorities_data.get("authorities", [])):
if i >= 5:
break
print(f" ID: {authority.get('LocalAuthorityId')}, Name: {authority.get('Name')}")
# Optionally, print the full JSON for inspection
# print(json.dumps(authorities_data, indent=2))
except requests.exceptions.HTTPError as http_err:
print(f"HTTP error occurred: {http_err} - {response.text}")
except requests.exceptions.ConnectionError as conn_err:
print(f"Connection error occurred: {conn_err}")
except requests.exceptions.Timeout as timeout_err:
print(f"Timeout error occurred: {timeout_err}")
except requests.exceptions.RequestException as req_err:
print(f"An unexpected error occurred: {req_err}")
except json.JSONDecodeError as json_err:
print(f"Error decoding JSON response: {json_err} - Response text: {response.text}")
This Python script connects to the Food Standards Agency's API to fetch a list of all local authorities. Upon successful execution, it will output the IDs and names of the first five authorities, demonstrating a basic interaction with the FSA's public data services. Ensure you have the requests library installed (pip install requests) to run this example. For more detailed requests, such as searching for specific businesses or filtering by hygiene rating, consult the Food Hygiene Rating Scheme API documentation.