# FDA Drug Shortages Scraper - Status, NDC & Manufacturer Feed (`groundplanes/openfda-drug-shortages`) Actor

Scrape current, resolved, and discontinued FDA drug shortage records from the official openFDA Drug Shortages API with package NDC, manufacturer, therapeutic category, availability, and ISO update dates.

- **URL**: https://apify.com/groundplanes/openfda-drug-shortages.md
- **Developed by:** [Groundplane Labs](https://apify.com/groundplanes) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.10 / 1,000 shortage records

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?

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

## FDA Drug Shortages Scraper - Status, NDC & Manufacturer Feed

Retrieve current, resolved, and discontinued U.S. Food and Drug Administration (FDA) drug shortage records from the official openFDA Drug Shortages API (`drug/shortages.json`). Filter by shortage status, generic drug name, therapeutic category, and update date to monitor pharmaceutical supply availability, package NDCs, manufacturers, dosage forms, and ISO-formatted dates.

> **Disclaimer:** This Actor is an independent open-data integration tool and is not affiliated with, endorsed by, or sponsored by the U.S. Food and Drug Administration (FDA) or the U.S. Department of Health and Human Services.
>
> **openFDA disclaimer (verbatim, from the openFDA API):** Do not rely on openFDA to make decisions regarding medical care. While we make every effort to ensure that data is accurate, you should assume all results are unvalidated. We may limit or otherwise restrict your access to the API in line with our Terms of Service.

***

### What it does

- Queries the official openFDA Drug Shortages endpoint (`https://api.fda.gov/drug/shortages.json`).
- Normalizes FDA `MM/DD/YYYY` shortage dates (`initial_posting_date` and `update_date`) into strict ISO `YYYY-MM-DD` dates.
- Extracts harmonized `openfda` product metadata (`brandName`, `route`, and `rxOtc` classification) alongside shortage-level fields (`packageNdc`, `genericName`, `companyName`, `status`, `availability`, `therapeuticCategory`, `dosageForm`, `presentation`, `updateType`).
- Validates every output row against the schema before pushing, deduplicates on `packageNdc + updateDate` (or `genericName + companyName + presentation` when package NDC is absent), and sorts newest first by `updateDate` descending.

### Who it's for

- **Hospital & health-system pharmacy procurement teams** monitoring active injectable and oral drug shortages by NDC and therapeutic category.
- **Pharmaceutical supply chain & market intelligence analysts** tracking manufacturer availability updates and shortage resolution timelines.
- **Healthcare data engineering & analytics teams** feeding normalized FDA shortage records into inventory risk dashboards and alerts.

***

### Input

| Field | Type | Default / Prefill | Description |
|---|---|---|---|
| `statuses` | array of strings | `["Current"]` | Filter by FDA drug shortage status: `Current`, `Resolved`, `To Be Discontinued`. Leave empty for all statuses. |
| `genericNameQuery` | string | `""` | Optional case-insensitive substring or keyword to match against `genericName`, `brandName`, or `presentation`. |
| `therapeuticCategories` | array of strings | `[]` | Optional therapeutic category filter values (e.g. `["Cardiovascular", "Anesthesia", "Oncology"]`). |
| `updatedSince` | string | `""` | Optional earliest `updateDate` in `YYYY-MM-DD` format (e.g. `"2026-01-01"`). |
| `openFdaApiKey` | string (secret) | `""` | Optional user-supplied openFDA API key for higher rate limits. Leave blank for keyless public access. |
| `maxItems` | integer | `200` | Maximum number of records to return, sorted newest first by `updateDate`. |

#### Example input JSON

```json
{
  "statuses": ["Current"],
  "genericNameQuery": "",
  "therapeuticCategories": [],
  "updatedSince": "",
  "openFdaApiKey": "",
  "maxItems": 200
}
```

#### Example run options (default max charge $50)

When starting a run via the Apify API or Console, set a default maximum charge limit of **$50** (`"maxTotalChargeUsd": 50`):

```json
{
  "maxTotalChargeUsd": 50
}
```

The Actor checks your remaining spending limit before every dataset push and stops cleanly if the limit is reached.

***

### Output

#### Output fields

| Field | Type | Description |
|---|---|---|
| `packageNdc` | string | null | FDA National Drug Code (NDC) package identifier. |
| `genericName` | string | Generic drug name and strength/form description. |
| `brandName` | string | null | Brand name from openFDA product harmonization, if available. |
| `companyName` | string | null | Manufacturer or labeler company name. |
| `status` | string | Shortage status (`Current`, `Resolved`, `To Be Discontinued`). |
| `availability` | string | null | Current supply availability status reported to FDA (e.g. `Available`, `Limited Availability`, `Unavailable`). Published by openFDA only for `Current` records: always null on `Resolved` and `To Be Discontinued` rows, because the source does not publish it for those segments. |
| `therapeuticCategory` | array of strings | null | FDA therapeutic categories associated with the drug. |
| `dosageForm` | string | null | Dosage form (e.g. `Injection`, `Tablet`, `Capsule`, `Solution`). |
| `presentation` | string | null | Specific package presentation description including NDC. |
| `initialPostingDate` | string | null | Date the shortage was initially posted by FDA in `YYYY-MM-DD` format. |
| `updateDate` | string | null | Most recent FDA shortage update date in `YYYY-MM-DD` format. |
| `updateType` | string | null | Type of latest FDA update (e.g. `New`, `Revised`, `Reverified`, `Resolved`). |
| `route` | array of strings | null | Administration route(s) from openFDA product data. |
| `rxOtc` | string | null | Prescription (`RX`) or over-the-counter (`OTC`) classification derived from openFDA `product_type`. |
| `fdaShortageUrl` | string | URL of the official FDA Drug Shortages database page. |

#### Sample output row (synthetic example)

```json
{
  "packageNdc": "99999-101-10",
  "genericName": "Examplemine Hydrochloride Injection",
  "brandName": "EXAMPLEMINE",
  "companyName": "Example Pharma Labs Inc.",
  "status": "Current",
  "availability": "Limited Availability",
  "therapeuticCategory": [
    "Anesthesia",
    "Critical Care"
  ],
  "dosageForm": "Injection",
  "presentation": "Examplemine Hydrochloride, Injection, 10 mg/mL, 10 mL Vial (NDC 99999-101-10)",
  "initialPostingDate": "2025-04-14",
  "updateDate": "2026-10-28",
  "updateType": "Reverified",
  "route": [
    "INTRAVENOUS"
  ],
  "rxOtc": "RX",
  "fdaShortageUrl": "https://www.accessdata.fda.gov/scripts/drugshortages/default.cfm"
}
```

***

### How pricing works

Pay per result. You only pay for rows returned.

***

### Data source and terms

- **Official Source:** U.S. Food and Drug Administration openFDA Drug Shortages API (`https://api.fda.gov/drug/shortages.json`).
- **Update Frequency:** Updated daily by FDA. Each run checks the API's `last_updated` stamp: if it is more than 14 days old, the run ends `PARTIAL:` and says the source data is stale.
- **Terms of Use:** openFDA data is U.S. government open data licensed under Creative Commons CC0 (`https://open.fda.gov/terms/` and `https://open.fda.gov/license/`). Manufacturer phone numbers and individual strings from the upstream `contact_info` field are excluded from the output.

***

### Troubleshooting (`PARTIAL:` status messages)

- If a run finishes with a status message starting with `PARTIAL:`, the Actor preserved and pushed all validated records collected before a paging cap, scan-time budget (`240s`), upstream HTTP retry exhaustion, or schema drift check was triggered.
- A `PARTIAL:` caused by a source problem (schema drift, source errors, stale or interrupted source) ends with: *"If this keeps happening, please open an issue on this actor's Issues tab and we'll fix it fast."* A `PARTIAL:` caused only by your own limits (maxItems, the charge cap, or the scan budget) does not carry that line.
- A run whose filters match nothing finishes successfully as `Complete: 0 rows matched your filters`, with the number of records scanned and a note on which filters to widen.
- Found a problem or need a field? Open an issue on the Issues tab; we respond quickly.

### Limits and FAQ

- **Do I need an openFDA API key?** No. The default keyless mode supports up to 240 requests per minute and 1,000 requests per day, and a full run of all FDA drug shortage records requires only 2 API requests. You can optionally supply your own key in `openFdaApiKey` (`isSecret: true`).
- **How are records deduplicated?** Records are deduplicated by `packageNdc + updateDate` (falling back to `genericName + companyName + presentation` if `packageNdc` is null).
- **Canary input:** the input below returns up to 5 rows in a few seconds and is the quickest way to confirm the Actor and the source are healthy.

```json
{
  "statuses": ["Current"],
  "genericNameQuery": "",
  "therapeuticCategories": [],
  "updatedSince": "",
  "openFdaApiKey": "",
  "maxItems": 5
}
```

- **Paging limit:** openFDA caps the `skip` parameter at 25,000 records (beyond that, `search_after` paging would be needed). This endpoint holds roughly 1,600 records in total, and the Actor pages at most 10,000 records (largest `skip` used: 9,000), so a run never approaches the cap.

***

### Changelog

- **v0.1.2 (2026-10-31):** Red Team fix round: the core-column sentinel no longer treats `availability` as a core field (openFDA publishes it only for `Current` records; `Resolved` and `To Be Discontinued` runs previously failed with a false schema-drift claim and now complete with `availability` null, as disclosed in the output table); per-row validation now checks the raw source values, so an unparseable date or an out-of-enum status counts as a bad row instead of being normalized into a silent null; source freshness is measured on every run (a `meta.last_updated` older than 14 days ends the run `PARTIAL:` with a staleness reason); Retry-After is honored in HTTP-date form as well as seconds; the optional API key input no longer carries a schema default.
- **v0.1.1 (2026-10-31):** Fix round: added a core-column sentinel that fails loudly on renamed source fields; zero matches now finish as `Complete: 0` instead of failing; the Issues line now appears only on source-caused `PARTIAL:` messages and the charge-cap message now starts with `PARTIAL:`; status messages state rows pushed, total matches, and records scanned; the verbatim openFDA disclaimer is now quoted in full; `updatedSince` compares against `updateDate` only; added `defaultRunOptions` (max charge $50) and a matching example run input.
- **v0.1 (2026-10-31):** Initial release querying `https://api.fda.gov/drug/shortages.json` with ISO date normalization, schema validation, and pay-per-event spending limit protection.

# Actor input Schema

## `genericNameQuery` (type: `string`):

Optional case-insensitive substring or keyword to match against genericName, brandName, or presentation (e.g. "Injection", "Sodium", "Lidocaine"). Leave blank for all drugs.

## `maxItems` (type: `integer`):

Maximum number of shortage records to return, sorted newest first by updateDate.

## `openFdaApiKey` (type: `string`):

Optional user-supplied openFDA API key for higher rate limits. Leave blank to use keyless public access.

## `statuses` (type: `array`):

Filter by FDA drug shortage status values: Current, Resolved, or To Be Discontinued. Leave empty to include all statuses.

## `therapeuticCategories` (type: `array`):

Optional therapeutic category filter values (e.g. \["Cardiovascular", "Oncology", "Anesthesia", "Pediatric"]). Leave empty for all categories.

## `updatedSince` (type: `string`):

Optional earliest updateDate in YYYY-MM-DD format (e.g. "2026-01-01"). Leave blank for all dates.

## Actor input object example

```json
{
  "genericNameQuery": "",
  "maxItems": 200,
  "statuses": [
    "Current"
  ],
  "therapeuticCategories": [],
  "updatedSince": ""
}
```

# 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 = {
    "genericNameQuery": "",
    "maxItems": 200,
    "statuses": [
        "Current"
    ],
    "therapeuticCategories": [],
    "updatedSince": ""
};

// Run the Actor and wait for it to finish
const run = await client.actor("groundplanes/openfda-drug-shortages").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 = {
    "genericNameQuery": "",
    "maxItems": 200,
    "statuses": ["Current"],
    "therapeuticCategories": [],
    "updatedSince": "",
}

# Run the Actor and wait for it to finish
run = client.actor("groundplanes/openfda-drug-shortages").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 '{
  "genericNameQuery": "",
  "maxItems": 200,
  "statuses": [
    "Current"
  ],
  "therapeuticCategories": [],
  "updatedSince": ""
}' |
apify call groundplanes/openfda-drug-shortages --silent --output-dataset

```

## MCP server setup

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

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/Qt4N1RGrf9KaslhRg/builds/y0K7aIw4fB6Ukl4bo/openapi.json
