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

# API Quickstart

> Parse your first document with the Pulse API and SDKs.

## Prerequisites

Before you begin, make sure you have:

> [card] API Key
>
> Get your API key from the [Platform](https://platform.runpulse.com)

> [card] SDK or HTTP Client
>
> Install the official SDK or use curl/fetch

## Step 1: Install the SDK

```bash Python theme={null}
pip install pulse-python-sdk
```

```bash TypeScript theme={null}
npm install pulse-ts-sdk
```

## Step 2: Basic Document Extraction

Extract content from a document URL:

```python Python theme={null}
from pulse import Pulse
from pulse.types import (
    ExtractRequestFigureProcessing,
    ExtractRequestExtensions,
    ExtractRequestExtensionsAltOutputs,
)

client = Pulse(api_key="YOUR_API_KEY")

# Extract from a URL
response = client.extract(
    file_url="https://platform.runpulse.com/api/examples/637e5678-30b1-45fa-acc4-877f2d636419/pdf",
    figure_processing=ExtractRequestFigureProcessing(
        description=True,
    ),
    extensions=ExtractRequestExtensions(
        alt_outputs=ExtractRequestExtensionsAltOutputs(
            return_html=True,
        ),
    ),
)

print(f"Markdown: {response.markdown}")
print(f"Extraction ID: {response.extraction_id}")
```

```typescript TypeScript theme={null}
import { PulseClient } from 'pulse-ts-sdk';

const client = new PulseClient({ apiKey: "YOUR_API_KEY" });

const response = await client.extract({
    fileUrl: "https://platform.runpulse.com/api/examples/637e5678-30b1-45fa-acc4-877f2d636419/pdf",
    figureProcessing: { description: true },
    extensions: { altOutputs: { returnHtml: true } }
});

console.log(`Markdown: ${response.markdown}`);
console.log(`Extraction ID: ${response.extraction_id}`);
```

```bash curl theme={null}
curl -X POST https://api.runpulse.com/extract \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "file_url": "https://platform.runpulse.com/api/examples/637e5678-30b1-45fa-acc4-877f2d636419/pdf",
    "figure_processing": {"description": true},
    "extensions": {"alt_outputs": {"return_html": true}}
  }'
```

## Step 3: Uploading Files Directly

`/extract` accepts file uploads directly via multipart/form-data:

```python Python theme={null}
from pulse import Pulse
from pulse.types import ExtractRequestFigureProcessing

client = Pulse(api_key="YOUR_API_KEY")

# Upload and extract a local file
with open("invoice.pdf", "rb") as f:
    response = client.extract(
        file=f,
        pages="1-5",  # 1-indexed page range
        figure_processing=ExtractRequestFigureProcessing(
            description=True,
        ),
    )

print(f"Extraction ID: {response.extraction_id}")
print(f"Markdown: {response.markdown}")
```

```typescript TypeScript theme={null}
import * as fs from 'fs';
import { PulseClient } from 'pulse-ts-sdk';

const client = new PulseClient({ apiKey: "YOUR_API_KEY" });

// Upload and extract a local file
const fileBuffer = fs.readFileSync("invoice.pdf");
const blob = new Blob([fileBuffer], { type: 'application/pdf' });

const response = await client.extract({
    file: blob,
    pages: "1-5",  // 1-indexed page range
    figureProcessing: { description: true }
});

console.log(`Extraction ID: ${response.extraction_id}`);
console.log(`Markdown: ${response.markdown}`);
```

```bash curl theme={null}
# Upload a file directly
curl -X POST https://api.runpulse.com/extract \
  -H "x-api-key: YOUR_API_KEY" \
  -F "file=@invoice.pdf" \
  -F "pages=1-5"
```

> [!TIP]
>
> Use `file` for direct uploads or `file_url` when you have a public/presigned URL.

## Step 4: Asynchronous Processing for Large Documents

For documents over 50 pages or when processing multiple files, use `async: true` on the `/extract` endpoint:

```python Python theme={null}
import time
from pulse import Pulse

client = Pulse(api_key="YOUR_API_KEY")

# Submit async extraction
submission = client.extract(
    file_url="https://platform.runpulse.com/api/examples/637e5678-30b1-45fa-acc4-877f2d636419/pdf",
    figure_processing=ExtractRequestFigureProcessing(description=True),
    async_=True  # Note: async_ in Python (async is reserved)
)

print(f"Job submitted: {submission.job_id}")

# Poll for completion
job_id = submission.job_id
while True:
    job_status = client.jobs.get_job(job_id=job_id)
    print(f"Status: {job_status.status}")
    
    if job_status.status == "completed":
        print("Job completed!")
        print(f"Result: {job_status.result}")
        break
    elif job_status.status in ["failed", "canceled"]:
        print(f"Job ended: {job_status.status}")
        break
    
    time.sleep(2)
```

```typescript TypeScript theme={null}
import { PulseClient } from 'pulse-ts-sdk';

const client = new PulseClient({ apiKey: "YOUR_API_KEY" });

// Submit async extraction
const submission = await client.extract({
    fileUrl: "https://platform.runpulse.com/api/examples/637e5678-30b1-45fa-acc4-877f2d636419/pdf",
    async: true
});

console.log(`Job submitted: ${submission.job_id}`);

// Poll for completion
const jobId = submission.job_id;
while (true) {
    const jobStatus = await client.jobs.getJob({ jobId });
    console.log(`Status: ${jobStatus.status}`);
    
    if (jobStatus.status === 'completed') {
        console.log('Job completed!');
        console.log(`Result: ${JSON.stringify(jobStatus.result)}`);
        break;
    } else if (jobStatus.status === 'failed' || jobStatus.status === 'canceled') {
        console.log(`Job ended: ${jobStatus.status}`);
        break;
    }
    
    await new Promise(resolve => setTimeout(resolve, 2000));
}
```

```bash curl theme={null}
# Submit async extraction
curl -X POST https://api.runpulse.com/extract \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"file_url": "https://platform.runpulse.com/api/examples/637e5678-30b1-45fa-acc4-877f2d636419/pdf", "async": true}'

# Response: {"job_id": "abc123", "status": "pending", "message": "Document processing started"}

# Poll for results
curl https://api.runpulse.com/job/abc123 \
  -H "x-api-key: YOUR_API_KEY"
```

## Common Use Cases

> [accordion] Invoice Processing
>
> Extract structured data from invoices:
>
> ```python Python theme={null}
> schema = {
>     "type": "object",
>     "properties": {
>         "invoice_number": {"type": "string"},
>         "vendor_name": {"type": "string"},
>         "total": {"type": "number"},
>         "line_items": {
>             "type": "array",
>             "items": {
>                 "type": "object",
>                 "properties": {
>                     "description": {"type": "string"},
>                     "amount": {"type": "number"}
>                 }
>             }
>         }
>     }
> }
>
> # Step 1: Extract the document
> response = client.extract(
>     file_url="https://platform.runpulse.com/api/examples/637e5678-30b1-45fa-acc4-877f2d636419/pdf"
> )
>
> # Step 2: Apply schema via /schema endpoint
> schema_result = client.schema(
>     extraction_id=response.extraction_id,
>     schema_config={"input_schema": schema}
> )
> ```
>
> ```typescript TypeScript theme={null}
> const schema = {
>     type: "object",
>     properties: {
>         invoice_number: { type: "string" },
>         vendor_name: { type: "string" },
>         total: { type: "number" }
>     }
> };
>
> // Step 1: Extract the document
> const response = await client.extract({
>     fileUrl: "https://platform.runpulse.com/api/examples/637e5678-30b1-45fa-acc4-877f2d636419/pdf"
> });
>
> // Step 2: Apply schema via /schema endpoint
> const schemaResult = await client.schema({
>     extraction_id: response.extraction_id,
>     schema_config: { input_schema: schema }
> });
> ```

> [accordion] Contract Analysis
>
> Extract key terms from contracts:
>
> ```python Python theme={null}
> schema = {
>     "type": "object",
>     "properties": {
>         "parties": {
>             "type": "array",
>             "items": {
>                 "type": "object",
>                 "properties": {
>                     "name": {"type": "string"},
>                     "role": {"type": "string"}
>                 }
>             }
>         },
>         "effective_date": {"type": "string"},
>         "payment_terms": {"type": "string"}
>     }
> }
>
> # Step 1: Extract
> response = client.extract(
>     file_url="https://platform.runpulse.com/api/examples/637e5678-30b1-45fa-acc4-877f2d636419/pdf"
> )
>
> # Step 2: Apply schema
> schema_result = client.schema(
>     extraction_id=response.extraction_id,
>     schema_config={"input_schema": schema}
> )
> ```
>
> ```typescript TypeScript theme={null}
> const schema = {
>     type: "object",
>     properties: {
>         parties: {
>             type: "array",
>             items: {
>                 type: "object",
>                 properties: {
>                     name: { type: "string" },
>                     role: { type: "string" }
>                 }
>             }
>         },
>         effective_date: { type: "string" },
>         payment_terms: { type: "string" }
>     }
> };
>
> // Step 1: Extract
> const response = await client.extract({
>     fileUrl: "https://platform.runpulse.com/api/examples/637e5678-30b1-45fa-acc4-877f2d636419/pdf"
> });
>
> // Step 2: Apply schema
> const schemaResult = await client.schema({
>     extraction_id: response.extraction_id,
>     schema_config: { input_schema: schema }
> });
> ```

> [accordion] Research Paper Processing
>
> Extract structured content from academic papers:
>
> ```python Python theme={null}
> schema = {
>     "type": "object",
>     "properties": {
>         "title": {"type": "string"},
>         "authors": {"type": "array", "items": {"type": "string"}},
>         "abstract": {"type": "string"},
>         "keywords": {"type": "array", "items": {"type": "string"}}
>     }
> }
>
> # Step 1: Extract
> response = client.extract(
>     file_url="https://platform.runpulse.com/api/examples/637e5678-30b1-45fa-acc4-877f2d636419/pdf"
> )
>
> # Step 2: Apply schema
> schema_result = client.schema(
>     extraction_id=response.extraction_id,
>     schema_config={"input_schema": schema}
> )
> ```
>
> ```typescript TypeScript theme={null}
> const schema = {
>     type: "object",
>     properties: {
>         title: { type: "string" },
>         authors: { type: "array", items: { type: "string" } },
>         abstract: { type: "string" },
>         keywords: { type: "array", items: { type: "string" } }
>     }
> };
>
> // Step 1: Extract
> const response = await client.extract({
>     fileUrl: "https://platform.runpulse.com/api/examples/637e5678-30b1-45fa-acc4-877f2d636419/pdf"
> });
>
> // Step 2: Apply schema
> const schemaResult = await client.schema({
>     extraction_id: response.extraction_id,
>     schema_config: { input_schema: schema }
> });
> ```

## Next Steps

> [card] [Schema Extraction](https://docs.runpulse.com/api-reference/endpoint/schema.md)
>
> Apply schemas to extracted documents

> [card] [Route by Document Type](https://docs.runpulse.com/api-reference/endpoint/classify.md)
>
> Classify mixed intake before extracting

> [card] [Large Documents](https://docs.runpulse.com/api-reference/large-documents.md)
>
> Best practices for big files

> [card] [Async Processing](https://docs.runpulse.com/api-reference/async-processing.md)
>
> Async flag, polling, and webhooks

> [card] [API Reference](https://docs.runpulse.com/api-reference/introduction.md)
>
> Explore all endpoints


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.