# openFDA Adverse Events Scraper (FAERS) (`devilscrapes/openfda-adverse-events-scraper`) Actor

Export FDA FAERS adverse-event reports as flat, one-row-per-reaction rows — drug names, seriousness flags, patient demographics and reaction outcome — from the public openFDA API. Self-reported, unvalidated data for research, never for medical-care decisions.

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

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

<div align="center">
  <img src=".actor/icon.svg" width="160" alt="Devil Scrapes mark" />

## openFDA Adverse Events Scraper (FAERS)

**💰 $4.20 / 1 000 results**  ·  pay only for results  ·  no credit card to try

*We do the dirty work so your dataset stays clean.* 😈

Export FDA FAERS adverse-event reports as flat, one-row-per-reaction rows — drug names, seriousness flags, patient demographics and reaction outcome — from the public openFDA API. Self-reported, unvalidated data for research, never for medical care decisions.

</div>

***

### 🎯 What this scrapes

The FDA's Adverse Event Reporting System (FAERS) is the world's largest public feed of drug-safety signals, but the raw record is a deeply nested JSON blob that buries seriousness flags and patient data three levels down. This Actor pages `api.fda.gov/drug/event.json` on your search, flattens every report into one row per reaction, each carrying the report's full drug list, and hands pharmacovigilance and competitive-intel teams a table they can pivot on directly. openFDA's own guidance applies here: this is unvalidated, self-reported data, and it should never drive medical care decisions.

### 🔥 What we handle for you

- flattens each FAERS report into one row per reaction — each row carries the report's full drug list — instead of a deeply nested blob
- retries transient 429/5xx responses with backoff so a rate-limit blip does not kill the run
- stops cleanly at your `maxResults` row cap instead of over-fetching openFDA's full result set
- validates every row through a typed Pydantic model before it reaches your dataset

### 💡 Use cases

- Track adverse-event volume for a specific drug ahead of a competitive or regulatory review.
- Feed a pharmacovigilance signal-detection pipeline with flattened seriousness and outcome fields.
- Benchmark reported reaction severity across a drug class over a date range.
- Backfill a research dataset without hand-flattening FAERS' nested JSON.

### ⚙️ How to use it

1. Click **Try for free** at the top of the page.
2. Fill in the input form — most fields have sensible defaults.
3. Click **Start**. Output streams into the run's dataset.
4. Export from **Storage → Dataset** as JSON, CSV, or Excel — or fetch via the API.

### 📥 Input

| Field | Type | Required | Default | Notes |
|---|---|:--:|---|---|
| `searchQuery` | `string` | no | 'patient.drug.medicinalproduct:"ozempic"' | Raw openFDA Lucene-style search expression, passed through to the <code>search</code> query param unmodified, e.g.… |
| `maxResults` | `integer` | no | 20 | Hard cap on rows emitted. Each row is one billed <code>result-row</code> event. |
| `pageSize` | `integer` | no | 20 | openFDA <code>limit</code> per request. openFDA's keyless tier caps this at 100. |
| `proxyConfiguration` | `object` | no | {'useApifyProxy': False} | openFDA is a public government API and does not need a proxy. Leave this off unless your account requires egress… |

#### Example input

