# 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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).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": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=datamule/openfda-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "openFDA Scraper",
        "description": "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.",
        "version": "0.1",
        "x-build-id": "OfE7T327q9MV6KYHt"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/datamule~openfda-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-datamule-openfda-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/datamule~openfda-scraper/runs": {
            "post": {
                "operationId": "runs-sync-datamule-openfda-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/datamule~openfda-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-datamule-openfda-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "endpoint": {
                        "title": "openFDA endpoint",
                        "enum": [
                            "drug/event",
                            "drug/label",
                            "drug/enforcement",
                            "drug/ndc",
                            "drug/drugsfda",
                            "device/event",
                            "device/510k",
                            "device/classification",
                            "device/enforcement",
                            "device/recall",
                            "device/pma",
                            "device/udi",
                            "device/registrationlisting",
                            "device/covid19serology",
                            "food/enforcement",
                            "food/event",
                            "animalandveterinary/event",
                            "tobacco/problem"
                        ],
                        "type": "string",
                        "description": "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.",
                        "default": "drug/event"
                    },
                    "search": {
                        "title": "Search query",
                        "type": "string",
                        "description": "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": {
                        "title": "Count (aggregation) field",
                        "type": "string",
                        "description": "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": {
                        "title": "Sort",
                        "type": "string",
                        "description": "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": {
                        "title": "Max results",
                        "minimum": 1,
                        "type": "integer",
                        "description": "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.",
                        "default": 100
                    },
                    "skip": {
                        "title": "Skip (offset)",
                        "minimum": 0,
                        "maximum": 25000,
                        "type": "integer",
                        "description": "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.",
                        "default": 0
                    },
                    "apiKey": {
                        "title": "openFDA API key (optional)",
                        "type": "string",
                        "description": "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."
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
