Jump to content

Get tables from a document

Every table in a PDF or a photo, as rows and as a CSV file.

Chab finds the tables on each page and returns their rows with the page number. You also get a CSV file you can open in a spreadsheet. A table that goes on to the next page comes back as one table. It works for reports and price lists, and for receipts too.

Paste this into your AI agent

Set up Chab for me: fetch https://www.chab.ai/agent-setup.md?v=497c0f and follow it. Then use Chab to get the balance sheet from pages 5 and 6 of this annual report as a table: https://upload.wikimedia.org/wikipedia/commons/f/f6/Wikimedia_Eesti_financial_statement_2016_%28English%29.pdf

Your agent connects Chab and then runs it. Price: From 1 credit, about 1 credit for one or two pages. The free credits cover a first try. How it works in each app

Full reference for developers
Returns
JSON result and a file
REST endpoint
POST /v1/documents/tables
Over MCP
Call chab_operation_start with "documents.tables"

What you get

Example request

{  "source": {    "type": "url",    "url": "https://upload.wikimedia.org/wikipedia/commons/f/f6/Wikimedia_Eesti_financial_statement_2016_%28English%29.pdf"  },  "first_page": 5,  "max_pages": 2}

Example result

{  "data": {    "result": {      "source": {        "type": "url",        "url": "https://upload.wikimedia.org/wikipedia/commons/f/f6/Wikimedia_Eesti_financial_statement_2016_%28English%29.pdf",        "filename": "Wikimedia_Eesti_financial_statement_2016_(English).pdf",        "format": "pdf",        "byte_size": 47490      },      "page_count": 14,      "first_page": 5,      "pages_read": 2,      "table_count": 2,      "tables": [        {          "index": 1,          "page": 5,          "pages": [5],          "title": "Statement of financial position (In Euros)",          "columns": ["", "31.12.2016", "31.12.2015", "Note"],          "row_count": 21,          "rows": [            ["Assets", "", "", ""],            ["Current assets", "", "", ""],            ["Cash and cash equivalents", "15 397", "4 772", "2"],            ["Receivables and prepayments", "3 759", "8 228", "3"],            ["Total current assets", "19 156", "13 000", ""]          ]        },        {          "index": 2,          "page": 6,          "pages": [6],          "title": "Statement of revenues and expenses (In Euros)",          "columns": ["", "2016", "2015", "Note"],          "row_count": 15,          "rows": [            ["Revenue", "", "", ""],            ["Fees received from members", "189", "275", "7"],            ["Grants and donations", "65 639", "83 457", "8"]          ]        }      ],      "files": [        {          "filename": "Wikimedia_Eesti_financial_statement_2016__English-tables.zip",          "tables": [1, 2],          "contents": ["table-1-page-5.csv", "table-2-page-6.csv"]        }      ],      "failed_pages": [],      "usage": { "input_tokens": 1583, "output_tokens": 764 }    },    "artifacts": [      {        "id": "art_01M7J5733HVSR0NY8VH7ZQ242J",        "type": "zip",        "role": "document_tables",        "mime_type": "application/zip",        "filename": "Wikimedia_Eesti_financial_statement_2016__English-tables.zip",        "download_url": "/v1/operations/op_01M7J56VGK09XT1F1T9RVPAQNN/artifacts/art_01M7J5733HVSR0NY8VH7ZQ242J/download"      }    ],    "warnings": [      {        "code": "partial_results",        "message": "The document has 14 pages; pages 5 to 6 were read. Use first_page and max_pages for the others.",        "field": "pages_read",        "severity": "warning"      }    ],    "result_expires_at": "2026-11-19T12:27:23+00:00"  },  "meta": {    "request_id": "req_123"  }}

Inputs

