{
  "openapi": "3.1.0",
  "info": {
    "title": "Quernmark",
    "version": "0.1.0",
    "description": "Whether a feed additive may be used on a date in the EU and in England, Scotland and Wales, from the official registers and the acts they cite."
  },
  "servers": [],
  "security": [
    {
      "bearer": []
    },
    {}
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "paths": {
    "/v1/tools/additive_status": {
      "post": {
        "operationId": "additive_status",
        "summary": "Feed additive status on a date",
        "description": "Says whether a feed additive may be used on a date, in the EU and in England, Scotland and Wales, optionally for one species: one verdict per market with status, usable (true, false, conditional or unknown), until and why, plus the register entries behind it with their acts and links. It applies the rules the registers leave to the reader: past its printed expiry but renewal filed in time (authorised_pending_renewal), existing product under re-evaluation, being withdrawn with separate run-out dates for the additive, premixtures and feed (read from the act), GB transitional periods, revoked or not listed. Call it before using an additive in a recipe, approving a label, or answering whether a product is still allowed. Do not call it to search by part of a name (use find_additives) or to list what expires soon (use expiring). It cannot see an application still under assessment, a decision not yet published in the register, or national enforcement practice, and it is not legal advice.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "additive"
                ],
                "properties": {
                  "additive": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "The feed additive: its identification number (4b1820, E 324, 3a672a; spaces and case do not matter), an EU authorisation number (AUTH-FEED-11713), an EU register entry (POL-FEED-17370), a GB register entry (feedadd-1351), or its name (Bacillus velezensis DSM 15544). The identification number is the surest key."
                  },
                  "date": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "Date to check, YYYY-MM-DD. Defaults to today. A past or future date applies today's register to that date."
                  },
                  "species": {
                    "type": "string",
                    "maxLength": 80,
                    "description": "Optional animal, to check the authorisation covers it: for example laying hens, chickens for fattening, piglets, dairy cows, salmon, dogs, cats. Known terms: chickens_for_fattening, chickens_reared_for_laying, laying_hens, turkeys, ducks, geese, quail, piglets, pigs_for_fattening, sows, dairy_cows, cattle_for_fattening, calves, sheep, goats, horses, rabbits, salmonids, fish, shrimp, dogs, cats, ornamental_fish, ornamental_birds, mink. Other words are matched literally against the register text."
                  },
                  "market": {
                    "type": "string",
                    "maxLength": 60,
                    "description": "Where: EU, GB (England, Scotland and Wales), England, Scotland, Wales, or all. Comma-separated for several. Defaults to all. Northern Ireland follows EU rules: use EU."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/find_additives": {
      "post": {
        "operationId": "find_additives",
        "summary": "Find feed additives by name, holder or code",
        "description": "Searches both registers by name, part of a name, authorisation holder or identification number, and returns additives grouped by identification number, with their names, whether each is in the EU and GB register, and the id to pass to additive_status. Call it when you do not know the identification number, or a name is ambiguous. It does not say whether an additive may be used (use additive_status). Results are paged: 20 by default, next_cursor while has_more is true.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "query"
                ],
                "properties": {
                  "query": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 120,
                    "description": "Name or part of one (velezensis, selenium yeast, clove), a holder (DSM, Asahi), or an identification number or its start (4b18)."
                  },
                  "market": {
                    "type": "string",
                    "maxLength": 60,
                    "description": "Where: EU, GB (England, Scotland and Wales), England, Scotland, Wales, or all. Comma-separated for several. Defaults to all. Northern Ireland follows EU rules: use EU."
                  },
                  "group": {
                    "type": "string",
                    "maxLength": 20,
                    "description": "Optional functional group code from Annex I of Regulation (EC) No 1831/2003, such as 4b (gut flora stabilisers), 3b (trace elements), 2b (flavourings), 1k (silage additives) or 5 (coccidiostats)."
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 50,
                    "description": "Results per page, default 20."
                  },
                  "cursor": {
                    "type": "string",
                    "maxLength": 300,
                    "description": "next_cursor from the previous page."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/compare_eu_gb": {
      "post": {
        "operationId": "compare_eu_gb",
        "summary": "Compare EU and GB status of one additive",
        "description": "Puts the EU status of one feed additive next to its status in England, Scotland and Wales on a date, and lists where they differ: one market allows it and another does not, a transitional period that runs out in one and not the other, or the same identification number under a different name or strain. Call it for exports between the EU and Great Britain, or for a product sold in both. Do not call it when only one market matters (use additive_status with market). It compares register entries; it cannot judge whether a renamed strain is the same product in law.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "additive"
                ],
                "properties": {
                  "additive": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "The feed additive: its identification number (4b1820, E 324, 3a672a; spaces and case do not matter), an EU authorisation number (AUTH-FEED-11713), an EU register entry (POL-FEED-17370), a GB register entry (feedadd-1351), or its name (Bacillus velezensis DSM 15544). The identification number is the surest key."
                  },
                  "date": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "Date to check, YYYY-MM-DD. Defaults to today. A past or future date applies today's register to that date."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/expiring": {
      "post": {
        "operationId": "expiring",
        "summary": "Authorisations and run-out periods ending in a window",
        "description": "Lists what ends between from (default today) and before: printed EU expiry dates of live authorisations, with whether a renewal was filed in time and what the status becomes the day after; run-out dates of additives being withdrawn, separately for the additive, premixtures and feed, read from the act; GB transitional end dates and urgent authorisation expiries. Filter by market, functional group, holder (your own company), or renewal_filed false to see expiries nobody has applied to renew. Call it to plan reformulation or to watch your own authorisations. Paged: 25 by default, next_cursor while has_more is true. GB publishes no expiry dates, so GB lists only transitional and urgent dates.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "before"
                ],
                "properties": {
                  "before": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "End of the window, YYYY-MM-DD, for example 2027-12-31."
                  },
                  "from": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "Start of the window, YYYY-MM-DD. Defaults to today."
                  },
                  "market": {
                    "type": "string",
                    "maxLength": 60,
                    "description": "Where: EU, GB (England, Scotland and Wales), England, Scotland, Wales, or all. Comma-separated for several. Defaults to all. Northern Ireland follows EU rules: use EU."
                  },
                  "group": {
                    "type": "string",
                    "maxLength": 20,
                    "description": "Optional functional group code from Annex I of Regulation (EC) No 1831/2003, such as 4b (gut flora stabilisers), 3b (trace elements), 2b (flavourings), 1k (silage additives) or 5 (coccidiostats)."
                  },
                  "holder": {
                    "type": "string",
                    "maxLength": 80,
                    "description": "Only authorisations whose holder (or, in GB, whose name, which carries the holder) contains this, for example DSM, Asahi or Novus. For a supplier watching its own authorisations."
                  },
                  "renewal_filed": {
                    "type": "boolean",
                    "description": "Only EU expiries where a renewal application was (true) or was not (false) filed in time. Leaves out run-out and GB dates."
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100,
                    "description": "Items per page, default 25."
                  },
                  "cursor": {
                    "type": "string",
                    "maxLength": 300,
                    "description": "next_cursor from the previous page."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/changes_since": {
      "post": {
        "operationId": "changes_since",
        "summary": "Register changes since a date",
        "description": "Lists what changed in the EU and GB feed additive registers after a date, oldest first: new EU entries, deletions and printed expiry dates passed, GB status updates and transitional periods ended, and differences between our own daily snapshots of both registers, which neither register publishes. Call it once a day with the date of your last call, or page with next_cursor while has_more is true. Filter by market and kinds. It reports the register's recorded dates; a register can record a change some days after the act was published.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "since": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "Changes dated after this day, YYYY-MM-DD. Required unless cursor is given."
                  },
                  "cursor": {
                    "type": "string",
                    "maxLength": 300,
                    "description": "next_cursor from the previous page."
                  },
                  "market": {
                    "type": "string",
                    "maxLength": 60,
                    "description": "Where: EU, GB (England, Scotland and Wales), England, Scotland, Wales, or all. Comma-separated for several. Defaults to all. Northern Ireland follows EU rules: use EU."
                  },
                  "kinds": {
                    "type": [
                      "array",
                      "string"
                    ],
                    "maxItems": 8,
                    "maxLength": 200,
                    "items": {
                      "type": "string",
                      "enum": [
                        "eu_entered",
                        "eu_deleted",
                        "eu_expiry",
                        "gb_updated",
                        "gb_transitional_end",
                        "snapshot_added",
                        "snapshot_changed",
                        "snapshot_removed"
                      ]
                    },
                    "description": "Only these kinds, as a list or comma-separated: eu_entered, eu_deleted, eu_expiry, gb_updated, gb_transitional_end, snapshot_added, snapshot_changed, snapshot_removed."
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 200,
                    "description": "Changes per page, default 50."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    }
  }
}
