Example food enforcement API queries

To help get you started, we have provided some API query examples below. Use the Run query button to call the API and get back results. You can experiment by editing the example queries in the black text box.

Example query

One adverse event report

This query searches for all records in a certain date range, and asks for a single one.

See searchable fields for more about date_started. Brackets [ ] are used to specify a range for date, number, or string fields.

  1. search for all records with receivedate between Jan 01, 2004 and Jan 1, 2016.

  2. limit to 1 record.

Example query

One adverse event report involving a product from a certain industry

This query searches records listing a product associated with a certain industry, and returns a single record.

  1. search for all records where products.industry_code (FDA industry code) contains 23 (Nuts/Edible Seed).

  2. limit to 1 record.

Example query

Count of consumer reactions

This query is similar to the prior one, but returns a count of the 1000 most frequently reported consumer reactions.

count the field reaction.exact (consumer reactions).

The suffix .exact is required by openFDA to count the unique full phrases in the field reactions. Without it, the API will count each word in that field individually—difficulty sleeping would be counted as separate values, difficulty and sleeping.

See searchable fields for more about consumer reactions in adverse event records.

  1. search for all records where products.industry_code (FDA industry code) contains 23 (cereal prep/breakfast food).

  2. limit to 1 record.