# OpenFDA Drug & Device Data Scraper (`gochujang/openfda-drug-tracker`) Actor

Query the FDA Open Data API for drug adverse events, drug labels, drug recalls, and device recalls. No API key required. Search by drug name or manufacturer. Filter by date range. Output structured records with key safety signals.

- **URL**: https://apify.com/gochujang/openfda-drug-tracker.md
- **Developed by:** [Hojun Lee](https://apify.com/gochujang) (community)
- **Categories:** Education
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## OpenFDA Drug & Device Data Scraper

Query the **FDA Open Data API** for drug safety data — no API key required.

### What it does

Scrapes four FDA Open Data endpoints:

| Mode | Endpoint | Data |
|------|----------|------|
| `adverse_events` | `/drug/event.json` | FAERS/MedWatch adverse event reports |
| `drug_labels` | `/drug/label.json` | FDA drug labels (SPL) with indications & warnings |
| `drug_recalls` | `/drug/enforcement.json` | Drug enforcement / recall actions |
| `device_recalls` | `/device/enforcement.json` | Medical device enforcement / recall actions |

### Input

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `mode` | string | `adverse_events` | Dataset to query |
| `searchQuery` | string | `aspirin` | Drug name or manufacturer to search for |
| `limit` | integer | `100` | Max records to return (1–1000) |
| `dateRange` | string | `1year` | Time window: `1month`, `6months`, `1year`, `all` |

#### Example input — adverse events for Pfizer

```json
{
  "mode": "adverse_events",
  "searchQuery": "pfizer",
  "limit": 200,
  "dateRange": "1year"
}
```

#### Example input — aspirin recalls (all time)

```json
{
  "mode": "drug_recalls",
  "searchQuery": "aspirin",
  "limit": 50,
  "dateRange": "all"
}
```

### Output (adverse\_events)

```json
{
  "mode": "adverse_events",
  "report_id": "10000004",
  "drug_name": "ASPIRIN",
  "manufacturer": "Bayer",
  "reaction": "headache, nausea",
  "serious": true,
  "outcome": "recovered",
  "report_date": "2026-01-15",
  "country": "US",
  "num_drugs": 2,
  "num_reactions": 3,
  "fetched_at": "2026-09-01T10:00:00+00:00"
}
```

### Output (drug\_recalls / device\_recalls)

```json
{
  "mode": "drug_recalls",
  "report_id": "D-1234-2026",
  "drug_name": "ASPIRIN 325MG TABLETS",
  "manufacturer": "Acme Pharma Inc",
  "recall_class": "Class II",
  "recall_status": "Ongoing",
  "reason": "Subpotent drug product",
  "product_quantity": "500,000 bottles",
  "report_date": "2025-06-01",
  "country": "US",
  "fetched_at": "2026-09-01T10:00:00+00:00"
}
```

### Pricing

| Event | Price |
|-------|-------|
| Actor start | $0.005 |
| Per record fetched | $0.002 |

Fetching 100 records costs approximately **$0.205**.

### FDA API Notes

- **No API key required** — 1,000 requests/day free
- Rate limit: ~40 requests/minute (handled automatically via semaphore + delay)
- For high-volume usage, register for a free FDA API key at https://open.fda.gov/apis/authentication/

### Data Source

All data is sourced from the **FDA Open Data** portal:

- https://open.fda.gov/
- Terms of Service: https://open.fda.gov/terms/

FDA data is public domain — no copyright restrictions.

# Actor input Schema

## `mode` (type: `string`):

Which FDA dataset to query: adverse\_events (MedWatch/FAERS), drug\_labels (SPL drug labels), drug\_recalls (drug enforcement), device\_recalls (device enforcement).

## `searchQuery` (type: `string`):

Drug name or company/manufacturer name to search for. Examples: 'aspirin', 'pfizer', 'metformin', 'johnson'.

## `limit` (type: `integer`):

Maximum number of records to fetch (default: 100, max: 1000). Note: FDA API rate limit is ~40 req/min without a key.

## `dateRange` (type: `string`):

Filter results to a specific time window relative to today.

## Actor input object example

```json
{
  "mode": "adverse_events",
  "searchQuery": "aspirin",
  "limit": 100,
  "dateRange": "1year"
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

## `summary` (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 = {
    "searchQuery": "aspirin"
};

// Run the Actor and wait for it to finish
const run = await client.actor("gochujang/openfda-drug-tracker").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 = { "searchQuery": "aspirin" }

# Run the Actor and wait for it to finish
run = client.actor("gochujang/openfda-drug-tracker").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 '{
  "searchQuery": "aspirin"
}' |
apify call gochujang/openfda-drug-tracker --silent --output-dataset

```

## MCP server setup

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

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/Ww0oGSukcMXzLoibj/builds/wlHMDB90sEsWDGXAg/openapi.json
