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

# Parse Quickstart

> Parse your first document into Markdown and structured elements.

Parse converts a document into Markdown and structured elements while preserving reading order, layout, tables, images, and formulas.

In this quickstart, you will:

1. Install Python dependencies.
2. Parse a sample document.
3. Read the returned Markdown and structured elements.

## Before you start

You need:

* TextIn API credentials. See [Authentication](/xparse/authentication).
* Python 3.8 or later.
* A PDF, image, Office file, or other supported document.

You can use your own file or download a [sample PDF](https://api.textin.ai/image/download?filename=35265762a76e40b4846ae52d08.pdf).

<Info>
  For supported formats, file size limits, page limits, and concurrency limits, see [Supported Files & Limits](/xparse/supported-files).
</Info>

## Install dependencies

```bash theme={null}
pip install requests
```

## Set your credentials

Set your App ID and Secret Code as environment variables:

```bash theme={null}
export TEXTIN_APP_ID="your-app-id"
export TEXTIN_SECRET_CODE="your-secret-code"
```

On Windows PowerShell:

```powershell theme={null}
$env:TEXTIN_APP_ID="your-app-id"
$env:TEXTIN_SECRET_CODE="your-secret-code"
```

## Parse a document

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

with open("document.pdf", "rb") as file:
    response = requests.post(
        "https://api.textin.ai/api/v1/xparse/parse/sync",
        headers={
            "x-ti-app-id": os.environ["TEXTIN_APP_ID"],
            "x-ti-secret-code": os.environ["TEXTIN_SECRET_CODE"],
        },
        files={"file": ("document.pdf", file)},
    )

response.raise_for_status()
result = response.json()["data"]

print(result["markdown"])
```

## Inspect the result

Parse returns Markdown and structured document elements.

### Markdown

```markdown theme={null}
# Annual Report 2024

## Executive Summary

This report presents...
```

Use Markdown for:

* RAG pipelines and retrieval workflows
* Full-text search and indexing
* Summarization
* Chunking and embedding
* Document review applications

### Structured elements

Each element represents part of the document, such as a heading, paragraph, table, image, or formula.

```python theme={null}
for element in result["elements"][:5]:
    print(element["type"], element["page_number"], element["text"][:80])
```

Common element fields include:

| Field         | Description                                                         |
| ------------- | ------------------------------------------------------------------- |
| `element_id`  | Unique identifier for the element                                   |
| `type`        | Element type, such as `Title`, `NarrativeText`, `Table`, or `Image` |
| `text`        | Recognized text content                                             |
| `page_number` | Page containing the element                                         |
| `coordinates` | Normalized four-point bounding box                                  |

<Info>
  See [Response Format](/xparse/parse/response-format) for the complete response structure.
</Info>

## Save the output

```python theme={null}
from pathlib import Path

Path("output.md").write_text(result["markdown"], encoding="utf-8")
```

## Use cURL

You can also call the synchronous Parse endpoint directly:

```bash theme={null}
curl -X POST "https://api.textin.ai/api/v1/xparse/parse/sync" \
  -H "x-ti-app-id: $TEXTIN_APP_ID" \
  -H "x-ti-secret-code: $TEXTIN_SECRET_CODE" \
  -F "file=@document.pdf"
```

## Use the Python SDK

If you are using the Python SDK version that exposes `XParseClient`, you can call Parse like this:

```python theme={null}
from xparse_client import XParseClient

client = XParseClient(
    app_id="your-app-id",
    secret_code="your-secret-code",
)

with open("document.pdf", "rb") as file:
    result = client.parse.run(
        file=file,
        filename="document.pdf",
    )

print(result.markdown)
```

<Note>
  The SDK interface may vary by package version. If your installed `xparse-client` package does not expose `XParseClient`, use the REST API examples above or the SDK version provided by TextIn.
</Note>

## Next steps

<CardGroup cols={2}>
  <Card title="Configuration" icon="sliders" href="/xparse/parse/configuration">
    Customize parsing behavior and returned data.
  </Card>

  <Card title="Response Format" icon="code" href="/xparse/parse/response-format">
    Understand Markdown, elements, coordinates, pages, and optional fields.
  </Card>

  <Card title="Async Processing" icon="clock" href="/xparse/parse/async-processing">
    Process large documents or batch jobs asynchronously.
  </Card>

  <Card title="Examples" icon="book-open" href="/xparse/parse/examples">
    Explore common implementation patterns.
  </Card>
</CardGroup>