```json
{
  "searchQuery": "patient.drug.medicinalproduct:\"ozempic\"",
  "maxResults": 3,
  "pageSize": 3,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

### 📤 Output

Every row is one dataset item.

| Field | Type | Notes |
|---|---|---|
| `safety_report_id` | `string` | FDA safety report identifier (`safetyreportid`). |
| `receive_date` | `string` | Date FAERS received the report, ISO `YYYY-MM-DD` when parseable, else the raw `receivedate` value. |
| `reporter_country` | `string` | Reporter's country code (`primarysource.reportercountry`, falling back to `occurcountry`). |
| `serious` | `boolean` | Whether the report was flagged serious (`serious == "1"`). |
| `seriousness_death` | `boolean` | Whether the report flagged death as an outcome (`seriousnessdeath == "1"`). |
| `seriousness_hospitalization` | `boolean` | Whether the report flagged hospitalization (`seriousnesshospitalization == "1"`). |
| `seriousness_life_threatening` | `boolean` | Whether the report flagged a life-threatening event (`seriousnesslifethreatening == "1"`). |
| `seriousness_disabling` | `boolean` | Whether the report flagged a disabling event (`seriousnessdisabling == "1"`). |
| `patient_age` | `number` | Patient age at onset, unit not normalized (`patient.patientonsetage`). |
| `patient_sex` | `string` | Patient sex mapped to `male` / `female` / `unknown` (`patient.patientsex`). |
| `drug_names` | `string` | Every implicated drug name for this report, from `patient.drug[].medicinalproduct`, joined with `; `. |
| `reaction_term` | `string` | This row's adverse reaction term (`patient.reaction[].reactionmeddrapt`); empty string if the report listed no… |
| `reaction_outcome` | `string` | Reaction outcome mapped to text (e.g. `fatal`, `recovered/resolved`), or `null` if unmapped or missing… |

#### Example output

```json
{
  "safety_report_id": "10188271",
  "receive_date": "2014-05-22",
  "reporter_country": "US",
  "serious": true,
  "seriousness_death": false,
  "seriousness_hospitalization": true,
  "seriousness_life_threatening": false,
  "seriousness_disabling": true,
  "patient_age": 81.0,
  "patient_sex": "female",
  "drug_names": "LANTUS SOLOSTAR",
  "reaction_term": "Stenosis",
  "reaction_outcome": "unknown"
}
```

### 💰 Pricing

Pay-Per-Event — you pay only when these events fire:

| Event | USD | What it is |
|---|---:|---|
| `actor-start` | $0.2 | One-off warm-up charge per run |
| `result-row` | $0.004 | Per unique dataset item |

Example: 1 000 results at the rates above ≈ **$4.20**. No subscription, no minimum, no card to start — Apify gives every new account $5 of free credit.

### 🚧 Limitations

- openFDA's own disclaimer applies in full: this is unvalidated, self-reported adverse-event data and must never be used to make medical care decisions.
- `patient_age` passes through openFDA's raw numeric value without normalizing the reporting unit (years vs. months vs. weeks).
- openFDA's keyless tier rate-limits aggressively (public guidance: ~240 requests/minute); a very large `maxResults` on a broad query may take longer to complete.

### ❓ FAQ

**Do I need an API key?**

No. openFDA serves FAERS keylessly; the Actor stays inside the anonymous rate limit and backs off automatically on 429 responses.

**Can I use this data to evaluate a drug's safety for a patient?**

No. openFDA states its own data is unvalidated and self-reported, and this Actor carries the same disclaimer — do not use these rows to make medical care decisions.

**Why does one report produce multiple rows?**

A report with three reported reactions becomes three rows, each carrying the full drug list for that report — the natural one-row-per-fact join for a reaction-level dataset.

### 💬 Your feedback

Spotted a bug, hit a weird edge case, or need a new field? Open an
issue on the Actor's **Issues** tab on Apify Console — we ship
fixes weekly and we read every report.

***

<div align="center">

Built by **[Devil Scrapes](https://apify.com/DevilScrapes)** 😈 — a small fleet of
opinionated public-data Actors. Honest pricing, real engineering, zero fine print.

</div>

# Actor input Schema

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

Raw openFDA Lucene-style search expression, passed through to the <code>search</code> query param unmodified, e.g. <code>patient.drug.medicinalproduct:"ozempic"</code> or <code>receivedate:\[20240101+TO+20241231]</code>.

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

Hard cap on rows emitted. Each row is one billed <code>result-row</code> event.

## `pageSize` (type: `integer`):

openFDA <code>limit</code> per request. openFDA's keyless tier caps this at 100.

## `proxyConfiguration` (type: `object`):

openFDA is a public government API and does not need a proxy. Leave this off unless your account requires egress through Apify Proxy.

## Actor input object example

```json
{
  "searchQuery": "patient.drug.medicinalproduct:\"ozempic\"",
  "maxResults": 20,
  "pageSize": 20,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `datasetItems` (type: `string`):

All dataset items as JSON.

## `datasetItemsCsv` (type: `string`):

Same data exported to CSV.

## `datasetView` (type: `string`):

Open the run dataset in the Console.

# 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": "patient.drug.medicinalproduct:\"ozempic\"",
    "maxResults": 20,
    "pageSize": 20,
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("devilscrapes/openfda-adverse-events-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 = {
    "searchQuery": "patient.drug.medicinalproduct:\"ozempic\"",
    "maxResults": 20,
    "pageSize": 20,
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("devilscrapes/openfda-adverse-events-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 '{
  "searchQuery": "patient.drug.medicinalproduct:\\"ozempic\\"",
  "maxResults": 20,
  "pageSize": 20,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call devilscrapes/openfda-adverse-events-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,devilscrapes/openfda-adverse-events-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/tdkfPc2ZkVOVIFWUp/builds/Y34eZ9AtMqgfbKlOd/openapi.json
