> ## 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.

# Get Document Contents

> Retrieve all pages of a document by document ID

## Request Body

<ParamField body="doc_id" type="string" required>
  The document identifier. Get this from the `doc_id` field in search results.
  Examples: `nda/2017/208264Orig1s000ChemR.pdf` or
  `https://www.fda.gov/media/71756/download`
</ParamField>

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

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

## Response

<ResponseField name="doc_id" type="string">
  The document identifier.
</ResponseField>

<ResponseField name="dataset" type="string">
  The dataset this document belongs to.
</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="pages" type="array">
  Array of document pages.

  <Expandable title="Page object">
    <ResponseField name="page_num" type="integer">
      Page number (0-indexed).
    </ResponseField>

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

<ResponseField name="total_pages" type="integer">
  Total number of pages in the document (for pagination).
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.rhizomeai.com/api/contents \
    -H "Content-Type: application/json" \
    -H "x-api-key: YOUR_API_KEY" \
    -d '{
      "doc_id": "nda/2017/208264Orig1s000ChemR.pdf",
      "top_k": 10,
      "offset": 0
    }'
  ```

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

  response = requests.post(
      "https://api.rhizomeai.com/api/contents",
      headers={
          "Content-Type": "application/json",
          "x-api-key": "YOUR_API_KEY"
      },
      json={
          "doc_id": "nda/2017/208264Orig1s000ChemR.pdf",
          "top_k": 10,
          "offset": 0
      }
  )

  data = response.json()
  print(f"Document: {data['name']}")
  print(f"Total pages: {data['total_pages']}")
  for page in data["pages"]:
      print(f"Page {page['page_num']}: {page['text'][:100]}...")
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://api.rhizomeai.com/api/contents", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "x-api-key": "YOUR_API_KEY",
    },
    body: JSON.stringify({
      doc_id: "nda/2017/208264Orig1s000ChemR.pdf",
      top_k: 10,
      offset: 0,
    }),
  });

  const data = await response.json();
  console.log(`Document: ${data.name}`);
  console.log(`Total pages: ${data.total_pages}`);
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "doc_id": "nda/2017/208264Orig1s000ChemR.pdf",
    "dataset": "fda_drug",
    "name": "TEPADINA THIOTEPA",
    "url": "https://www.accessdata.fda.gov/drugsatfda_docs/nda/2017/208264Orig1s000ChemR.pdf",
    "company": "ADIENNE SA",
    "year_decision": 2017,
    "pages": [
      {
        "page_num": 1,
        "text": "CENTER FOR DRUG EVALUATION AND RESEARCH..."
      },
      {
        "page_num": 2,
        "text": "TABLE OF CONTENTS..."
      },
      {
        "page_num": 3,
        "text": "EXECUTIVE SUMMARY..."
      }
    ],
    "total_pages": 97
  }
  ```
</ResponseExample>

## Pagination Example

To fetch all pages of a large document:

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

doc_id = "nda/2017/208264Orig1s000ChemR.pdf"
all_pages = []
offset = 0
page_size = 20

while True:
    response = requests.post(
        "https://api.rhizomeai.com/api/contents",
        headers={
            "Content-Type": "application/json",
            "x-api-key": "YOUR_API_KEY"
        },
        json={
            "doc_id": doc_id,
            "top_k": page_size,
            "offset": offset
        }
    )

    data = response.json()
    all_pages.extend(data["pages"])

    if len(all_pages) >= data["total_pages"]:
        break

    offset += page_size

print(f"Retrieved {len(all_pages)} pages")
```

## Error Codes

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