> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rhizomeai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Search

> Search regulatory documents by keyword with page-level results

## Request Body

<ParamField body="query_text" type="string" required>
  The search query text. Searches across document content using BM25 ranking.
</ParamField>

<ParamField body="top_k" type="integer" default={20}>
  Maximum number of results to return. Min: 1, Max: 100.
</ParamField>

<ParamField body="offset" type="integer" default={0}>
  Number of results to skip for pagination. Min: 0.
</ParamField>

<ParamField body="dataset_to_search" type="string[]" default={[]}>
  Filter results to specific datasets. Empty array searches all datasets.
  Available datasets include: `fda_drug`, `fda_biologic`, `fda_pma`,
  `fda_denovo_or_510k`, `fda_guidance`, `fda_warning_letters`,
  `fda_clinical_trials`, `fda_483`, `fda_inspections`, `ema_epar`,
  `ema_guidelines`, `canada_guidance`, and more. See
  [Introduction](/introduction#available-datasets) for the full list.
</ParamField>

<ParamField body="year_from" type="integer">
  Filter results from this year onwards (inclusive).
</ParamField>

<ParamField body="year_to" type="integer">
  Filter results up to this year (inclusive).
</ParamField>

## Response

<ResponseField name="results" type="array">
  Array of search results, ordered by relevance score.

  <Expandable title="Result object">
    <ResponseField name="id" type="string">
      Unique page chunk identifier.
    </ResponseField>

    <ResponseField name="doc_id" type="string">
      Document identifier. Use this with `/contents` to get all pages.
    </ResponseField>

    <ResponseField name="dataset" type="string">
      The dataset this result belongs to.
    </ResponseField>

    <ResponseField name="page_num" type="integer">
      The page number where the match was found (0-indexed).
    </ResponseField>

    <ResponseField name="score" type="number">
      BM25 relevance score. Higher is more relevant.
    </ResponseField>

    <ResponseField name="name" type="string">
      Document name/title.
    </ResponseField>

    <ResponseField name="url" type="string">
      Original FDA URL for the document.
    </ResponseField>

    <ResponseField name="company" type="string">
      Company name (if applicable).
    </ResponseField>

    <ResponseField name="year_decision" type="integer">
      Year of the decision/publication.
    </ResponseField>

    <ResponseField name="text" type="string">
      Full text content of the matched page.
    </ResponseField>

    <ResponseField name="highlight" type="string">
      Text snippet with `<b>` tags highlighting matched terms.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="total" type="integer">
  Total number of matching results (for pagination).
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.rhizomeai.com/api/search \
    -H "Content-Type: application/json" \
    -H "x-api-key: YOUR_API_KEY" \
    -d '{
      "query_text": "FDA approval process",
      "top_k": 10,
      "offset": 0
    }'
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://api.rhizomeai.com/api/search",
      headers={
          "Content-Type": "application/json",
          "x-api-key": "YOUR_API_KEY"
      },
      json={
          "query_text": "FDA approval process",
          "top_k": 10,
          "offset": 0
      }
  )

  data = response.json()
  print(f"Found {data['total']} results")
  for result in data["results"]:
      print(f"- {result['name']} (page {result['page_num']})")
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://api.rhizomeai.com/api/search", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "x-api-key": "YOUR_API_KEY",
    },
    body: JSON.stringify({
      query_text: "FDA approval process",
      top_k: 10,
      offset: 0,
    }),
  });

  const data = await response.json();
  console.log(`Found ${data.total} results`);
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "results": [
      {
        "id": "nda/2017/208264Orig1s000ChemR.pdf 3 42",
        "doc_id": "nda/2017/208264Orig1s000ChemR.pdf",
        "dataset": "fda_drug",
        "page_num": 42,
        "score": 15.57,
        "name": "TEPADINA THIOTEPA",
        "url": "https://www.accessdata.fda.gov/drugsatfda_docs/nda/2017/208264Orig1s000ChemR.pdf",
        "company": "ADIENNE SA",
        "year_decision": 2017,
        "text": "QUALITY ASSESSMENT | post approval + Formulation...",
        "highlight": "<b>Process</b> parameters * Scale/equipment * Site Leachables..."
      }
    ],
    "total": 17319
  }
  ```
</ResponseExample>

## Error Codes

| Status | Description                              |
| ------ | ---------------------------------------- |
| 400    | Invalid request body                     |
| 401    | Missing or invalid API key               |
| 429    | Rate limit exceeded (50 requests/minute) |
| 500    | Internal server error                    |
