# openFDA Scraper (`datamule/openfda-scraper`) Actor

Scrape the U.S. FDA's official openFDA API — drug & device adverse events, recalls/enforcement, 510(k) clearances, product labels, NDC, food & animal events. One actor over 18 official public datasets with the full search/count/sort grammar. Pay per record.

- **URL**: https://apify.com/datamule/openfda-scraper.md
- **Developed by:** [Datamule](https://apify.com/datamule) (community)
- **Categories:** Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.35 / 1,000 record scrapeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## openFDA Scraper

Pull structured public‑health data straight from the **U.S. FDA's official [openFDA API](https://open.fda.gov/)** — no scraping, no anti‑bot fights, no auth required. One Actor covers **18 official FDA datasets** with the full openFDA query grammar (search, count, sort, pagination), and returns clean, table‑ready records with the complete original object preserved.

Great for pharmacovigilance, medical‑device safety monitoring, recall tracking, regulatory & competitive intelligence, research, and data journalism.

### Datasets covered

| Group | Endpoint | What it is |
|-------|----------|------------|
| Drug | `drug/event` | Adverse‑event reports (FAERS) |
| Drug | `drug/label` | Structured product labeling (SPL) |
| Drug | `drug/enforcement` | Drug recalls / enforcement reports |
| Drug | `drug/ndc` | National Drug Code directory |
| Drug | `drug/drugsfda` | Drugs@FDA approvals |
| Device | `device/event` | Medical‑device adverse events (MAUDE) |
| Device | `device/510k` | 510(k) clearances |
| Device | `device/classification` | Device classification |
| Device | `device/enforcement` | Device recalls / enforcement |
| Device | `device/recall` | Device recalls |
| Device | `device/pma` | Pre‑market approvals |
| Device | `device/udi` | Unique device identifiers (GUDID) |
| Device | `device/registrationlisting` | Registration & listing |
| Device | `device/covid19serology` | COVID‑19 serology test performance |
| Food | `food/enforcement` | Food recalls / enforcement |
| Food | `food/event` | Food & cosmetic adverse events (CAERS) |
| Animal | `animalandveterinary/event` | Animal & veterinary adverse events |
| Tobacco | `tobacco/problem` | Tobacco problem reports |

### Input

| Field | Type | Description |
|-------|------|-------------|
| `endpoint` | select | Which openFDA dataset to query (default `drug/event`). |
| `search` | string | openFDA search query, e.g. `patient.drug.medicinalproduct:aspirin` or `classification:"Class I" AND report_date:[20240101 TO 20241231]`. Empty = most recent records. |
| `count` | string | Aggregation field → returns `{term, count}` buckets instead of records, e.g. `patient.reaction.reactionmeddrapt.exact`. Append `.exact` to count whole phrases. |
| `sort` | string | e.g. `receivedate:desc`, `decision_date:desc` (record mode only). |
| `maxResults` | integer | Max records/buckets to return (auto‑paginated). Default 100. |
| `skip` | integer | Starting offset (record mode; openFDA caps `skip` at 25000). |
| `apiKey` | string | Optional free [openFDA API key](https://open.fda.gov/apis/authentication/) — raises the rate limit. Not required. |

See each endpoint's searchable fields in the [openFDA API reference](https://open.fda.gov/apis/).

### Output

Because the 18 datasets have very different native shapes, every record carries a small set of **normalized convenience columns** — `endpoint`, `recordId`, `primaryDate`, `name`, `company`, `classification`, `reason`, `status`, `country`, `state` — **plus the full, lossless original record under `raw`**, so nothing from the source is dropped.

In **count mode** each record is a `{term, count}` bucket.

Example (drug recall):

```json
{
  "endpoint": "drug/enforcement",
  "mode": "search",
  "recordId": "D-0595-2026",
  "primaryDate": "2026-06-04",
  "name": "Gas-X Extra Strength, SIMETHICONE 125 mg ...",
  "company": "Haleon US Holdings LLC",
  "classification": "Class I",
  "reason": "Chemical Contamination ...",
  "status": "Ongoing",
  "country": "United States",
  "state": "NJ",
  "raw": { "...": "the complete original openFDA object" }
}
```

### Pricing

Pay‑per‑result: you are charged per record (or count bucket) returned. Failed or empty queries cost nothing.

### Notes

- Data comes directly from `api.fda.gov` — the official FDA endpoint. This Actor does not modify or validate the underlying data; consult FDA's [disclaimer](https://open.fda.gov/terms/). Do not use openFDA data to make decisions about medical care.
- openFDA is public and free; an optional API key only raises rate limits.
- Deep paging is capped at `skip=25000` by openFDA — for very large pulls, window through the data with a date‑range `search` + `sort`.

# Actor input Schema

## `endpoint` (type: `string`):

Which openFDA dataset to query. Each is an official FDA public dataset with the same search grammar. e.g. drug/event = drug adverse-event reports (FAERS), drug/enforcement = drug recalls, device/510k = device clearances, food/enforcement = food recalls.

## `search` (type: `string`):

openFDA search query (Lucene-style). Field:value with AND/OR, quoted phrases, and ranges. Examples: patient.drug.medicinalproduct:aspirin  |  classification:"Class I" AND report\_date:\[20240101 TO 20241231]  |  device\_name:pacemaker. Leave empty to return the most recent records for the endpoint. See https://open.fda.gov/apis/ for each endpoint's searchable fields.

## `count` (type: `string`):

Switches to openFDA COUNT mode: instead of raw records, return the frequency of values in this field as {term, count} buckets. e.g. patient.reaction.reactionmeddrapt.exact (top reactions), classification (recalls by class), openfda.manufacturer\_name.exact. Leave empty for normal record mode. Append .exact to count whole phrases.

## `sort` (type: `string`):

Sort results by a field, e.g. receivedate:desc, decision\_date:desc, report\_date:asc. Only applies in record mode (not count mode). Leave empty for the API default order.

## `maxResults` (type: `integer`):

Maximum number of records (or count buckets) to return. Record mode paginates automatically at up to 1000 per request. Note: openFDA caps deep paging at skip=25000 — for very large pulls, use a date-range search + sort to window through the data.

## `skip` (type: `integer`):

Starting offset into the result set (record mode only). openFDA caps skip at 25000. Usually leave at 0 and use maxResults; set this only to resume a large pull.

## `apiKey` (type: `string`):

Optional free openFDA API key (get one at https://open.fda.gov/apis/authentication/). Raises the rate limit from 40 req/min & 1,000/day to 240 req/min & 120,000/day. Not required — the API works without it.

## Actor input object example

```json
{
  "endpoint": "drug/event",
  "search": "patient.drug.medicinalproduct:aspirin",
  "maxResults": 100,
  "skip": 0
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "search": "patient.drug.medicinalproduct:aspirin",
    "count": "",
    "sort": "",
    "maxResults": 100,
    "skip": 0,
    "apiKey": ""
};

// Run the Actor and wait for it to finish
const run = await client.actor("datamule/openfda-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "search": "patient.drug.medicinalproduct:aspirin",
    "count": "",
    "sort": "",
    "maxResults": 100,
    "skip": 0,
    "apiKey": "",
}

# Run the Actor and wait for it to finish
run = client.actor("datamule/openfda-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "search": "patient.drug.medicinalproduct:aspirin",
  "count": "",
  "sort": "",
  "maxResults": 100,
  "skip": 0,
  "apiKey": ""
}' |
apify call datamule/openfda-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,datamule/openfda-scraper"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/NyBffGEvunQ5SV7Ni/builds/OfE7T327q9MV6KYHt/openapi.json
