Canadian Recalls and Safety Alerts API Guide

Table of contents

Introduction

The Recalls and Safety Alerts web site brings together information from Health Canada, Transport Canada, and the Canadian Food Inspection Agency in order to provide Canadian consumers with a central location to find recall and safety information.

This Application Programming Interface (API) allows developers to access that information in JSON format for reuse in their own applications.

The base URI for the Recalls and Safety Alerts site is http://healthycanadians.gc.ca/recall-alert-rappel-avis/index-eng.php. Any requests are made relative to this URI.

Recent recalls

The place where most applications would start is with recent recalls. This request returns a response with the 15 latest recalls in each category.

Parameters

There is only one parameter in the request: language.

Request language parameters
Parameter Meaning Values Required? Notes
/api/recent/lang Changes language
  • en - English
  • fr - French
Yes Determines whether the response is in English or French.

Recent recalls can be accessed via these URIs:

Response format

The response is in JSON, and consists of a result object that contains five objects:

Response result objects
Key Value
ALL The latest 15 recalls from any category, as an array of 15 recall objects
FOOD The latest 15 recalls from the food category, as an array of 15 recall objects
VEHICLES The latest 15 recalls from the vehicles category, as an array of 15 recall objects
HEALTH The latest 15 recalls from the health products category, as an array of 15 recall objects
CPS The latest 15 recalls from the consumer products category, as an array of 15 recall objects

Each recall object consists of the following values:

Recall object values
Key Value
recallId The ID of the recall.
title The title of the recall.
category An array of categories in which the recall was published (typically only 1 category is seen):
1 for food, 2 for vehicles, 3 for health products, 4 for consumer products.
date_published UNIX timestamp for publication date
url A partial URL that provides the complete details of the recall in JSON format.

Sample response

{
    "results": {
        "ALL": [{ //All categories
            "recallId": "41799",
            "title": "Enjoying Leftover Food Safely",
            "category": ["1"],
            "date_published": 1412899200,
            "url": "\/api\/41799\/en"
        }],
        "FOOD": [{ //Food recalls and alerts, category 1
            "recallId": "41799",
            "title": "Enjoying Leftover Food Safely",
            "category": ["1"],
            "date_published": 1412899200,
            "url": "\/api\/41799\/en"
        }],
        "VEHICLE": [{ //Vehicle recalls and alerts, category 2
            "recallId": "41163",
            "title": "FORD issued a recall on the ESCAPE,  and FOCUS models",
            "category": ["2"],
            "date_published": 1407801600,
            "url": "\/api\/41163\/en"
        }],
        "HEALTH": [{ //Health product  recalls and alerts, category 3
            "recallId": "41655",
            "title": "Health Canada takes action to stop import of products from three  sites in India",
            "category": ["3"],
            "date_published": 1412035200,
            "url": "\/api\/41655\/en"
        }],
        "CPS": [{ //Consumer product recalls and alerts, category 4
            "recallId": "41765",
            "title": "Shoppers Drug Mart recalls \"Novelty Toy\" Halloween  Squish Ball",
            "category": ["4"],
            "date_published": 1412899200,
            "url": "\/api\/41765\/en"
        }],
    }
}			

jQuery example

Example for a function that appends a list of the most recent recalls of all categories to an element with id "#responses", given a language selection:

function getRecent(lang) {
    var base = 'http://healthycanadians.gc.ca/recall-alert-rappel-avis';
    var uri = base + '/api/recent/' + lang;
    $.ajax({
        url:uri,
        type:'GET',
        Accept:"application/json",
        dataType: 'json',
        success:function(data){
            var frag = document.createDocumentFragment();
            for (var i=0; i<data.results.ALL.length; i++) {
                var a = document.createElement("a");
                var title = document.createTextNode(data.results.ALL[i].title);
                a.appendChild(title);
                a.setAttribute("href", base + data.results.ALL[i].url);
                frag.appendChild(a);
                frag.appendChild(document.createElement("br"));
            }
            $("#responses")[0].appendChild(frag);
        },
        error:function(error){
        },
    });
    return;
};			

Recall details

When requesting the recall details you only have to specify two parameters in the API call, the recall ID of the recall and the language (en or fr) that you would like the output in.

Parameters

Recall detail parameters
Parameter Meaning Values Required? Notes
/api/##### Returns recall details ##### - ID of the recall to be returned Yes Recall IDs can be found by doing a request for recent recalls, searching using the API, or via the Recalls and Safety Alerts website.
/api/#####/lang Changes language
  • en - English
  • fr - French
