3

Two of the sample queries on the open.fda.gov "API Basics" webpage return what appears to be inconsistent results:

  1. https://api.fda.gov/drug/event.json?search=patient.drug.openfda.pharm_class_epc:"nonsteroidal+anti-inflammatory+drug"

    This returns just one patient record with 5 reactions ("ASTHENIA", "DISEASE RECURRENCE", "DIZZINESS", "TRANSIENT ISCHAEMIC ATTACK", "VERTIGO") and one drug ("AGGRENOX").

  2. https://api.fda.gov/drug/event.json?search=patient.drug.openfda.pharm_class_epc:"nonsteroidal+anti-inflammatory+drug"&count=patient.reaction.reactionmeddrapt.exact

    This returns counts for 100 reactions (e.g., "ABDOMINAL DISCOMFORT", "ABDOMINAL PAIN UPPER", ... , "WEIGHT DECREASED", "WEIGHT INCREASED").

The results from the second query are to be expected since NonSteroidal Anti Inflammatory Drugs (NSAIDs) are commonly used. My guess is that the 100 record limit is the default.

My question is: why does the first query return only one (random) patient record? The documentation implies that, by default, the API will return up to the first 1000 records.

2

The first query only returning 1 result is probably a bug with the API. I would suggest reporting it. The total number of records for this query currently is 286,115. You can get more records using the limit parameter. This query will get you the first 50 records.

https://api.fda.gov/drug/event.json?search=patient.drug.openfda.pharm_class_epc:"nonsteroidal+anti-inflammatory+drug"&limit=50

You can use the &skip parameter to walk through the results. Yesterday, you could request fairly large limits. I noticed that today you get an error message if you set the limit to above 100 records. I think they retuned the number of records and limit after they launched on Monday.

They added this to the API Basics on the &limit option:

Return up to this number of records that match the search parameter. Large numbers (above 100) could take a very long time, or crash your browser.

1

Thanks all for your contributions. We return 1 result by default when searching to help manage load on the system. You can edit this to return up to 100 with the limit parameter. For instance:

?search=patient.drug.openfda.pharm_class_epc:"nonsteroidal+anti-inflammatory+drug"&limit=10

Note that due to the amount of data contained in many of these records, querying more than 15 or so at a time can crash your browser. That's why we support the skip parameter, which makes it easy to paginate through records. For instance, if a search has 20 total results, you can get the first 10 with:

?search=patient.drug.openfda.pharm_class_epc:"nonsteroidal+anti-inflammatory+drug"&limit=10

and the second 10 with:

?search=patient.drug.openfda.pharm_class_epc:"nonsteroidal+anti-inflammatory+drug"&limit=10&skip=10

(sorry, had to remove https://api.fda.gov/drug/event.json from the beginning of these as I don't have enough reputation on StackExchange to post more than 2 links)

Sean Herron, openFDA Core Team

  • 1
    Is there a way to specify which result fields are of interest? That would reduce the load on your servers. For example, I am primarily interested in correlating drug names (brand or generic) with the most common (or severe) reactions so a lot of the XML that is returned is currently ignored (discarded). Other than counting you do not provide much control over what is returned. – medidatian Jun 6 '14 at 18:01
  • We'll look in to it, but at first glance I think it will actually increase our load. Pulling a record from ElasticSearch will return the full record, and then we would need to have the added step of stripping out fields not requested. – Sean Herron Jun 9 '14 at 19:08
  • I understand the concern. It would reduce the number of bytes that need to be transmitted to the user (network bandwidth) but that may not be an issue for your system at this point. – medidatian Jun 11 '14 at 2:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.