# Drug Shortage API — Delta Monitor & FDA Shortage Tracker (`malonestar/drug-shortage-delta-monitor`) Actor

Drug shortage API on the official openFDA feed: normalized shortage records, delta monitor mode that emits only NEW or status-CHANGED shortages (new/resolved/reappeared), and therapeutic-class + dosage-form rollups of current shortages. Keyless.

- **URL**: https://apify.com/malonestar/drug-shortage-delta-monitor.md
- **Developed by:** [Kyle Maloney](https://apify.com/malonestar) (community)
- **Categories:** Lead generation, Developer tools, Agents
- **Stats:** 2 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $6.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 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

## Drug Shortage API — Delta Monitor & FDA Shortage Tracker

A **drug shortage API** built on the official **openFDA drug-shortages** feed. It
normalizes every FDA shortage into a clean, snake_case record, and — the moat vs a
flat exporter — adds a **delta monitor** that emits only shortages that are **NEW
or whose status CHANGED** since your last run, plus **therapeutic-class and
dosage-form rollups** of current shortages.

### Who it's for
- **Hospital & health-system pharmacy** teams tracking active drug shortages.
- **Pharma supply-chain / procurement** watching a therapeutic class or a competitor.
- **340B, GPO & drug-distribution** analysts monitoring resolutions and reappearances.
- **AI agents** needing a chainable "FDA drug shortage" tool.

### What it does
Pages the openFDA `drug/shortages` feed, normalizes dates to `YYYY-MM-DD` and
array fields, and (optionally) runs in **delta mode**: keyed on a stable shortage
id, it tags each record `change_type` = `new` | `resolved` | `reappeared` |
`updated` | `unchanged`, and in monitor mode emits only the changed ones — a
recurring shortage-change alert. Turn on **includeRollup** for summary rows
counting current shortages per therapeutic category and per dosage form.

### Example input
```json
{
  "status": "Current",
  "therapeuticCategory": "",
  "sinceDate": "",
  "maxResults": 1000,
  "monitor": true,
  "includeRollup": true
}
````

### Output

**Detail rows** (`record_type: "shortage"`): `shortage_id`, `change_type` (delta
mode), `generic_name`, `proprietary_name`, `company_name`, `status`,
`availability`, `shortage_reason`, `resolved_note`, `related_info`,
`therapeutic_category[]`, `dosage_form`, `strength[]`, `presentation`,
`contact_info`, `update_type`, `initial_posting_date`, `update_date`,
`change_date`, `product_ndc`, `route[]`, `substance_name[]`, `rxcui[]`,
`source_system`.

**Rollup rows** (`record_type: "rollup"`): `rollup_dimension`
(`therapeutic_category` | `dosage_form`), `rollup_key`, `current_shortage_count`.

### Use as an MCP tool

Available to AI agents via `mcp.apify.com` as a "drug shortage monitor" tool —
status/category in, normalized shortage records (with delta tags) out. The
field-level output descriptions make it a clean, chainable tool.

### FAQ

**Where's the data from?** The official FDA openFDA `drug/shortages` API.
**Is it keyless?** Yes — openFDA is keyless, JSON, no anti-bot.
**Can I get only new/changed shortages?** Yes — `monitor: true` on a schedule
emits only new/resolved/reappeared/updated records.
**Can I count shortages by drug class?** Yes — `includeRollup: true`.
**How fresh is it?** openFDA refreshes the shortages dataset regularly; each run
reads the current feed.

### Source

FDA **openFDA drug/shortages API** (`api.fda.gov/drug/shortages.json`). Official,
keyless, no anti-bot. Not for medical decisions — see the openFDA disclaimer.

### Pricing (Pay Per Result)

Billed per record returned (detail + any rollup rows). Empty results cost nothing
beyond the tiny actor start.

# Actor input Schema

## `status` (type: `string`):

Which FDA shortage status to return: 'Current' (active shortages), 'Resolved' (recently resolved), or 'all' (both). Applied server-side as an openFDA search filter.

## `therapeuticCategory` (type: `string`):

Optional therapeutic-class filter applied server-side (openFDA therapeutic\_category), e.g. 'Oncology', 'Psychiatry', 'Analgesia/Addiction'. Leave empty for all categories.

## `sinceDate` (type: `string`):

Only return shortages whose update date (or initial posting date when no update) is on or after this date. Use for recurring monitoring windows. Empty = no lower bound.

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

Maximum number of shortage records to fetch and normalize before filtering. The full feed is ~1,700 records; openFDA is paged internally at 1000/request.

## `monitor` (type: `boolean`):

When scheduled, emit only shortages that are NEW or whose status CHANGED since the previous run — each tagged change\_type (new, resolved, reappeared, updated). Unchanged shortages are skipped. State is kept in the actor's key-value store keyed on a stable shortage id.

## `includeRollup` (type: `boolean`):

Also emit summary rows (record\_type='rollup') counting CURRENT shortages per therapeutic\_category and per dosage\_form, alongside the detail rows.

## Actor input object example

```json
{
  "status": "Current",
  "maxResults": 1000,
  "monitor": false,
  "includeRollup": false
}
```

# Actor output Schema

## `results` (type: `string`):

Normalized FDA drug-shortage records in the default dataset.

# 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 = {
    "status": "Current"
};

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

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

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=malonestar/drug-shortage-delta-monitor",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Drug Shortage API — Delta Monitor & FDA Shortage Tracker",
        "description": "Drug shortage API on the official openFDA feed: normalized shortage records, delta monitor mode that emits only NEW or status-CHANGED shortages (new/resolved/reappeared), and therapeutic-class + dosage-form rollups of current shortages. Keyless.",
        "version": "1.0",
        "x-build-id": "7ar8XRWZmaOO5jLfc"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/malonestar~drug-shortage-delta-monitor/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-malonestar-drug-shortage-delta-monitor",
                "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/malonestar~drug-shortage-delta-monitor/runs": {
            "post": {
                "operationId": "runs-sync-malonestar-drug-shortage-delta-monitor",
                "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/malonestar~drug-shortage-delta-monitor/run-sync": {
            "post": {
                "operationId": "run-sync-malonestar-drug-shortage-delta-monitor",
                "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": {
                    "status": {
                        "title": "Shortage status",
                        "enum": [
                            "all",
                            "Current",
                            "Resolved"
                        ],
                        "type": "string",
                        "description": "Which FDA shortage status to return: 'Current' (active shortages), 'Resolved' (recently resolved), or 'all' (both). Applied server-side as an openFDA search filter.",
                        "default": "Current"
                    },
                    "therapeuticCategory": {
                        "title": "Therapeutic category",
                        "type": "string",
                        "description": "Optional therapeutic-class filter applied server-side (openFDA therapeutic_category), e.g. 'Oncology', 'Psychiatry', 'Analgesia/Addiction'. Leave empty for all categories."
                    },
                    "sinceDate": {
                        "title": "Updated since (YYYY-MM-DD)",
                        "type": "string",
                        "description": "Only return shortages whose update date (or initial posting date when no update) is on or after this date. Use for recurring monitoring windows. Empty = no lower bound."
                    },
                    "maxResults": {
                        "title": "Max results",
                        "minimum": 1,
                        "maximum": 100000,
                        "type": "integer",
                        "description": "Maximum number of shortage records to fetch and normalize before filtering. The full feed is ~1,700 records; openFDA is paged internally at 1000/request.",
                        "default": 1000
                    },
                    "monitor": {
                        "title": "Delta mode (only new / changed since last run)",
                        "type": "boolean",
                        "description": "When scheduled, emit only shortages that are NEW or whose status CHANGED since the previous run — each tagged change_type (new, resolved, reappeared, updated). Unchanged shortages are skipped. State is kept in the actor's key-value store keyed on a stable shortage id.",
                        "default": false
                    },
                    "includeRollup": {
                        "title": "Include therapeutic-class / dosage-form rollup",
                        "type": "boolean",
                        "description": "Also emit summary rows (record_type='rollup') counting CURRENT shortages per therapeutic_category and per dosage_form, alongside the detail rows.",
                        "default": false
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