No, but defaults to English if not specified Determines whether the response is in English or French.

Response format

Response format values
Key Value
url URL for the recall on the full Recalls and Safety Alerts website
recallId ID of the recall
start_date UNIX timestamp for the recall start date
date_published UNIX timestamp for the publication date
category The category in which the recall was published; 1 for food, 2 for vehicles, 3 for health products, 4 for consumer products.
panels More details about the recall. A "panel" corresponds to approximately one section of the recall on the full webpage. Of those panels, the following are likely to be of most interest:
  • basic_details: a short summary of the recall
  • cms_issue_problem: details about the issue. May not be present in every recall.
  • cms_who_what_consumer: instructions to consumers (ie, to return a product to the retailer.) Usually present in consumer product recalls.
  • details: details about the issue. May not be present in every recall.
  • product_1: details about the affected product. For a recall involving multiple products, subsequent panels labeled product_2,product_3, and so on will be present.
  • more_information: references to other information about the topic
  • media_enquiries: contact information for media enquiries
  • public_enquiries: contact information for public enquiries
  • id_numbers: ID number for the recall

Sample response

{
    "url": "http:\/\/healthycanadians.gc.ca\/recall-alert-rappel-avis\/hc-sc\/2014\/41799a-eng.php",
    "recallId": "RA-41799",
    "title": "\n Enjoying  Leftover Food Safely",
    "start_date": 1412899200,
    "date_published": -62169984000,
    "category": ["1"],
    "panels": [{
        "panelName": "basic_details",
        "title": "Summary",
        "text": "<b>Issue:<\/b> Food Safety, Important Safety  Information<BR\/><b>Audience:<\/b> General  Public<BR\/><b>Category:<\/b> Other<BR\/><b>Alert  type:<\/b> Information Update<BR\/><b>Department:<\/b>  Health Canada<BR\/>"
    }, {
        "panelName": "cms_issue_problem",
        "title": "Issue",
        "text": "\n Many Canadians enjoy eating leftovers from family dinners and  from dining out as a time-saving and budget-friendly meal. It is important to  remember that leftovers need to be properly handled to help reduce the risk of  foodborne illness. It's estimated that there are approximately 4 million cases  of food-related illnesses in Canada every year. Many of these illnesses could  be prevented by following proper food handling and preparation techniques.\n\n  Here are some tips to help make sure your leftovers are safe to  eat:\n<h3>\n Handling leftovers<\/h3>\n<ul>\n <li>\n  Wash your hands before and after handling  leftovers. Wash all utensils, dishes and work surfaces with hot soapy  water.<\/li>\n <li>\n  Keep  foods out of the danger zone, between 4\u00b0C (40\u00b0F) and 60\u00b0C  (140\u00b0F), to prevent the growth of harmful bacteria. Throw away any cooked  food left in the danger zone for more than two hours.<\/li>\n  <li>\n  Never rely on your nose,  eyes or taste buds to judge the safety of food. You cannot tell if food is  contaminated by its look, smell or taste. <strong>When in doubt, throw it  out!<\/strong><\/li>\n<\/ul>\n<h3>\n Cooling  leftovers<\/h3>\n<ul>\n <li>\n  Refrigerate or freeze all leftovers within  two hours to minimize the chance of bacteria growing.<\/li>\n  <li>\n  Refrigerate all hot  leftovers promptly in uncovered, shallow containers so they cool  quickly.<\/li>\n <li>\n  Very  hot items can first be cooled at room temperature and then refrigerated once  the steaming stops.<\/li>\n <li>\n   Leave the lid off or wrap loosely until the food is cooled to refrigeration  temperature.<\/li>\n<\/ul>\n<h3>\n Storing  leftovers<\/h3>\n<ul>\n <li>\n  Always use a clean container or leak-proof  plastic bag to store leftovers.<\/li>\n <li>\n  Meat from large cooked birds should be cut,  deboned and stored refrigerated or frozen for safety.<\/li>\n  <li>\n  Keep different types of  leftovers separate to prevent cross contamination.<\/li>\n  <li>\n  Don't overstock the  refrigerator - allow cool air to circulate freely.<\/li>\n  <li>\n  Eat refrigerated leftovers  within 2 to 4 days, or freeze them for later use. The recommended refrigeration  times may vary slightly, depending on the food: <a  href=\"http:\/\/healthycanadians.gc.ca\/eating-nutrition\/safety-salubrite\/storage-entreposage-eng.php\">follow  these guidelines<\/a> to be safe.<\/li>\n <li>\n  Label the leftovers so you can identify the  contents and include the date, to make sure they aren't stored too  long.<\/li>\n<\/ul>\n<h3>\n Defrosting leftovers<\/h3>\n<ul>\n  <li>\n  Thaw frozen leftovers in  the refrigerator or using the \"defrost\" setting on your microwave.  Make sure leftovers are completely defrosted before reheating.<\/li>\n  <li>\n  Consume or cook the  leftovers immediately after they have thawed.<\/li>\n<\/ul>\n<h3>\n  Reheating leftovers<\/h3>\n<ul>\n <li>\n  When reheating leftovers, cook to a safe  internal temperature of 74\u00b0C (165\u00b0F).<\/li>\n <li>\n  Use a digital food thermometer to check the  internal temperature.<\/li>\n <li>\n  Bring gravies, soups and sauces to a full,  rolling boil and stir during the process.<\/li>\n <li>\n  Discard uneaten leftovers after they have  been reheated - <strong>don't reheat leftovers more than  once<\/strong>.<\/li>\n<\/ul>\n<h3>\n Reheating in a  microwave<\/h3>\n<ul>\n <li>\n  Use only containers or plastic wrap designed  for use in the microwave.<\/li>\n <li>\n  Loosen the lid or wrap to allow steam to  escape.<\/li>\n <li>\n  Stop  the microwave midway through reheating and stir the food so that the heat is  evenly distributed.<\/li>\n <li>\n   Rotate the plate several times during cooking if your microwave does not  have a rotating tray.<\/li>\n<\/ul>"
    }, {
        "panelName": "more_information",
        "title": "For more information",
        "text": "<p><h3>\n Government of  Canada<\/h3>\n<ul>\n <li>\n   <a href=\"http:\/\/www.healthycanadians.gc.ca\/eating-nutrition\/safety-salubrite\/leftovers-restes-eng.php\">Food  safety tips for leftovers<\/a><\/li>\n <li>\n  <a href=\"http:\/\/www.healthycanadians.gc.ca\/eating-nutrition\/safety-salubrite\/storage-entreposage-eng.php\">Safe  food storage<\/a><\/li>\n <li>\n  <a  href=\"http:\/\/www.healthycanadians.gc.ca\/eating-nutrition\/safety-salubrite\/fours-micro-ovens-eng.php\">Microwaves<\/a><\/li>\n  <li>\n  <a  href=\"http:\/\/www.healthycanadians.gc.ca\/eating-nutrition\/safety-salubrite\/cook-temperatures-cuisson-eng.php\">Safe  internal cooking temperatures<\/a><\/li>\n <li>\n  <a  href=\"http:\/\/www.healthycanadians.gc.ca\/eating-nutrition\/poisoning-intoxication\/index-eng.php\">Food  Poisoning<\/a><\/li>\n<\/ul>\n<h3>\n Partnership for  Consumer Food Safety Education<\/h3>\n<ul>\n <li>\n  <a  href=\"http:\/\/www.befoodsafe.ca\/\">Be Food  Safe<\/a><\/li>\n<\/ul>\n<p>\n Stay connected with  Health Canada, and receive the latest advisories and product recalls using  <a href=\"http:\/\/www.hc-sc.gc.ca\/home-accueil\/sm-ms\/index-eng.php\">social  media<\/a> tools.<\/p><\/p>\n"
    }, {
        "panelName": "media_enquiries",
        "title": "Media enquiries",
        "text": "\n Health Canada<br \/>\n 613-957-2983"
    }, {
        "panelName": "public_enquiries",
        "title": "Public enquiries",
        "text": "\n 613-957-2991<br \/>\n 1-866 225-0709"
    }, {
        "panelName": "id_numbers",
        "title": "Identification number",
        "text": "<b>Identification number:<\/b>  RA-41799<BR\/>"
    }]
}			

