# Drug Shortage Monitor — openFDA Availability & Duration (`alaudinburki/drug-shortage-monitor`) Actor

Monitor US drug shortages from openFDA: product, firm, status, availability, dosage form and how long it has been in shortage. Keyless, one row per shortage episode.

- **URL**: https://apify.com/alaudinburki/drug-shortage-monitor.md
- **Developed by:** [alaudin burki](https://apify.com/alaudinburki) (community)
- **Stats:** 2 total users, 1 monthly users, 0.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

## Drug Shortage Monitor — openFDA Availability & Duration

Monitor US drug shortages from **openFDA**: product, firm, status, availability, dosage form and **how
long the shortage has lasted**. Keyless, public, one row per shortage episode.

### What you get

| Field | Example |
|---|---|
| `genericName` | Clindamycin Phosphate Injection |
| `companyName` | Pfizer Inc. |
| `status` | Current · To Be Discontinued · Resolved |
| `availability` | Available · Limited Availability · Unavailable · **Not stated** |
| `daysInShortage` | 1,308 |
| `updatedAt` | 2026-10-16 |

### Two things this Actor refuses to do

**1. Invent an availability.** In a live page of 1,000 records, **29 carried no availability value at
all**. Reporting those as "Available" would be a confident wrong answer about medicine, so a missing
value becomes **`Not stated`** — a distinct value, not a default.

**2. Read `MM/DD/YYYY` by luck.** openFDA publishes US-format dates. `new Date("02/22/2012")` parses as
February 22nd in a US locale and as an invalid date in most others, so the parse is explicit and tested
against a leap day and a rollover: `02/30` is rejected rather than silently becoming March 1st.

### A shortage can happen twice

The same product, package and firm can appear more than once — a shortage that resolved and later
recurred. A live page of 1,000 records contained **7 such pairs**. The row id therefore includes the
**posting date**, so the second episode is a second row. Without it, the second episode was deduplicated
away and the run silently lost real records; a unit test now asserts the two stay distinct.

### Use cases

- **Pharmacy and hospital supply teams** — a daily list of what is unavailable or limited right now.
- **Healthcare compliance** — evidence of shortages for substitution policies and audit trails.
- **Pharma competitive intelligence** — which firms have products in shortage, and for how long.
- **Journalists and analysts** — `daysInShortage` turns a list into a story.

### Limits

- **openFDA is unvalidated.** Its own disclaimer is carried into every run summary: do not use this data
  to make decisions about medical care.
- **US only.** This is the FDA's shortage list; other regulators publish separately.
- `daysInShortage` is measured from the posting date, which is when the shortage was *recorded*, not
  necessarily when supply first tightened.
- A resolved shortage stays in the dataset; uncheck **Include resolved** to see only live ones.

### Verified

**36 unit tests** on the reader — both date traps, the missing-availability rule, the recurring-episode
id, and search-expression escaping — plus **14 live checks** against the real API: 1,000 records parsed,
every row flat, every id unique, and a search that matches nothing returning an empty page rather than
an error.

***

One row per shortage episode, flat, ready for a scheduled run or a spreadsheet.

# Actor input Schema

## `query` (type: `string`):

A generic name to search for, such as insulin. Leave blank to fetch every shortage on record.

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

Filter by openFDA status.

## `includeResolved` (type: `boolean`):

Resolved shortages are historical. Uncheck to see only live ones.

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

Hard limit. A run that stops early says so.

## `timeoutSecs` (type: `integer`):

Per page.

## Actor input object example

```json
{
  "query": "lidocaine",
  "status": "any",
  "includeResolved": true,
  "maxItems": 2000,
  "timeoutSecs": 30
}
```

# Actor output Schema

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

One row per shortage episode, with the 20 fields listed under Views.

# 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 = {
    "query": "lidocaine",
    "status": "any",
    "includeResolved": true,
    "maxItems": 2000
};

// Run the Actor and wait for it to finish
const run = await client.actor("alaudinburki/drug-shortage-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 = {
    "query": "lidocaine",
    "status": "any",
    "includeResolved": True,
    "maxItems": 2000,
}

# Run the Actor and wait for it to finish
run = client.actor("alaudinburki/drug-shortage-monitor").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 '{
  "query": "lidocaine",
  "status": "any",
  "includeResolved": true,
  "maxItems": 2000
}' |
apify call alaudinburki/drug-shortage-monitor --silent --output-dataset

```

## MCP server setup

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

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/xbzgZ4gI3kaFtLcOg/builds/Qps73lfV6af7RqFgW/openapi.json
