# DailyMed Drug Label Scraper - NIH Drug Data (`lulzasaur/dailymed-scraper`) Actor

Scrape DailyMed drug labels from the NIH. Search by drug name. Extract ingredients, dosage forms, NDC codes, labelers, and full pharmaceutical data.

- **URL**: https://apify.com/lulzasaur/dailymed-scraper.md
- **Developed by:** [lulz bot](https://apify.com/lulzasaur) (community)
- **Categories:** E-commerce
- **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/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

## DailyMed Drug Label Scraper

Scrape drug label data from [DailyMed](https://dailymed.nlm.nih.gov/dailymed/), the NIH's official source for FDA-approved drug labeling. Search by drug name or fetch specific labels by set ID.

### Features

- **Search mode**: Search drug labels by name using the DailyMed API
- **Label mode**: Fetch specific drug labels by set ID
- **Rich data extraction**: Active ingredients, dosage form, route, NDC codes
- **Paginated search**: Automatically follows API pagination for large result sets
- **NIH API + HTML parsing**: Combines JSON API search with HTML detail page parsing

### Input

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `mode` | string | `"search"` | `"search"` to find drugs by name, `"label"` for specific set IDs. |
| `searchQueries` | string\[] | `[]` | Drug names to search for (e.g. `["ibuprofen", "aspirin"]`). |
| `setIds` | string\[] | `[]` | DailyMed SPL set IDs for direct label fetch. |
| `limit` | integer | `50` | Maximum number of labels to return per search query. |
| `proxyConfiguration` | object | - | Optional proxy settings. |

### Output

Each result includes:

| Field | Description |
|-------|-------------|
| `setId` | DailyMed SPL set identifier (UUID) |
| `splVersion` | SPL version number |
| `title` | Full drug label title |
| `genericName` | Generic drug name |
| `brandName` | Brand/trade name |
| `labeler` | Manufacturer/labeler name |
| `activeIngredients` | Array of active ingredient names |
| `dosageForm` | Dosage form (tablet, capsule, solution, etc.) |
| `route` | Route of administration (oral, topical, etc.) |
| `marketingCategory` | Product type / marketing category |
| `ndcCodes` | Array of National Drug Code numbers |
| `publishDate` | Date the label was published |
| `effectiveDate` | Marketing start date |
| `sourceUrl` | Full URL to the DailyMed drug info page |
| `scrapedAt` | ISO timestamp of when the data was scraped |

### Usage Examples

#### Search by drug name

```json
{
    "mode": "search",
    "searchQueries": ["ibuprofen"],
    "limit": 20
}
```

#### Multiple drug search

```json
{
    "mode": "search",
    "searchQueries": ["aspirin", "acetaminophen", "metformin"],
    "limit": 10
}
```

#### Fetch specific labels

```json
{
    "mode": "label",
    "setIds": [
        "3a38add6-a114-4e18-836c-3bfc727db231",
        "07edcb31-d31d-4607-98c3-dcb1e062cc70"
    ]
}
```

### How It Works

1. **Search mode**: Queries the DailyMed REST API (`/services/v2/spls.json`) for SPLs matching the drug name. Automatically paginates through results up to the limit. Then visits each drug's HTML detail page to extract rich structured data.

2. **Label mode**: Directly fetches the drug info HTML page for each set ID and parses the product information tables.

3. **Data extraction**: Parses DailyMed's structured HTML tables including Product Information, Active Ingredients, Product Characteristics, and Marketing Information sections.

### Notes

- DailyMed is maintained by the NIH National Library of Medicine
- Data comes from FDA-approved drug labeling (package inserts)
- Set IDs are UUIDs that uniquely identify each drug label
- NDC (National Drug Code) is the universal product identifier for drugs in the US
- The API is free and requires no authentication
- Rate limited to 20 requests/minute to be respectful to NIH servers

# Actor input Schema

## `mode` (type: `string`):

Mode: 'search' to search drug labels by name, 'label' to fetch specific labels by set ID.

## `searchQueries` (type: `array`):

Drug names to search for (e.g. \["ibuprofen", "aspirin"]). Used in 'search' mode.

## `setIds` (type: `array`):

DailyMed SPL set IDs to fetch directly (e.g. \["3a38add6-a114-4e18-836c-3bfc727db231"]). Used in 'label' mode.

## `limit` (type: `integer`):

Maximum number of drug labels to return per search query.

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

Optional proxy configuration for requests.

## Actor input object example

```json
{
  "mode": "search",
  "searchQueries": [
    "ibuprofen"
  ],
  "limit": 50
}
```

# 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 = {
    "searchQueries": [
        "ibuprofen"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("lulzasaur/dailymed-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 = { "searchQueries": ["ibuprofen"] }

# Run the Actor and wait for it to finish
run = client.actor("lulzasaur/dailymed-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 '{
  "searchQueries": [
    "ibuprofen"
  ]
}' |
apify call lulzasaur/dailymed-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,lulzasaur/dailymed-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/7bdfmlRi2pAQYMfxn/builds/qF2Diseq6DW3KGwax/openapi.json