jQuery example

Example for a function that appends the title and summary of a recall to an element with id "#responses", given a recall ID and language selection:

function getRecall(id, lang) {
    var base = 'http://healthycanadians.gc.ca/recall-alert-rappel-avis';
    var uri = base + '/api/' + id + '/' + lang;
    $.ajax({
        url:uri,
        type:'GET',
        Accept:"application/json",
        dataType: 'json',
        success:function(data){
            console.log(data.title);
            var frag = document.createDocumentFragment();
            var h2 = document.createElement("h2");
            var title = document.createTextNode(data.title);
            var p = document.createElement("p");
            var text = document.createTextNode(data.panels[0].text);
            h2.appendChild(title);
            p.appendChild(text);
            frag.appendChild(h2);
            frag.appendChild(p);
            $("#responses")[0].appendChild(frag);
        },
        error:function(error){
        },
    });
    return;
};			

Search

The API offers limited search functionality.

Parameters

Note that these parameters are passed in the query string:

Query string parameters
Parameter Meaning Values Required? Notes
/api/search?search=text Searches the database text - the text string to search the database for Yes Response will contain search results for text. Other parameters are optional, see below.
&lang=lang Changes language
  • en - English
  • fr - French
No, but defaults to English if not specified. Determines whether the response is in English or French.
&cat=n Selects specific categories to search
  • 1 - Food
  • 2 - Vehicles
  • 3 - Health Products
  • 4 - Consumer Products
