# Drug Shortage & Discontinuation Monitor (FDA) (`sashaebashu/fda-drug-shortage`) Actor

Track US drug shortages and permanent discontinuations from the FDA's own database — by drug, therapeutic category or manufacturer — with alerts when a product becomes unavailable or is discontinued.

- **URL**: https://apify.com/sashaebashu/fda-drug-shortage.md
- **Developed by:** [Sasha Ebashu](https://apify.com/sashaebashu) (community)
- **Categories:** Business, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $10.00 / 1,000 results

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

## Drug Shortage & Discontinuation Monitor (FDA)

Tracks **US drug shortages** from the FDA's own database and tells you what changed since the last
run — including the event that matters most to a buyer: a product being **discontinued for good**
rather than merely out of stock.

Built on the FDA's public API. No key, no login, no scraping.

### What you get

One row per FDA shortage record:

| Field | What it is |
|---|---|
| `genericName` / `brandNames` / `substanceName` | The drug, as FDA names it plus the brand names it ships under |
| `company` / `contact` | Who reported the shortage, and the phone number FDA publishes for them |
| `status` | `Current`, `To Be Discontinued`, `Resolved` |
| **`isDiscontinuing`** | The product is going away permanently — plan around it, don't wait it out |
| `availability` | `Available`, `Limited Availability`, `Unavailable` — normalised (see limits) |
| `therapeuticCategory` | Anesthesia, Pediatric, Psychiatry, Oncology… |
| `dosageForm` / `presentation` / `packageNdc` / `productNdcs` | Exactly which pack is affected |
| `route` / `pharmClass` / `rxcui` / `applicationNumbers` | Clinical and regulatory identifiers for joining to your own data |
| `firstPostedAt` / `updatedAt` / **`daysInShortage`** | How long this has been going on |
| **`drugRecordsInShortage`** / **`drugCompaniesAffected`** / **`drugUnavailableCount`** | Per-drug context across the whole database — is one supplier struggling, or the entire market? |

### Monitor mode

Run it on a schedule and every record is labelled against the previous run:

| `changeType` | Means |
|---|---|
| **`to_be_discontinued`** | The product is being withdrawn permanently — the highest-priority event |
| **`became_unavailable`** | Supply has stopped |
| `resolved` | The shortage is over |
| `availability_change` | Supply level moved (e.g. Available → Limited) |
| `status_change` | Any other status move |
| `new_shortage` | First time seen in this scope |
| `unchanged` | Nothing moved |

The order is deliberate: it is what a pharmacy or procurement team has to act on first, not the
order the fields happen to sit in. Turn on **Output only changed records** for a pure alert feed.

### Input

| Field | What it does |
|---|---|
| **Drugs to watch** | Generic names, matched as substrings — `lisdexamfetamine` finds *Lisdexamfetamine Dimesylate Capsules*. Empty = every drug. |
| **Therapeutic categories** | FDA's own categories. |
| **Companies** | The reporting manufacturer, substring match. |
| **Statuses** | Defaults to `Current` + `To Be Discontinued`; add `Resolved` for history. |
| **Only fully unavailable** | Drop partial and limited supply, keep the hard stops. |
| **Monitor mode / Output only changed** | The alert behaviour above. |

### Notes & limits

Properties of the source, measured rather than assumed:

- **One drug is many records.** FDA files a row per company *and* presentation — Lisdexamfetamine
  currently spans 90 records across 13 companies, Ropivacaine 49. Rows are kept faithful to the
  source, and the per-drug rollup fields give you the aggregate without losing the detail.
- **The FDA data contains a typo, and it is handled.** `availability` holds both `Unavailable` and
  the misspelled `Unvailable`. Filtering on the correct spelling silently drops the affected record,
  so availability is normalised — `availabilityRaw` keeps the original text so nothing is hidden.
- **The whole database is downloaded every run** (~1,700 records, two requests — openFDA caps
  `limit` at 1000 and rejects 1001). Filters are applied locally on purpose: a server-side filter
  could hide a record that later reappears and would then read as "new". It also keeps the per-drug
  rollups true to the entire database rather than to your slice.
- **`Resolved` is rare** — 25 records against 1,177 `Current` and 450 `To Be Discontinued`. FDA
  removes resolved entries rather than archiving them, so this is not a shortage history.
- **Dates are the FDA's own posting dates**, in MM/DD/YYYY, converted to ISO in the output.
- The Actor honours your **Maximum cost per run** and stops when the cap is reached.

# Actor input Schema

## `drugs` (type: `array`):

Generic names, matched as substrings of the FDA name — "lisdexamfetamine" finds "Lisdexamfetamine Dimesylate Capsules". Leave empty for every drug.

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

FDA's own categories, e.g. Anesthesia, Pediatric, Psychiatry, Neurology, Cardiovascular, Oncology.

## `companies` (type: `array`):

Filter by the reporting manufacturer, matched as a substring.

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

Which FDA statuses to include. "To Be Discontinued" means the product is going away permanently — usually the one worth planning around.

## `onlyUnavailable` (type: `boolean`):

Keep just the records where nothing is shippable, ignoring partial and limited supply.

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

Overall cap on rows. 0 = no cap. The whole database is currently about 1,700 records.

## `monitorMode` (type: `boolean`):

Compare against the previous run over the same filters and label every record: to\_be\_discontinued, became\_unavailable, resolved, availability\_change, status\_change, new\_shortage, unchanged.

## `onlyChanges` (type: `boolean`):

Monitor mode only — return just what moved, as an alert feed.

## Actor input object example

```json
{
  "drugs": [
    "lisdexamfetamine",
    "amphetamine"
  ],
  "therapeuticCategories": [
    "Pediatric"
  ],
  "companies": [
    "Pfizer"
  ],
  "statuses": [
    "Current",
    "To Be Discontinued"
  ],
  "onlyUnavailable": false,
  "maxItems": 0,
  "monitorMode": false,
  "onlyChanges": false
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

## `alerts` (type: `string`):

No description

## `full` (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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("sashaebashu/fda-drug-shortage").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 = {}

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

```

## MCP server setup

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

```

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/0O1A33EFjMkJCPLsS/builds/qhi7o417QDes9toJf/openapi.json
