{
  "openapi": "3.1.0",
  "info": {
    "title": "Trivetto",
    "version": "0.1.0",
    "description": "Novel food and GRAS status of an ingredient in the EU, Great Britain and the US, on any date, with the act, register row or notice it rests on."
  },
  "servers": [],
  "security": [
    {
      "bearer": []
    },
    {}
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "paths": {
    "/v1/tools/crosswalk": {
      "post": {
        "operationId": "crosswalk",
        "summary": "Ingredient status in the EU, GB and US",
        "description": "Status of one food ingredient in three markets at once on a date: the EU Union list of novel foods, the FSA register for England, Scotland and Wales, and the FDA GRAS Notice Inventory. Returns per market a verdict (authorised, not_yet_listed, differs_by_nation, no_questions, pending, no_basis, ceased_to_evaluate, possible_match_only, not_found, unknown), the best matching entry with its citation, other entries that also match (other strains or forms), any data protection that makes it exclusive to one company and until when, and a one-paragraph summary to quote. Call it first when you have an ingredient name, a substance with its source organism, or a production strain (for example Akkermansia muciniphila, L-ergothioneine, 2'-fucosyllactose E. coli K-12). Do not call it to list everything that changed (use changes_since) or for full conditions of use (use get_entry with the id it returns). It matches by name, stated synonym and production strain; the three registers share no key, so a match is not proof of the same substance and specification. It cannot tell whether a food was on the market before 15 May 1997 (and so not novel in the EU), and a missing GRAS notice does not mean a substance is not allowed in the US.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "ingredient"
                ],
                "properties": {
                  "ingredient": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 200,
                    "description": "Ingredient name as you would search a register: substance, source organism or production strain, for example 'pasteurised Akkermansia muciniphila' or '2'-fucosyllactose E. coli K-12'. Also accepts an id: NOVEL-166, GRN 1270, eu:l-ergothioneine."
                  },
                  "date": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "Date to answer for, YYYY-MM-DD, from 2018-01-01. Defaults to today."
                  },
                  "markets": {
                    "type": [
                      "string",
                      "array"
                    ],
                    "maxLength": 20,
                    "maxItems": 3,
                    "items": {
                      "type": "string",
                      "enum": [
                        "EU",
                        "GB",
                        "UK",
                        "US"
                      ]
                    },
                    "description": "One market or a list: EU (Union list), GB (FSA register, England, Scotland and Wales; UK is read as GB) or US (FDA GRAS inventory). Defaults to all three."
                  }
                }
              }
            }
          }
        },
        "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_ingredient": {
      "post": {
        "operationId": "find_ingredient",
        "summary": "Find ingredient entries by name",
        "description": "Lists every entry in the EU Union list, the GB register and the GRAS inventory whose name matches a query, ranked, with each entry's id, how it matched (exact_name, contains_query, synonym, partial), production strains where stated and a one-line status. Call it when a name is ambiguous, when several forms or strains exist, or when crosswalk found only a possible match. Then pass an id to get_entry. Paginated, 10 per page by default; follow next_page. It does not return conditions of use (use get_entry) and it matches names only, not chemistry: a CAS number or a trade name the registers do not use will not match.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "query"
                ],
                "properties": {
                  "query": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 200,
                    "description": "Name, organism, strain or part of a name, for example 'fucosyllactose', 'Tenebrio molitor', 'CECT 30648'. Also accepts an id such as NOVEL-12 or GRN 1270."
                  },
                  "market": {
                    "type": [
                      "string",
                      "array"
                    ],
                    "maxLength": 20,
                    "maxItems": 3,
                    "items": {
                      "type": "string",
                      "enum": [
                        "EU",
                        "GB",
                        "UK",
                        "US"
                      ]
                    },
                    "description": "One market or a list: EU (Union list), GB (FSA register, England, Scotland and Wales; UK is read as GB) or US (FDA GRAS inventory). Defaults to all three."
                  },
                  "date": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "Date to answer for, YYYY-MM-DD, from 2018-01-01. Defaults to today."
                  },
                  "page": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 500,
                    "description": "Page number, from 1. Follow next_page while it is not null."
                  },
                  "per_page": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 25,
                    "description": "Results per page, 1 to 25, default 10."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/get_entry": {
      "post": {
        "operationId": "get_entry",
        "summary": "Full record of one entry",
        "description": "The full record behind one entry, by id: for an EU Union list entry the conditions of use (food category and maximum level), labelling, other requirements, data protection (applicant company and end date), a specification excerpt, when it was first listed and every amending act that touched it; for a GB register entry the same per nation with its status change date, legislation and specification link; for a GRAS notice the intended use, basis, notifier company, closure date and FDA's letter. Includes the status on a date and the entries in the other two markets that match it by name. Call it after crosswalk or find_ingredient when you need the conditions, the maximum level or the labelling wording. Ids look like eu:l-ergothioneine, gb:novel-166 (NOVEL-166 also works) and us:grn-1270 (GRN 1270 also works). Long lists of uses are cut at 40 with the total stated. It quotes the register; it does not interpret whether your product fits a food category.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "id"
                ],
                "properties": {
                  "id": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 120,
                    "description": "Entry id from crosswalk or find_ingredient, or NOVEL-<n>, GRN <n>."
                  },
                  "date": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "Date to answer for, YYYY-MM-DD, from 2018-01-01. Defaults to today."
                  }
                }
              }
            }
          }
        },
        "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": "Changes since a date",
        "description": "What changed after a date, newest first: EU amending acts by the date they apply, with what each did (authorisation, amendment, correction) and the entries it touched, plus any act EUR-Lex lists that the consolidated text does not yet contain; GB register status changes per nation; FDA GRAS closures with the letter type, and filings where the inventory dates them; and changes our own weekly comparison observed. Call it to poll for news on a schedule or to answer what was authorised in a period. Filter with market and kinds; paginate with next_page (25 per page by default). Do not call it for one ingredient's status (use crosswalk). The FSA register keeps only each entry's latest status change, so earlier GB changes are not listed.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "since"
                ],
                "properties": {
                  "since": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "Return changes dated after this day, YYYY-MM-DD, from 1998-01-01."
                  },
                  "until": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "Optional last day to include, YYYY-MM-DD."
                  },
                  "market": {
                    "type": [
                      "string",
                      "array"
                    ],
                    "maxLength": 20,
                    "maxItems": 3,
                    "items": {
                      "type": "string",
                      "enum": [
                        "EU",
                        "GB",
                        "UK",
                        "US"
                      ]
                    },
                    "description": "One market or a list: EU (Union list), GB (FSA register, England, Scotland and Wales; UK is read as GB) or US (FDA GRAS inventory). Defaults to all three."
                  },
                  "kinds": {
                    "type": [
                      "array",
                      "string"
                    ],
                    "maxItems": 6,
                    "maxLength": 200,
                    "items": {
                      "type": "string",
                      "enum": [
                        "eu_act",
                        "eu_act_not_yet_consolidated",
                        "gb_status",
                        "us_closed",
                        "us_filed",
                        "observed"
                      ]
                    },
                    "description": "Only these kinds, as a list or a comma-separated string: eu_act, eu_act_not_yet_consolidated, gb_status, us_closed, us_filed, observed."
                  },
                  "page": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 500,
                    "description": "Page number, from 1. Follow next_page while it is not null."
                  },
                  "per_page": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100,
                    "description": "Changes per page, 1 to 100, default 25."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    },
    "/v1/tools/data_protection_ending": {
      "post": {
        "operationId": "data_protection_ending",
        "summary": "Exclusive authorisations ending in a window",
        "description": "EU and GB novel food authorisations whose data protection ends between two dates, soonest first, with the applicant company that holds the exclusivity, the end date (stated in the entry, or computed from the GB register's five-year wording and marked as computed) and the citation. While data protection runs, only that applicant may place the novel food on the market; after it ends, any business may within the entry's conditions. Call it to find ingredients that open up to competitors, or to check a supplier's exclusivity. Entries that state data protection without an end date are counted and listed separately. Not for the US: GRAS notices carry no data protection. It cannot know of agreements in which the applicant lets another company use its data, which also end exclusivity.",
        "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": "Last end date to include, YYYY-MM-DD."
                  },
                  "after": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "First end date to include, YYYY-MM-DD. Defaults to today; pass an earlier date to see protection that has already ended."
                  },
                  "market": {
                    "type": [
                      "string",
                      "array"
                    ],
                    "maxLength": 20,
                    "maxItems": 2,
                    "items": {
                      "type": "string",
                      "enum": [
                        "EU",
                        "GB",
                        "UK"
                      ]
                    },
                    "description": "EU, GB or both (default both). UK is read as GB."
                  },
                  "page": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 500,
                    "description": "Page number, from 1. Follow next_page while it is not null."
                  },
                  "per_page": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 50,
                    "description": "Entries per page, 1 to 50, default 25."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid key"
          },
          "429": {
            "description": "Limit reached"
          }
        }
      }
    }
  }
}