FieldTypeDetails
sourcerequiredobjectThe document: an uploaded file (file_id), a reusable artifact such as a screenshot (artifact_id), or a public https URL (url). PDF, PNG, JPEG, WebP, TIFF or HEIC.
source.typerequiredstringOne of file_id, artifact_id, url
source.idstringThe fil_ or art_ id, with type file_id or artifact_id.Up to 64 characters
source.urlstringA public https URL of the document, with type url. Chab downloads it (up to your plan's upload size) and checks it for viruses like an upload.Up to 2048 characters
first_pageintegerThe first page to read.Default 1. Min 1
max_pagesintegerMost pages to read from first_page on. Credits are reserved for these pages and the unused part is released. An image is one page.Default 10. Min 1 max 50

How to call it

AI apps use it through hosted MCP. Coding agents can also use the CLI, and your own code can call the API. Each call starts a job, and your agent picks up the result when it is ready.

curl -X POST https://www.chab.ai/v1/documents/tables \  -H "Authorization: Bearer CHAB_API_KEY" \  -H "Content-Type: application/json" \  -H "Idempotency-Key: documents-tables-001" \  -d '{"source":{"type":"url","url":"https://upload.wikimedia.org/wikipedia/commons/f/f6/Wikimedia_Eesti_financial_statement_2016_%28English%29.pdf"},"first_page":5,"max_pages":2}'

Get tables from a document result

{  "data": {    "result": {      "source": {        "type": "url",        "url": "https://upload.wikimedia.org/wikipedia/commons/f/f6/Wikimedia_Eesti_financial_statement_2016_%28English%29.pdf",        "filename": "Wikimedia_Eesti_financial_statement_2016_(English).pdf",        "format": "pdf",        "byte_size": 47490      },      "page_count": 14,      "first_page": 5,      "pages_read": 2,      "table_count": 2,      "tables": [        {          "index": 1,          "page": 5,          "pages": [5],          "title": "Statement of financial position (In Euros)",          "columns": ["", "31.12.2016", "31.12.2015", "Note"],          "row_count": 21,          "rows": [            ["Assets", "", "", ""],            ["Current assets", "", "", ""],            ["Cash and cash equivalents", "15 397", "4 772", "2"],            ["Receivables and prepayments", "3 759", "8 228", "3"],            ["Total current assets", "19 156", "13 000", ""]          ]        },        {          "index": 2,          "page": 6,          "pages": [6],          "title": "Statement of revenues and expenses (In Euros)",          "columns": ["", "2016", "2015", "Note"],          "row_count": 15,          "rows": [            ["Revenue", "", "", ""],            ["Fees received from members", "189", "275", "7"],            ["Grants and donations", "65 639", "83 457", "8"]          ]        }      ],      "files": [        {          "filename": "Wikimedia_Eesti_financial_statement_2016__English-tables.zip",          "tables": [1, 2],          "contents": ["table-1-page-5.csv", "table-2-page-6.csv"]        }      ],      "failed_pages": [],      "usage": { "input_tokens": 1583, "output_tokens": 764 }    },    "artifacts": [      {        "id": "art_01M7J5733HVSR0NY8VH7ZQ242J",        "type": "zip",        "role": "document_tables",        "mime_type": "application/zip",        "filename": "Wikimedia_Eesti_financial_statement_2016__English-tables.zip",        "download_url": "/v1/operations/op_01M7J56VGK09XT1F1T9RVPAQNN/artifacts/art_01M7J5733HVSR0NY8VH7ZQ242J/download"      }    ],    "warnings": [      {        "code": "partial_results",        "message": "The document has 14 pages; pages 5 to 6 were read. Use first_page and max_pages for the others.",        "field": "pages_read",        "severity": "warning"      }    ],    "result_expires_at": "2026-11-19T12:27:23+00:00"  },  "meta": {    "request_id": "req_123"  }}

Price: From 1 credit, about 1 credit for one or two pages. See all prices

Want to try Chab with your agent?

Copy the prompt and paste it into your AI. Your agent starts with free credits and doesn't need an account.

See plans