Food Standards Agency

Food Standards Agency

Government

UK food hygiene rating data API. The data provides the food hygiene rating or inspection result given to a business and reflects the standards of food hygiene found on the date of inspection or visit by the local authority. Businesses include restaurants, pubs, cafés, takeaways, hotels and other places consumers eat, as well as supermarkets and other food shops.

Visit API

📚 Documentation & Examples

Everything you need to integrate with Food Standards Agency

🚀 Quick Start Examples

Food Standards Agency Javascript Examplejavascript
// Food Standards Agency API Example
const response = await fetch('http://ratings.food.gov.uk/open-data/en-GB', {
    method: 'GET',
    headers: {
        'Content-Type': 'application/json'
    }
});

const data = await response.json();
console.log(data);

Public Rest API Documentation for Food Hygiene Ratings

The Food Hygiene Ratings API provides publicly available data on food hygiene ratings and inspection outcomes for food businesses in the UK. The API allows developers to access food hygiene ratings data in a convenient, machine-readable format. In this blog, we will explore the API with some possible example code in JavaScript.

API Endpoint

The API endpoint for the Food Hygiene Ratings API is http://api.ratings.food.gov.uk/. The endpoint takes the form of a RESTful API, where developers can access data through several HTTP methods such as GET, POST, PUT, and DELETE. Each HTTP request method returns a different data response and status code.

API Example code in JavaScript

Getting information about a food business

To get information about a food business, you can query the API endpoint using the GET method with a URL parameter specifying the business ID. Here is an example of how to get the food hygiene rating for a business using JavaScript:

async function getFoodHygieneRating(businessId) {
  const url = `http://api.ratings.food.gov.uk/businesses/${businessId}`;
  const response = await fetch(url);
  const data = await response.json();
  return data.RatingValue;
}

getFoodHygieneRating(12345)
  .then(rating => console.log(`Food Hygiene Rating: ${rating}`))
  .catch(err => console.error(err));

Searching for food businesses

To search for food businesses, you can query the API endpoint using the GET method with a URL parameter specifying the search term. Here is an example of how to search for food businesses by name using JavaScript:

async function searchFoodBusiness(name) {
  const url = `http://api.ratings.food.gov.uk/businesses?q=${name}`;
  const response = await fetch(url);
  const data = await response.json();
  return data;
}

searchFoodBusiness('Pizza Hut')
  .then(businesses => console.log(`Found ${businesses.length} businesses`))
  .catch(err => console.error(err));

Retrieving food hygiene ratings

To retrieve food hygiene ratings, you can query the API endpoint using the GET method with a URL parameter specifying the authority ID and rating value. Here is an example of how to retrieve food hygiene ratings using JavaScript:

async function getRatings(authorityId, rating) {
  const url = `http://api.ratings.food.gov.uk/ratings?localAuthorityId=${authorityId}&ratingKey=${rating}`;
  const response = await fetch(url);
  const data = await response.json();
  return data;
}

getRatings('927', '5')
  .then(ratings => console.log(`Found ${ratings.length} businesses with rating of 5`))
  .catch(err => console.error(err));

Conclusion

The Food Hygiene Ratings API is an important public resource for developers looking to access information on food businesses in the UK. With the above example code in JavaScript, you can quickly query the API to retrieve rating information and search for food businesses.

📊 30-Day Uptime History

Daily uptime tracking showing online vs offline minutes

Jun 7Jun 9Jun 11Jun 13Jun 15Jun 17Jun 19Jun 21Jun 23Jun 25Jun 27Jun 29Jul 1Jul 3Jul 604008001440Minutes
Online
Offline

Related APIs in Government