{
  "openapi": "3.1.0",
  "info": {
    "title": "Neap",
    "version": "0.1.0",
    "description": "One versioned view of medicine shortages across EU registers, joined by ATC, sources on each record."
  },
  "servers": [],
  "security": [
    {
      "bearer": []
    },
    {}
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "paths": {
    "/v1/tools/find_medicine": {
      "post": {
        "operationId": "find_medicine",
        "summary": "Find a medicine by name",
        "description": "Finds medicines by product or substance name and returns each register's own codes: the national code for shortages_by_national_code and the ATC code for shortages_by_atc and cross_country_summary. It searches only the names each served register publishes, in that register's language: EMA in English, Spain in Spanish, France in French, Italy in Italian, Czechia product names only. It is not the WHO ATC index and knows no synonyms or translations, so try the brand and each country's spelling. Matching ignores case and accents, needs every word, and a long word may drop its last letter. ATC comes from the register or Neap's tested matching, with atcBasis saying which. No match does not mean no shortage: search by ATC code to reach registers that spell the name differently.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "additionalProperties": false,
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 80,
                    "description": "A product or substance name as a register might print it, for example ozempic, semaglutide or metotrexato."
                  },
                  "countries": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 2,
                      "maxLength": 2
                    },
                    "maxItems": 8,
                    "description": "ISO country codes, or EU for the EMA catalogue. Served: EU, CZ, ES, FR, IT. Defaults to every served source."
                  },
                  "statuses": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "shortage",
                        "supply_tension",
                        "announced",
                        "resolved",
                        "discontinued"
                      ]
                    },
                    "description": "Defaults to every status, so resolved and discontinued records are found too."
                  },
                  "as_of": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "Read the data version on or before this date instead of the latest. A pinned read reports source health as it was then."
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100,
                    "description": "Default 25."
                  },
                  "offset": {
                    "type": "integer",
                    "minimum": 0
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "dataVersion",
                    "sources",
                    "attribution",
                    "warnings",
                    "complete"
                  ],
                  "properties": {
                    "dataVersion": {
                      "type": "string"
                    },
                    "sources": {
                      "type": "array"
                    },
                    "attribution": {
                      "type": "array"
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "complete": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/shortages_by_atc": {
      "post": {
        "operationId": "shortages_by_atc",
        "summary": "Shortages by ATC code",
        "description": "Lists shortage records for an ATC code across EU registers, in one record shape. Call it to see which products a register reports short for a substance or class. For a per-country count, call cross_country_summary; for one product, shortages_by_national_code; to get a code from a name, find_medicine. Each record carries its source status text, start and expected end, sourceListDate for the list as a whole, source URL and content hash. Defaults to shortage, supply_tension and announced, where announced starts after the snapshot; counts gives shortNow and announced apart. Check substancesUnderCode; a code with no records gets nearCodes, never their answer. Strength and form are not normalised. Records with no ATC code are counted in notJoinable, and absence from a register does not mean a product is available.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "atc"
                ],
                "additionalProperties": false,
                "properties": {
                  "atc": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 40,
                    "description": "ATC code at any level, for example N, J01, J01C or J01CA04. Matches by prefix, so N covers every nervous system record. To get a code from a medicine name, call find_medicine first."
                  },
                  "countries": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 2,
                      "maxLength": 2
                    },
                    "maxItems": 8,
                    "description": "ISO country codes, or EU for the EMA catalogue. Served: EU, CZ, ES, FR, IT. Defaults to every served source."
                  },
                  "statuses": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "shortage",
                        "supply_tension",
                        "announced",
                        "resolved",
                        "discontinued"
                      ]
                    },
                    "description": "Defaults to shortage, supply_tension and announced."
                  },
                  "as_of": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "Read the data version on or before this date instead of the latest. A pinned read reports source health as it was then."
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100,
                    "description": "Default 25."
                  },
                  "offset": {
                    "type": "integer",
                    "minimum": 0
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "dataVersion",
                    "sources",
                    "attribution",
                    "warnings",
                    "complete"
                  ],
                  "properties": {
                    "dataVersion": {
                      "type": "string"
                    },
                    "sources": {
                      "type": "array"
                    },
                    "attribution": {
                      "type": "array"
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "complete": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/shortages_by_national_code": {
      "post": {
        "operationId": "shortages_by_national_code",
        "summary": "Shortage record for a national product code",
        "description": "Looks up one product by its national code in one country: Czech KOD_SUKL, Spanish Codigo Nacional, Italian AIC (nine digits for a pack; six digits also returns every pack of that medicine), the ANSM listing id for France, or the EMA shortage page slug with country EU. Call it when you hold the code for a specific pack. For a substance across countries, call shortages_by_atc. For Czechia it also returns the product's dated notices. found false means the register lists nothing for that code, not that the product is available. Germany, Hungary and Slovenia return source_not_served, Finland and Ireland source_excluded.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "country",
                  "code"
                ],
                "additionalProperties": false,
                "properties": {
                  "country": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 2,
                    "description": "ISO country code, or EU for the EMA catalogue."
                  },
                  "code": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "minLength": 1,
                    "maxLength": 120,
                    "description": "The code as printed on the pack or in the register. Leading zeros may be left out."
                  },
                  "as_of": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "Read the data version on or before this date instead of the latest. A pinned read reports source health as it was then."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "dataVersion",
                    "sources",
                    "attribution",
                    "warnings",
                    "complete"
                  ],
                  "properties": {
                    "dataVersion": {
                      "type": "string"
                    },
                    "sources": {
                      "type": "array"
                    },
                    "attribution": {
                      "type": "array"
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "complete": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/cross_country_summary": {
      "post": {
        "operationId": "cross_country_summary",
        "summary": "Cross-country summary for an ATC code",
        "description": "Compares one ATC code across every served register: active records per country, split into shortNow and announced (start date after the snapshot), status breakdown, earliest start, latest update, how many are past their expected end, and how many have none. Call it to see whether a shortage is local or spreading. For the records themselves, call shortages_by_atc; for movement over time, call history_for. Counts are records as each register defines them (packs in Spain and Czechia, products elsewhere), so they compare presence, not volume. Countries with no active record are listed separately from countries Neap does not cover.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "atc"
                ],
                "additionalProperties": false,
                "properties": {
                  "atc": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 40,
                    "description": "ATC code at any level, for example N, J01, J01C or J01CA04. Matches by prefix, so N covers every nervous system record. To get a code from a medicine name, call find_medicine first."
                  },
                  "as_of": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "Read the data version on or before this date instead of the latest. A pinned read reports source health as it was then."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "dataVersion",
                    "sources",
                    "attribution",
                    "warnings",
                    "complete"
                  ],
                  "properties": {
                    "dataVersion": {
                      "type": "string"
                    },
                    "sources": {
                      "type": "array"
                    },
                    "attribution": {
                      "type": "array"
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "complete": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/changes_since": {
      "post": {
        "operationId": "changes_since",
        "summary": "Changes since a cursor",
        "description": "Returns what moved in the registers since a cursor: rows listed or delisted, status changes, date changes and ATC changes, and Czech products leaving the current view (left_current_view), oldest first. Call it on a schedule and store nextCursor. Pass c0 to start from the beginning, or a date as YYYY-MM-DD. Do not use it for the current state of a substance: call shortages_by_atc. delisted means a row left the register, which is not the same as resolved. Changes exist only from the first snapshot on, apart from recent dated Czech notices.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "cursor": {
                    "type": "string",
                    "maxLength": 12,
                    "description": "nextCursor from the last call, c0, or YYYY-MM-DD. Defaults to c0."
                  },
                  "countries": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 2,
                      "maxLength": 2
                    },
                    "maxItems": 8,
                    "description": "ISO country codes, or EU for the EMA catalogue. Served: EU, CZ, ES, FR, IT. Defaults to every served source."
                  },
                  "atc": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 40,
                    "description": "Only changes for this ATC prefix."
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 200,
                    "description": "Default 100, at most 200. Page on with nextCursor."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "dataVersion",
                    "sources",
                    "attribution",
                    "warnings",
                    "complete"
                  ],
                  "properties": {
                    "dataVersion": {
                      "type": "string"
                    },
                    "sources": {
                      "type": "array"
                    },
                    "attribution": {
                      "type": "array"
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "complete": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/source_status": {
      "post": {
        "operationId": "source_status",
        "summary": "Health of each source register",
        "description": "Reports each register's state (ok, stale, drift, error, robots_blocked or never_fetched), last attempt, last success, source row count, served record count and content hash, plus which countries are held back or excluded and why. Call it before relying on a result that names a warning, or to decide whether a register can be trusted today. A register that changes format shows state drift and keeps its last good data until a person repairs the parser. It reports on the data, not on medicine supply.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "source": {
                    "type": "string",
                    "maxLength": 12,
                    "description": "One source id, such as ema, sukl, cima, ansm or aifa, or its country code, such as CZ. Defaults to all."
                  },
                  "as_of": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "Read the data version on or before this date instead of the latest. A pinned read reports source health as it was then."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "dataVersion",
                    "sources"
                  ],
                  "properties": {
                    "dataVersion": {
                      "type": "string"
                    },
                    "sources": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/history_for": {
      "post": {
        "operationId": "history_for",
        "summary": "History of shortages for an ATC code",
        "description": "Shows how shortages for an ATC code moved over time. Czechia comes from SUKL's dated notices, reaching back to 2008; other countries publish the present only, so their series is Neap's own daily snapshots and starts on the first snapshot. Call it to see whether a shortage is new, recurring or easing. Defaults to the three years up to to, or up to the data version, by month; pass from to go further back. For today's records, call shortages_by_atc. Czech figures are products with an open interruption notice, and a notice nobody closed still counts as open.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "atc"
                ],
                "additionalProperties": false,
                "properties": {
                  "atc": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 40,
                    "description": "ATC code at any level, for example N, J01, J01C or J01CA04. Matches by prefix, so N covers every nervous system record. To get a code from a medicine name, call find_medicine first."
                  },
                  "from": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                  },
                  "to": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                  },
                  "by": {
                    "type": "string",
                    "enum": [
                      "month",
                      "year"
                    ],
                    "description": "Default month."
                  },
                  "as_of": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "Read the data version on or before this date instead of the latest. A pinned read reports source health as it was then."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "dataVersion",
                    "sources",
                    "attribution",
                    "warnings",
                    "complete"
                  ],
                  "properties": {
                    "dataVersion": {
                      "type": "string"
                    },
                    "sources": {
                      "type": "array"
                    },
                    "attribution": {
                      "type": "array"
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "complete": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    }
  }
}
