Count/aggregate over an openFDA dataset
countopenFDA's most valuable feature: aggregate over any dataset by a field to get a top-terms histogram (returns results: [{term, count}] instead of records). Use the '.exact' field suffix to count whole phrases. Example: endpoint 'drug/event', field 'patient.reaction.reactionmeddrapt.exact', search 'patient.drug.medicinalproduct:"aspirin"' → the most common reactions reported for aspirin.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| field | Yes | The field to count/aggregate on (required), e.g. 'patient.reaction.reactionmeddrapt.exact' or 'classification'. Add '.exact' to count whole phrases rather than tokens. | |
| limit | No | Max number of distinct terms to return (1–1000). | |
| search | No | Optional Lucene filter applied before aggregation (same syntax as the search tools). | |
| endpoint | Yes | The openFDA endpoint to query, e.g. 'drug/event', 'device/510k', 'food/enforcement'. |