{
  "openapi": "3.1.0",
  "info": {
    "title": "Quality Medical Research — Public Clinical Trial Search API",
    "version": "1.0.1",
    "description": "Read-only public NLWeb search for published clinical research information at Quality Medical Research (QMR). Results do not establish participant eligibility or current study recruitment status. Standard REST errors from the WordPress API use a typed JSON object with code, message, and optional data.status; some upstream proxy errors may not use this format.\n\nVersioning & Deprecation Policy: API versions are tracked via the versioned API release and X-API-Version header (or versioned path prefixes such as /v1/). Deprecated endpoints or fields include RFC 8594 Deprecation and Sunset headers with advance notice prior to retirement."
  },
  "servers": [
  {
    "url": "https://qualitymedicalresearch.com/wp-json/qmr-nlweb/v1",
    "description": "QMR NLWeb API — version 1"
  },
  {
    "url": "https://qualitymedicalresearch.com",
    "description": "QMR public API alias"
  }
],
  "tags": [
    {
      "name": "Public clinical trial search",
      "description": "Search only published information; no login or patient records."
    }
  ],
  "paths": {
    "/ask": {
      "get": {
        "tags": [
          "Public clinical trial search"
        ],
        "operationId": "searchPublicClinicalTrialsGet",
        "summary": "Search public clinical trial pages using GET",
        "description": "Pass a natural-language question as query. Set streaming=true or Accept: text/event-stream to request Server-Sent Events.",
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "required": true,
            "description": "Natural-language query, such as Find Crohn's disease clinical trials.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 2000
            },
            "example": "Find Crohn's disease clinical trials"
          },
          {
            "name": "streaming",
            "in": "query",
            "required": false,
            "description": "Request SSE instead of JSON.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "$ref": "#/components/parameters/CursorParam"
          },
          {
            "$ref": "#/components/parameters/LimitParam"
          },
          {
            "name": "Accept",
            "in": "header",
            "required": false,
            "description": "text/event-stream requests SSE; application/json requests JSON.",
            "schema": {
              "type": "string",
              "enum": [
                "application/json",
                "text/event-stream"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Public search result in JSON or SSE format. Event streams emit start, result/error, and complete events.",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/XApiVersion"
              },
              "Deprecation": {
                "$ref": "#/components/headers/Deprecation"
              },
              "Sunset": {
                "$ref": "#/components/headers/Sunset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResponse"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                },
                "example": "event: start\ndata: {\"_meta\":{\"response_type\":\"answer\",\"response_format\":\"conversational_search\",\"version\":\"0.55\",\"streaming\":true}}\n\nevent: result\ndata: {\"index\":0,\"item\":{\"@type\":\"WebPage\",\"name\":\"Crohn’s Disease\",\"url\":\"https://qualitymedicalresearch.com/clinical-trials/crohns-disease/\"}}\n\nevent: complete\ndata: {\"_meta\":{\"response_type\":\"answer\",\"response_format\":\"conversational_search\",\"version\":\"0.55\",\"streaming\":true}}\n\n"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "500": {
            "$ref": "#/components/responses/ApplicationServerError"
          },
          "default": {
            "description": "Other application-level HTTP errors, when returned as JSON.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WordPressApiError"
                }
              }
            }
          }
        },
        "security": []
      },
      "post": {
        "tags": [
          "Public clinical trial search"
        ],
        "operationId": "searchPublicClinicalTrialsPost",
        "summary": "Search public clinical trial pages using POST",
        "description": "Provide query.text in a JSON request body. Set prefer.streaming to true or use Accept: text/event-stream to request SSE.",
        "parameters": [
          {
            "name": "Accept",
            "in": "header",
            "required": false,
            "description": "text/event-stream requests SSE; application/json requests JSON.",
            "schema": {
              "type": "string",
              "enum": [
                "application/json",
                "text/event-stream"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SearchRequest"
              },
              "example": {
                "query": {
                  "text": "Find Crohn's disease clinical trials"
                },
                "prefer": {
                  "streaming": false
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Public search results or server-sent events. SSE may contain error events when no public pages match.",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/XApiVersion"
              },
              "Deprecation": {
                "$ref": "#/components/headers/Deprecation"
              },
              "Sunset": {
                "$ref": "#/components/headers/Sunset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResponse"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "NLWeb v0.55 Server-Sent Events: start, result, error, complete."
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "500": {
            "$ref": "#/components/responses/ApplicationServerError"
          },
          "default": {
            "description": "Other application-level HTTP errors, when returned as JSON.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WordPressApiError"
                }
              }
            }
          }
        },
        "security": []
      }
    }
  },
  "components": {
    "parameters": {
      "CursorParam": {
        "name": "cursor",
        "in": "query",
        "required": false,
        "description": "Opaque cursor token from pagination.next_cursor to fetch the next page of results.",
        "schema": {
          "type": "string"
        }
      },
      "LimitParam": {
        "name": "limit",
        "in": "query",
        "required": false,
        "description": "Maximum number of results to return per page.",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 20
        }
      }
    },
    "headers": {
      "XApiVersion": {
        "description": "API version identifier for the response.",
        "schema": {
          "type": "string",
          "example": "1.0.1"
        }
      },
      "Deprecation": {
        "description": "RFC 8594 header indicating when an endpoint or feature is deprecated.",
        "schema": {
          "type": "string",
          "example": "@1798761600"
        }
      },
      "Sunset": {
        "description": "RFC 8594 HTTP-date indicating when a deprecated endpoint or feature will be retired.",
        "schema": {
          "type": "string",
          "format": "date-time",
          "example": "Thu, 31 Dec 2026 23:59:59 GMT"
        }
      }
    },
    "schemas": {
      "PaginationMeta": {
        "type": "object",
        "properties": {
          "has_more": {
            "type": "boolean",
            "description": "Whether additional result pages are available."
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Cursor to pass in the next request, or null if no more pages exist."
          }
        }
      },
      "SearchRequest": {
        "type": "object",
        "required": [
          "query"
        ],
        "properties": {
          "query": {
            "type": "object",
            "required": [
              "text"
            ],
            "properties": {
              "text": {
                "type": "string",
                "minLength": 1,
                "description": "Natural-language search text."
              }
            }
          },
          "prefer": {
            "type": "object",
            "properties": {
              "streaming": {
                "type": "boolean",
                "default": false
              }
            }
          }
        }
      },
      "ResponseMeta": {
        "type": "object",
        "properties": {
          "response_type": {
            "type": "string",
            "example": "answer"
          },
          "response_format": {
            "type": "string",
            "example": "conversational_search"
          },
          "version": {
            "type": "string",
            "example": "0.55"
          },
          "streaming": {
            "type": "boolean"
          }
        }
      },
      "PublicWebPage": {
        "type": "object",
        "properties": {
          "@type": {
            "type": "string",
            "example": "WebPage"
          },
          "name": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "description": {
            "type": "string"
          }
        }
      },
      "SearchResponse": {
        "type": "object",
        "properties": {
          "_meta": {
            "$ref": "#/components/schemas/ResponseMeta"
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicWebPage"
            }
          },
          "pagination": {
            "$ref": "#/components/schemas/PaginationMeta"
          }
        }
      },
      "WordPressApiError": {
        "type": "object",
        "description": "WordPress REST-style JSON error, for errors returned by the API application. Upstream Nginx/proxy failures may have a different format.",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "Machine-readable error identifier."
          },
          "message": {
            "type": "string",
            "description": "Human-readable explanation of the error."
          },
          "data": {
            "type": [
              "object",
              "null"
            ],
            "description": "Additional error metadata, including HTTP status where available.",
            "properties": {
              "status": {
                "type": "integer",
                "minimum": 400,
                "maximum": 599
              }
            },
            "additionalProperties": true
          }
        },
        "additionalProperties": true,
        "examples": [
          {
            "code": "invalid_request",
            "message": "A valid query is required.",
            "data": {
              "status": 400
            }
          }
        ]
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Request validation failed; example values are illustrative and may differ from the live endpoint.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/WordPressApiError"
            },
            "example": {
              "code": "invalid_request",
              "message": "A valid query is required.",
              "data": {
                "status": 400
              }
            }
          }
        }
      },
      "ApplicationServerError": {
        "description": "If the WordPress application returns a JSON server error, it uses a machine-readable error object. Reverse-proxy failures might return HTML instead.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/WordPressApiError"
            },
            "example": {
              "code": "internal_error",
              "message": "The request could not be completed.",
              "data": {
                "status": 500
              }
            }
          }
        }
      }
    }
  },
  "externalDocs": {
    "description": "QMR API documentation",
    "url": "https://qualitymedicalresearch.com/developers/"
  }
}