No, searches all categories if not specified. Determines whether the response is in English or French.
&lim=n Limits the number of results A positive integer value n No, defaults to 5 if not specified. If specified, the response will only contain n results.
&off=n Offsets the search results A positive integer value n No, defaults to 0 if not specified. If specified, the response will only contain the nth result onwards. For example, if off=5, then the response will contain only the 6th response onwards.

Example request URIs:

Response format

This is very similar to the response obtained by getting the most recent recalls, with the exceptions that:

  • the number of results returned in the response is not fixed at 15; it can be changed using the lim parameter
  • the number of results found in the database is at the end of the response, as results_count
  • the department where the recall information came from is specified

Otherwise, the organization is the same as recent recalls.

recall objects contain:

Recall object values
Key Value
recallId The ID of the recall; note that this ID is the same ID as used on the Recalls and Safety Alerts website. This ID is also used to retrieve recall details (see the next section for more details.)
title The title of the recall.
department The department where the recall information came from is specified.
category The category in which the recall was published; 1 for food, 2 for vehicles, 3 for health products, 4 for consumer products.
date_published UNIX timestamp for publication date
url A partial URL to get more details about the recall.

Sample response

{
    "results": [{
        "recallId": "41705",
        "title": "Next by Nature brand Dark Chocolate Cherries recalled due to  undeclared peanut",
        "department": "Canadian Food Inspection Agency",
        "date_published": 1412208000,
        "category": ["1"],
        "url": "http:\/\/healthycanadians.gc.ca\/api\/41705\/en"
    }, {
        "recallId": "41349",
        "title": "EBM brand biscuits recalled due to undeclared milk",
        "department": "Canadian Food Inspection Agency",
        "date_published": 1409875200,
        "category": ["1"],
        "url": "http:\/\/healthycanadians.gc.ca\/api\/41349\/en"
    }, {
        "recallId": "41193",
        "title": "Allergens and food safety at school - What's in your child's  lunch?",
        "department": "Health Canada",
        "date_published": 1408492800,
        "category": ["1"],
        "url": "http:\/\/healthycanadians.gc.ca\/api\/41193\/en"
    }, {
        "recallId": "40899",
        "title": "A1 Mountain Globe brand curry powders recalled due to undeclared  peanuts and mustard",
        "department": "Canadian Food Inspection Agency",
        "date_published": 1406764800,
        "category": ["1"],
        "url": "http:\/\/healthycanadians.gc.ca\/api\/40899\/en"
    }, {
        "recallId": "40397",
        "title": "Kawartha Dairy brand Chocolate Ice Cream recalled due to  improperly declared peanuts",
        "department": "Canadian Food Inspection Agency",
        "date_published": 1404086400,
        "category": ["1"],
        "url": "http:\/\/healthycanadians.gc.ca\/api\/40397\/en"
    }],
    "results_count": 90
}			

jQuery example

function doSearch(lang, text, cat, lim, off) {
    var base = 'http://healthycanadians.gc.ca/recall-alert-rappel-avis';
    var uri = base + '/api/search?search=' + text + '&lang=' + lang + '&lim=' + lim + '&off=' + off;
    $.ajax({
        url:uri,
        type:'GET',
        Accept:"application/json",
        dataType: 'json',
        success:function(data){
            var frag = document.createDocumentFragment();
            for (var i=0;i<data.results.length;i++) {
                var a = document.createElement("a");
                var title = document.createTextNode(data.results[i].title);
                a.appendChild(title);
                a.setAttribute("href", data.results[i].url);
                frag.appendChild(a);
                frag.appendChild(document.createElement("br"));
            }
            $("#responses")[0].appendChild(frag);
        },
        error:function(error){
        },
    });
    return;
};			
Date modified: