Many allergen recalls are labeling mistakes: the product contains an allergen the label doesn't declare. The notices are easy to miss. If you run a grocery app, a school meal planner, or a store with a product catalog, you probably want a script that tells you when a new recall mentions an allergen you care about.
This post builds that script in about 30 lines of Python. It uses the Food Recall Monitor API from Wryborg, which puts FDA and USDA FSIS recalls into one JSON schema, with allergens tagged and distribution states pulled out.
The data comes from official U.S. government records, can lag behind them, and is not a safety guarantee. Allergen tags and states are derived during ingest and can be wrong, so open the notice in source_url before you act on one.
Get a key
Subscribe to the free Basic plan on the Food Recall Monitor listing on RapidAPI. Then:
export RAPIDAPI_KEY=YOUR_RAPIDAPI_KEY python3 -m pip install requests Through RapidAPI the endpoints have no version prefix: it's /recalls, not /v1/recalls.
The filters that matter
GET /recalls takes allergen, which accepts the nine FDA major allergens: milk, egg, peanut, tree_nut, soy, wheat, fish, shellfish and sesame. It also takes state (a two-letter code; a state filter also returns NATIONWIDE recalls), date_from and date_to in YYYY-MM-DD, classification, status and limit (1 to 100).
There is no allergen=undeclared. I tried it and got a 422 listing the nine allowed values. Most allergen recalls are labeling errors anyway, and the word "undeclared" shows up in reason, so filter on that client-side if you only want those.
The free plan covers the last 12 months. If your date_from is older, the API clamps it and adds a warnings entry plus an X-History-Clamped header.
The script
It asks for peanut recalls that reached California in the last 90 days, prints anything whose id isn't in a local JSON file, then saves the ids it has seen.
import json import os from datetime import date, timedelta from pathlib import Path import requests HOST = "food-recall-monitor-api.p.rapidapi.com" HEADERS = {"X-RapidAPI-Key": os.environ["RAPIDAPI_KEY"], "X-RapidAPI-Host": HOST} ALLERGEN = "peanut" STATE = "CA" # a state filter also returns NATIONWIDE recalls SEEN_FILE = Path("seen-recall-ids.json") seen = set(json.loads(SEEN_FILE.read_text())) if SEEN_FILE.exists() else set() r = requests.get( f"https://{HOST}/recalls", headers=HEADERS, params={ "allergen": ALLERGEN, "state": STATE, "date_from": (date.today() - timedelta(days=90)).isoformat(), "limit": 25, }, timeout=30, ) r.raise_for_status() page = r.json() new = [x for x in page["data"] if x["id"] not in seen] print(f"{page['total']} recalls in window, {len(new)} new") for x in new: print(x["report_date"], x["classification"], x["firm"], "|", x["reason"]) print(" ", x["source_url"]) SEEN_FILE.write_text(json.dumps(sorted(seen | {x["id"] for x in page["data"]}))) The first run on December 5, 2026 (free plan) printed this, shortened to three of the five rows:
5 recalls in window, 5 new 2026-10-28 Class III El Ruisenor De Mexico, Inc. | undeclared allergen ingredient (Peanuts, Milk) https://api.fda.gov/food/enforcement.json?search=recall_number:%22H-0112-2027%22 2026-10-28 Class I El Ruisenor De Mexico, Inc. | undeclared allergen ingredient (Sesame, Peanuts, Wheat, Soy, Almonds, Walnuts, Yellow#5, Yellow#6, Red#40, Blue#2) https://api.fda.gov/food/enforcement.json?search=recall_number:%22H-0141-2027%22 2026-10-28 Class II El Ruisenor De Mexico, Inc. | undeclared allergen ingredient (Peanuts, Almonds, Sulfites, Yellow#6) https://api.fda.gov/food/enforcement.json?search=recall_number:%22H-0157-2027%22 The second run printed 5 recalls in window, 0 new, which is the point of the seen file.
For FDA recalls, source_url is an openFDA query for that recall number, so it returns JSON rather than a web page. For the consumer-facing notice, search the recall number on FDA's site.
Wire it to something
Print is fine for a test. In production, post new items to a Slack webhook or email, or add them to a review queue. The data is refreshed about every six hours, so polling a few times a day is plenty. Polling more often mostly repeats the same page and uses up requests. Classes follow FDA's scale: Class I is the most serious, and you may want to page a person for those.
Try it
The free plan on RapidAPI includes 500 requests a month, which covers a script like this for a long time. Start from the Food Recall Monitor listing.
If you want the other recall and screening APIs, or the direct sign-up, see wryborg.com and the API.market store.
