---
title: Extract
url: https://anyrow.ai/docs/api/extract
canonical_url: https://anyrow.ai/docs/api/extract
---

# Extract

Extract rows from a file or text, as one JSON response or a stream of server-sent events.

- [Extract data from text or file (JSON response)](https://anyrow.ai/docs/api/extract/once.md): `POST /v1/projects/{project_id}/extract`
- [Extract data from text or file (SSE stream)](https://anyrow.ai/docs/api/extract/stream.md): `POST /v1/projects/{project_id}/extract-stream`
- [Extract into table (JSON response)](https://anyrow.ai/docs/api/extract/table-once.md): `POST /v1/projects/{project_id}/tables/{table_id}/extract`
- [Extract into table (SSE stream)](https://anyrow.ai/docs/api/extract/table-stream.md): `POST /v1/projects/{project_id}/tables/{table_id}/extract-stream`

## Extract data from text or file (JSON response)

`POST /v1/projects/{project_id}/extract`

Authentication: `Authorization: ApiKey {your_api_key}`.

### Path parameters

- `project_id` (string, required)

### Request body

Content type: `multipart/form-data` or `application/x-www-form-urlencoded` (required).

- `columns` (string, optional)
- `file` (string, optional)
- `instruction` (string, optional): Up to 1000000 characters.
- `schema` (string, optional)
- `strictness` (string, optional): One of `strict`, `balanced`, `flexible`.
- `text` (string, optional): Up to 1000000 characters.

### Returns

200 `application/json`.

- `batch_id` (string, optional)
- `confidence` (number, required, nullable)
- `credits` (integer, required): At least 0.
- `duration_ms` (number, required, nullable)
- `fail_count` (number, required)
- `file_type` (string, optional, nullable): One of `text_pdf`, `scanned`, `image`, `text`, `document`, `unknown`.
- `files` (array of objects, required)
  - `confidence` (number, optional, nullable)
  - `error` (any, optional, nullable)
  - `file_name` (any, optional, nullable)
  - `rows` (number, optional, nullable)
  - `status` (string, optional)
- `result` (object, optional)
- `status` (string, required)
- `success_count` (number, required)
- `table_id` (string, required)
- `total_rows` (number, required)

### Errors

- 404: `not_found`

Errors every endpoint can return: [Errors](https://anyrow.ai/docs/api/errors.md).

### Request

```ts title="Node.js"
import { AnyrowSDK } from "@anyrow/sdk"

const anyrow = new AnyrowSDK({
  baseURL: "https://api.anyrow.ai",
  headers: { Authorization: `ApiKey ${process.env.ANYROW_API_KEY}` },
})

const { data, error } = await anyrow.extract.once({
  params: {
    project_id: "{project_id}"
  },
  form: {
    columns: "string",
    file: "<file>",
    instruction: "string",
    schema: "string",
    strictness: "strict",
    text: "string"
  },
})
```

```bash title="cURL"
curl -X POST 'https://api.anyrow.ai/v1/projects/{project_id}/extract' \
  -H 'Authorization: ApiKey {your_api_key}' \
  -F 'columns=string' \
  -F 'file=@./document.pdf' \
  -F 'instruction=string' \
  -F 'schema=string' \
  -F 'strictness=strict' \
  -F 'text=string'
```

```js title="JavaScript"
import { openAsBlob } from "node:fs"

const body = new FormData()
body.append("columns", "string")
body.append("file", await openAsBlob("./document.pdf"))
body.append("instruction", "string")
body.append("schema", "string")
body.append("strictness", "strict")
body.append("text", "string")

const response = await fetch("https://api.anyrow.ai/v1/projects/{project_id}/extract", {
  method: "POST",
  headers: {
    Authorization: "ApiKey {your_api_key}",
  },
  body,
})
const data = await response.json()
```

```python title="Python"
import requests

response = requests.post(
    "https://api.anyrow.ai/v1/projects/{project_id}/extract",
    headers={
        "Authorization": "ApiKey {your_api_key}",
    },
    data={
        "columns": "string",
        "instruction": "string",
        "schema": "string",
        "strictness": "strict",
        "text": "string",
    },
    files={"file": open("./document.pdf", "rb")},
)
print(response.json())
```

### Response

```json title="200"
{
  "batch_id": "string",
  "confidence": 0,
  "credits": 0,
  "duration_ms": 0,
  "fail_count": 0,
  "file_type": "text_pdf",
  "files": [
    {
      "confidence": 0,
      "error": null,
      "file_name": null,
      "rows": 0,
      "status": "string"
    }
  ],
  "result": {},
  "status": "string",
  "success_count": 0,
  "table_id": "string",
  "total_rows": 0
}
```

## Extract data from text or file (SSE stream)

`POST /v1/projects/{project_id}/extract-stream`

Authentication: `Authorization: ApiKey {your_api_key}`.

### Path parameters

- `project_id` (string, required)

### Request body

Content type: `multipart/form-data` or `application/x-www-form-urlencoded` (required).

- `columns` (string, optional)
- `file` (string, optional)
- `instruction` (string, optional): Up to 1000000 characters.
- `schema` (string, optional)
- `strictness` (string, optional): One of `strict`, `balanced`, `flexible`.
- `text` (string, optional): Up to 1000000 characters.

### Returns

200 `text/event-stream`.

### Errors

- 404: `not_found`

Errors every endpoint can return: [Errors](https://anyrow.ai/docs/api/errors.md).

### Request

```ts title="Node.js"
import { AnyrowSDK } from "@anyrow/sdk"

const anyrow = new AnyrowSDK({
  baseURL: "https://api.anyrow.ai",
  headers: { Authorization: `ApiKey ${process.env.ANYROW_API_KEY}` },
})

const { data, error } = await anyrow.extract.stream({
  params: {
    project_id: "{project_id}"
  },
  form: {
    columns: "string",
    file: "<file>",
    instruction: "string",
    schema: "string",
    strictness: "strict",
    text: "string"
  },
})
```

```bash title="cURL"
curl -X POST 'https://api.anyrow.ai/v1/projects/{project_id}/extract-stream' \
  -H 'Authorization: ApiKey {your_api_key}' \
  -F 'columns=string' \
  -F 'file=@./document.pdf' \
  -F 'instruction=string' \
  -F 'schema=string' \
  -F 'strictness=strict' \
  -F 'text=string'
```

```js title="JavaScript"
import { openAsBlob } from "node:fs"

const body = new FormData()
body.append("columns", "string")
body.append("file", await openAsBlob("./document.pdf"))
body.append("instruction", "string")
body.append("schema", "string")
body.append("strictness", "strict")
body.append("text", "string")

const response = await fetch("https://api.anyrow.ai/v1/projects/{project_id}/extract-stream", {
  method: "POST",
  headers: {
    Authorization: "ApiKey {your_api_key}",
  },
  body,
})
const data = await response.text()
```

```python title="Python"
import requests

response = requests.post(
    "https://api.anyrow.ai/v1/projects/{project_id}/extract-stream",
    headers={
        "Authorization": "ApiKey {your_api_key}",
    },
    data={
        "columns": "string",
        "instruction": "string",
        "schema": "string",
        "strictness": "strict",
        "text": "string",
    },
    files={"file": open("./document.pdf", "rb")},
)
print(response.text)
```

### Response

```text title="200"
string
```

## Extract into table (JSON response)

`POST /v1/projects/{project_id}/tables/{table_id}/extract`

Authentication: `Authorization: ApiKey {your_api_key}`.

### Path parameters

- `project_id` (string, required)
- `table_id` (string, required)

### Request body

Content type: `multipart/form-data` or `application/x-www-form-urlencoded` (required).

- `file` (string, optional)
- `text` (string, optional): Up to 1000000 characters.

### Returns

200 `application/json`.

- `batch_id` (string, optional)
- `confidence` (number, required, nullable)
- `credits` (integer, required): At least 0.
- `duration_ms` (number, required, nullable)
- `fail_count` (number, required)
- `file_type` (string, optional, nullable): One of `text_pdf`, `scanned`, `image`, `text`, `document`, `unknown`.
- `files` (array of objects, required)
  - `confidence` (number, optional, nullable)
  - `error` (any, optional, nullable)
  - `file_name` (any, optional, nullable)
  - `rows` (number, optional, nullable)
  - `status` (string, optional)
- `result` (object, optional)
- `status` (string, required)
- `success_count` (number, required)
- `table_id` (string, required)
- `total_rows` (number, required)

### Errors

- 404: `not_found`, `table_not_found`

Errors every endpoint can return: [Errors](https://anyrow.ai/docs/api/errors.md).

### Request

```ts title="Node.js"
import { AnyrowSDK } from "@anyrow/sdk"

const anyrow = new AnyrowSDK({
  baseURL: "https://api.anyrow.ai",
  headers: { Authorization: `ApiKey ${process.env.ANYROW_API_KEY}` },
})

const { data, error } = await anyrow.extract.table.once({
  params: {
    project_id: "{project_id}",
    table_id: "{table_id}"
  },
  form: {
    file: "<file>",
    text: "string"
  },
})
```

```bash title="cURL"
curl -X POST 'https://api.anyrow.ai/v1/projects/{project_id}/tables/{table_id}/extract' \
  -H 'Authorization: ApiKey {your_api_key}' \
  -F 'file=@./document.pdf' \
  -F 'text=string'
```

```js title="JavaScript"
import { openAsBlob } from "node:fs"

const body = new FormData()
body.append("file", await openAsBlob("./document.pdf"))
body.append("text", "string")

const response = await fetch("https://api.anyrow.ai/v1/projects/{project_id}/tables/{table_id}/extract", {
  method: "POST",
  headers: {
    Authorization: "ApiKey {your_api_key}",
  },
  body,
})
const data = await response.json()
```

```python title="Python"
import requests

response = requests.post(
    "https://api.anyrow.ai/v1/projects/{project_id}/tables/{table_id}/extract",
    headers={
        "Authorization": "ApiKey {your_api_key}",
    },
    data={
        "text": "string",
    },
    files={"file": open("./document.pdf", "rb")},
)
print(response.json())
```

### Response

```json title="200"
{
  "batch_id": "string",
  "confidence": 0,
  "credits": 0,
  "duration_ms": 0,
  "fail_count": 0,
  "file_type": "text_pdf",
  "files": [
    {
      "confidence": 0,
      "error": null,
      "file_name": null,
      "rows": 0,
      "status": "string"
    }
  ],
  "result": {},
  "status": "string",
  "success_count": 0,
  "table_id": "string",
  "total_rows": 0
}
```

## Extract into table (SSE stream)

`POST /v1/projects/{project_id}/tables/{table_id}/extract-stream`

Authentication: `Authorization: ApiKey {your_api_key}`.

### Path parameters

- `project_id` (string, required)
- `table_id` (string, required)

### Request body

Content type: `multipart/form-data` or `application/x-www-form-urlencoded` (required).

- `file` (string, optional)
- `text` (string, optional): Up to 1000000 characters.

### Returns

200 `text/event-stream`.

### Errors

- 404: `not_found`, `table_not_found`

Errors every endpoint can return: [Errors](https://anyrow.ai/docs/api/errors.md).

### Request

```ts title="Node.js"
import { AnyrowSDK } from "@anyrow/sdk"

const anyrow = new AnyrowSDK({
  baseURL: "https://api.anyrow.ai",
  headers: { Authorization: `ApiKey ${process.env.ANYROW_API_KEY}` },
})

const { data, error } = await anyrow.extract.table.stream({
  params: {
    project_id: "{project_id}",
    table_id: "{table_id}"
  },
  form: {
    file: "<file>",
    text: "string"
  },
})
```

```bash title="cURL"
curl -X POST 'https://api.anyrow.ai/v1/projects/{project_id}/tables/{table_id}/extract-stream' \
  -H 'Authorization: ApiKey {your_api_key}' \
  -F 'file=@./document.pdf' \
  -F 'text=string'
```

```js title="JavaScript"
import { openAsBlob } from "node:fs"

const body = new FormData()
body.append("file", await openAsBlob("./document.pdf"))
body.append("text", "string")

const response = await fetch("https://api.anyrow.ai/v1/projects/{project_id}/tables/{table_id}/extract-stream", {
  method: "POST",
  headers: {
    Authorization: "ApiKey {your_api_key}",
  },
  body,
})
const data = await response.text()
```

```python title="Python"
import requests

response = requests.post(
    "https://api.anyrow.ai/v1/projects/{project_id}/tables/{table_id}/extract-stream",
    headers={
        "Authorization": "ApiKey {your_api_key}",
    },
    data={
        "text": "string",
    },
    files={"file": open("./document.pdf", "rb")},
)
print(response.text)
```

### Response

```text title="200"
string
```
