{
  "openapi": "3.1.0",
  "info": {
    "title": "Journal of Biohacking evidence API",
    "version": "1.0.0",
    "summary": "Read-only search and lookup over the evidence dataset, served by the evidence worker.",
    "description": "Answers from the Journal of Biohacking evidence dataset (https://journalofbiohacking.com/data/evidence/v1/, version 1.0.0). Every compound and null result carries the address of its page on the journal. Educational reference, not medical advice. The journal reports what studies found and does not recommend any compound, dose or practice. The dataset has no dosing sections; compound names, aliases, evidence labels and citation titles can state a dose or strength, as studied or as a product is sold. The same worker serves an MCP endpoint at /mcp (Streamable HTTP).",
    "license": {
      "name": "Creative Commons Attribution 4.0 International (CC BY 4.0)",
      "identifier": "CC-BY-4.0"
    }
  },
  "servers": [
    {
      "url": "/",
      "description": "The address the evidence worker (workers/evidence-mcp in the repository) is deployed at. The journal site itself publishes the dataset files, not these endpoints."
    }
  ],
  "externalDocs": {
    "description": "Evidence dataset",
    "url": "https://journalofbiohacking.com/evidence-dataset/"
  },
  "paths": {
    "/api/v1/evidence/compounds": {
      "get": {
        "operationId": "searchCompounds",
        "summary": "Search or list compounds by name, alias or evidence scale step.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "step",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "consistent-human-trials",
                "human-trials-with-limits",
                "early-human-studies",
                "not-established-in-people",
                "too-little-read"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 10
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of compound summaries, best match first.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompoundPage"
                }
              }
            }
          },
          "400": {
            "description": "Unknown step.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/evidence/compounds/{id}": {
      "get": {
        "operationId": "getCompound",
        "summary": "One compound with its evidence labels, step, divergence, regulatory status, sources with PMIDs and claim receipt status.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The compound.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompoundEnvelope"
                }
              }
            }
          },
          "400": {
            "description": "The id is not valid percent-encoding.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No record with that id.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/evidence/scale": {
      "get": {
        "operationId": "getScale",
        "summary": "The journal evidence scale and how each labelling system reads onto it.",
        "responses": {
          "200": {
            "description": "The evidence scale (the file data/evidence/v1/evidence-scale.json).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScaleEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/evidence/null-results": {
      "get": {
        "operationId": "listNullResults",
        "summary": "List null results, optionally filtered by words or failure category.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "null-human-rct",
                "net-harm-boundary",
                "preclinical-collapse",
                "orthobiologic-device-null",
                "diagnostic-assay-myth",
                "surrogate-vs-mortality"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 10
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of null results.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NullResultPage"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/evidence/null-results/{id}": {
      "get": {
        "operationId": "getNullResult",
        "summary": "One null result.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The null result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NullResultEnvelope"
                }
              }
            }
          },
          "400": {
            "description": "The id is not valid percent-encoding.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No record with that id.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/evidence/openapi.json": {
      "get": {
        "operationId": "getOpenApi",
        "summary": "This description.",
        "responses": {
          "200": {
            "description": "OpenAPI 3.1 document.",
            "content": {
              "application/json": {}
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          }
        }
      },
      "Envelope": {
        "type": "object",
        "required": [
          "dataset",
          "version",
          "releasedOn",
          "licence",
          "notice"
        ],
        "properties": {
          "dataset": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "releasedOn": {
            "type": "string",
            "format": "date"
          },
          "licence": {
            "type": "object"
          },
          "notice": {
            "type": "string"
          }
        }
      },
      "CompoundSummary": {
        "type": "object",
        "required": [
          "id",
          "name",
          "page",
          "step",
          "stepName",
          "evidenceLabels"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "fullName": {
            "type": "string"
          },
          "page": {
            "type": "string",
            "format": "uri",
            "description": "Entry page to cite."
          },
          "step": {
            "type": "string",
            "enum": [
              "consistent-human-trials",
              "human-trials-with-limits",
              "early-human-studies",
              "not-established-in-people",
              "too-little-read"
            ]
          },
          "stepName": {
            "type": "string"
          },
          "stepRank": {
            "type": "integer"
          },
          "stepsDisagree": {
            "type": "boolean"
          },
          "evidenceLabels": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "regulatoryStatus": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "aliases": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "CompoundPage": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Envelope"
          },
          {
            "type": "object",
            "required": [
              "total",
              "limit",
              "offset",
              "items"
            ],
            "properties": {
              "total": {
                "type": "integer"
              },
              "limit": {
                "type": "integer"
              },
              "offset": {
                "type": "integer"
              },
              "items": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/CompoundSummary"
                }
              }
            }
          }
        ]
      },
      "CompoundEnvelope": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Envelope"
          },
          {
            "type": "object",
            "required": [
              "compound"
            ],
            "properties": {
              "compound": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/CompoundSummary"
                  },
                  {
                    "type": "object",
                    "required": [
                      "records"
                    ],
                    "properties": {
                      "stepDefinition": {
                        "type": "string"
                      },
                      "claimsDivergence": {
                        "type": "array"
                      },
                      "bodySystems": {
                        "type": "object"
                      },
                      "records": {
                        "type": "array",
                        "items": {
                          "type": "object"
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        ]
      },
      "ScaleEnvelope": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Envelope"
          },
          {
            "type": "object",
            "required": [
              "scale"
            ],
            "properties": {
              "scale": {
                "type": "object"
              }
            }
          }
        ]
      },
      "NullResult": {
        "type": "object",
        "required": [
          "id",
          "claim",
          "page"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "claim": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "categoryLabel": {
            "type": [
              "string",
              "null"
            ]
          },
          "preclinicalOrigin": {
            "type": "string"
          },
          "decisiveResult": {
            "type": "string"
          },
          "failureMode": {
            "type": "string"
          },
          "pmid": {
            "type": [
              "string",
              "null"
            ]
          },
          "citation": {
            "type": [
              "string",
              "null"
            ]
          },
          "page": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "NullResultPage": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Envelope"
          },
          {
            "type": "object",
            "required": [
              "total",
              "limit",
              "offset",
              "items"
            ],
            "properties": {
              "total": {
                "type": "integer"
              },
              "limit": {
                "type": "integer"
              },
              "offset": {
                "type": "integer"
              },
              "items": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/NullResult"
                }
              }
            }
          }
        ]
      },
      "NullResultEnvelope": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Envelope"
          },
          {
            "type": "object",
            "required": [
              "nullResult"
            ],
            "properties": {
              "nullResult": {
                "$ref": "#/components/schemas/NullResult"
              }
            }
          }
        ]
      }
    }
  }
}
