# Spain Medicine Shortages Monitor (AEMPS CIMA) (`hispadata/spain-medicines-monitor`) Actor

Daily alerts from the official AEMPS medicines database (CIMA): new, changed and resolved supply problems (shortages), new and withdrawn medicines and safety notes. Active ingredient, ATC, lab and alternatives included. Filter by keyword, ATC or lab. Only new alerts.

- **URL**: https://apify.com/hispadata/spain-medicines-monitor.md
- **Developed by:** [HispaData](https://apify.com/hispadata) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 medicine alerts

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?

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

## Spain Medicine Shortages Monitor: desabastecimientos y novedades de medicamentos de la AEMPS (CIMA)

**Know the same day when a medicine you dispense, prescribe, sell or make goes short in Spain, comes back, or gets a new expected return date.**
Reads **CIMA**, the official medicines database of the **Agencia Española de Medicamentos y Productos Sanitarios (AEMPS)**, and returns clean alerts with the active ingredient, ATC code, laboratory and whether AEMPS says there is an alternative. With *Only new alerts* on, each scheduled run gives you only what changed since the last one.

[Leer en español](#en-español)

### What it watches

| Alert | What it means |
|---|---|
| **New supply problem** | AEMPS has registered a new supply problem (shortage) for a presentation (national code). |
| **New expected end date** | The expected end of an active supply problem was moved. You get the old and the new date. |
| **Supply problem resolved** | The presentation is no longer in the AEMPS list of supply problems. |
| **New medicine** | A new medicine (including parallel imports) was added to CIMA. |
| **Medicine withdrawn** | A medicine was removed from CIMA. |
| **Marketing status changed** | Optional: a medicine started or stopped being marketed. |
| **Safety note** | A new AEMPS safety note for professionals (pharmacovigilance). |

### Why this Actor

- **Alerts, not dumps.** The AEMPS list holds around 900 active supply problems. This Actor remembers what it already gave you for the same filters and returns only new, changed and resolved ones. You never pay twice for the same alert.
- **Ready to use.** Medicine and presentation name, national code (CN), registration number, active ingredients, ATC code and name, laboratory, prescription status, generic, start date, expected end date, the AEMPS observation, whether an alternative exists, and links to CIMA, the leaflet and the technical sheet.
- **"Is there an alternative?" in one field.** `alternativeAvailable` is `true` when AEMPS says another medicine with the same active ingredient exists, `false` when it says there is no equivalent (prescriber must change treatment, temporary shortage or foreign medicine), and empty when it depends.
- **Filters that matter.** Keywords, ATC prefixes (for example `J01` antibiotics, `A10` diabetes), laboratories, supply problem types, prescription only, and "only shortages without an alternative".
- **Official data, no login, no proxies.** Only the public CIMA REST service that AEMPS offers for reuse.

### Who uses it

- Community and hospital pharmacies that want to warn patients and doctors early.
- Pharmaceutical wholesalers, distributors and pharmacy software that need a feed of shortages.
- Laboratories and market access teams that follow their own products and their competitors'.
- Health apps, journalists and researchers.
- AI agents and automations (Make, Zapier, n8n, Slack, email, Google Sheets) through the Apify API.

### How to use it

1. Leave the default input to get every alert, or add **keywords**, **ATC codes** or **laboratories**.
2. Click **Start**. The first run returns the supply problems that started in the last 7 days (you can choose up to 31), plus new and withdrawn medicines and safety notes of that period.
3. Click **Schedule** and run it every day (for example at 09:00 and 18:00 Madrid time). Connect the dataset to email, Slack, Google Sheets or a webhook.

#### Input example

```json
{
  "alertTypes": ["shortage_started", "shortage_updated", "shortage_resolved"],
  "atcCodes": ["J01", "A10"],
  "onlyWithoutAlternative": false
}
```

#### Output example

```json
{
  "alertType": "shortage_started",
  "alertLabel": "New supply problem",
  "date": "2026-11-24",
  "nationalCode": "764522",
  "medicine": "AZITROMICINA PENSA 500 mg GRANULADO PARA SUSPENSION ORAL EFG, 3 sobres",
  "problemType": 5,
  "problemTypeLabel": "Other medicines with the same active ingredient and route are available",
  "alternativeAvailable": true,
  "shortageStart": "2026-11-24",
  "expectedEnd": "2027-01-31",
  "aempsNote": "Existe/n otro/s medicamento/s con el mismo principio activo y para la misma vía de administración.",
  "registrationNumber": "65749",
  "activeIngredients": ["AZITROMICINA DIHIDRATO"],
  "atcCode": "J01FA10",
  "atcName": "Azitromicina",
  "laboratory": "Towa Pharmaceutical S.A.",
  "requiresPrescription": true,
  "generic": true,
  "urlCima": "https://cima.aemps.es/cima/publico/detalle.html?nregistro=65749",
  "urlLeaflet": "https://cima.aemps.es/cima/pdfs/p/65749/P_65749.pdf"
}
```

### Pricing

You pay per alert delivered, plus a small fee per run. Alerts you already received are never delivered or charged again. A daily run with no filters usually returns between 10 and 30 alerts on working days and very few at weekends.

### Notes

- Dates are Madrid calendar days. "Resolved" means the presentation left the AEMPS list of supply problems; each one is checked again on its own before it is reported.
- The meaning of each supply problem type comes from the fixed text AEMPS publishes with it. Always read `aempsNote`, which is copied as published.
- This Actor is not affiliated with AEMPS. The data is public information from CIMA. It is not medical advice.

***

### En español

**Entérate el mismo día de los problemas de suministro (desabastecimientos) de medicamentos en España, de cuándo se resuelven y de los cambios de fecha prevista.**
Lee **CIMA**, la base de datos oficial de medicamentos de la **AEMPS**, y devuelve alertas limpias: nuevo problema de suministro, nueva fecha prevista de fin, problema resuelto, medicamentos nuevos y dados de baja, cambios de comercialización y notas de seguridad.

- **Solo lo nuevo:** con *Only new alerts* activado, cada ejecución programada trae solo lo que ha cambiado desde la anterior. No pagas dos veces la misma alerta.
- **Datos listos:** código nacional, principio activo, ATC, laboratorio, si necesita receta, fechas, observación de la AEMPS, si hay alternativa, y enlaces a CIMA, prospecto y ficha técnica.
- **Filtros:** palabras clave (por ejemplo `amoxicilina`, `insulina`), prefijos ATC (`J01`, `A10`), laboratorios, tipo de problema, solo con receta y solo sin alternativa.
- **Para quién:** farmacias, hospitales, distribuidores, software de farmacia, laboratorios, apps de salud y periodistas.
- **Datos oficiales:** solo el servicio público de CIMA de la AEMPS, sin login ni proxies. No es consejo médico.

# Actor input Schema

## `alertTypes` (type: `array`):

Kinds of alerts you want. Default: everything except marketing status changes.

## `keywords` (type: `array`):

Return only alerts that mention any of these words in the medicine name, active ingredient, ATC name, laboratory or AEMPS note. Accents and case do not matter. Example: amoxicilina, insulina, ozempic. Leave empty for all.

## `excludeKeywords` (type: `array`):

Skip alerts that mention any of these words.

## `atcCodes` (type: `array`):

Keep only medicines whose ATC code starts with one of these. Example: J01 (antibiotics), A10 (diabetes), N06A (antidepressants).

## `laboratories` (type: `array`):

Keep only medicines of these marketing authorisation holders or marketers (part of the name is enough). Example: Cinfa, Normon, Pfizer.

## `problemTypes` (type: `array`):

Keep only these AEMPS supply problem types. Leave empty for all.

## `onlyWithoutAlternative` (type: `boolean`):

Keep only supply problems where AEMPS says there is no equivalent medicine (types 3, 4 and 7).

## `prescriptionOnly` (type: `boolean`):

Skip medicines that do not need a prescription.

## `includeParallelImports` (type: `boolean`):

Parallel import registrations (number with IP) are included by default.

## `onlyNew` (type: `boolean`):

Remember what was already delivered for the same filters and return only new alerts. The first run returns what started in the last days (see below). Turn off to get every supply problem that started in that period again.

## `lookbackDays` (type: `integer`):

How many days back the first run looks (1 to 31). Later runs continue from the previous one.

## `fetchDetails` (type: `boolean`):

Add active ingredients, ATC, laboratory, prescription status and links to the leaflet and technical sheet (one extra request per alert).

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

Maximum alerts returned (and charged) per run.

## Actor input object example

```json
{
  "alertTypes": [
    "shortage_started",
    "shortage_updated",
    "shortage_resolved",
    "medicine_authorized",
    "medicine_withdrawn",
    "safety_note"
  ],
  "onlyWithoutAlternative": false,
  "prescriptionOnly": false,
  "includeParallelImports": true,
  "onlyNew": true,
  "lookbackDays": 7,
  "fetchDetails": true,
  "maxResults": 500
}
```

# Actor output Schema

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

All new alerts delivered in this run.

# 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("hispadata/spain-medicines-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 = {}

# Run the Actor and wait for it to finish
run = client.actor("hispadata/spain-medicines-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 '{}' |
apify call hispadata/spain-medicines-monitor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,hispadata/spain-medicines-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/GApKuoa0CsOc57f9p/builds/hnBU5tr5mzbC1H2Ps/openapi.json
