Openfda Count Values
openfda_count_valuesAggregate and tally unique values for any field across any openFDA endpoint. Returns ranked term-count pairs sorted by count descending. Pair with openfda_search_adverse_events, openfda_search_drug_approvals, openfda_search_device_clearances, openfda_search_recalls, openfda_get_drug_label, or openfda_lookup_ndc when sample records help interpret the aggregates.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | Yes | Field to count. Append .exact for whole-phrase counting of free-text fields (e.g. "patient.reaction.reactionmeddrapt.exact"). Identifier fields openFDA already indexes as keywords (product_ndc, application_number, pma_number) must be counted bare — .exact on those is rejected as not countable. | |
| limit | No | Number of top terms to return (default 100, max 1000) | |
| search | No | Filter query to scope the count (e.g. patient.drug.medicinalproduct:"metformin"). Omit to count across every record in the endpoint. Double quotes, parentheses, and range brackets must balance, and the query must not end on a backslash — each is rejected before the request. | |
| endpoint | Yes | Full openFDA endpoint path (e.g. "drug/event", "device/classification") |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cap | No | The limit applied to the term list. | |
| meta | No | Response metadata | |
| error | No | Present when the call failed. Absent on success. | |
| shown | No | Number of terms returned in this response. | |
| notice | No | Guidance when no terms matched — how to verify the field name or adjust the count expression. Absent when terms are returned. | |
| results | No | Term-count pairs sorted by count descending | |
| termCount | No | Number of distinct terms returned | |
| truncated | No | True when the term list was capped at the limit — more distinct terms may exist. | |
| truncationCeiling | No | Count of the lowest-ranked term returned — omitted terms fall at or below it. |