agentsvc.io

services / table-extract

textoperational · 179 ms

Table Extractor (PDF and web page tables to rows)

Extract tables from a PDF or a web page as clean rows and columns: send a URL (HTML page or PDF), pdf_base64 or raw html. Returns every data table with header, rows, n_rows and n_cols, plus page number (PDF) or caption (HTML); format csv or markdown adds a ready-to-use string per table. Merged cells (colspan/rowspan) are filled in, navigation and layout tables are skipped. PDFs: ruled tables first, then tables aligned by text only (strategy auto, lattice or stream). Runs on agentsvc.io with pdfplumber, nothing is stored. Ideal for financial statements, price lists, reports, Wikipedia lists and invoices. Scanned PDFs need ocr first. Not charged on bad input.

Run free trial ↗1 free call per day with the example input. Paid: $0.008 USDC, no limit.

Call it

import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.EVM_PRIVATE_KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agentsvc.io/api/v1/proxy/table-extract", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({"url":"https://agentsvc.io/samples/sales-report.pdf"}),
});
const { data, payment } = await res.json();  // payment.status "settling"; header X-Payment-Settle: sync returns payment.transaction

Input

FieldTypeDescription
urlstringPublic http(s) URL of a web page or PDF
pdf_base64stringOr a PDF as base64 (max 10 MB)
htmlstringOr raw HTML
formatjson | csv | markdown = "json"json: header + rows only; csv or markdown also returns each table as a string
strategyauto | lattice | stream = "auto"PDF only: lattice = tables with ruling lines, stream = aligned text without lines, auto tries lattice then stream
max_pagesinteger = 20PDF pages to scan
max_tablesinteger = 20
max_rowsinteger = 500Rows kept per table

Output

FieldTypeDescription
sourcestring
kindstring
table_countinteger
tablesarray
pages_scannedinteger
strategy_usedstring
took_msinteger

Example response (data)

{
  "source": "https://agentsvc.io/samples/sales-report.pdf",
  "kind": "pdf",
  "table_count": 2,
  "tables": [
    {
      "page": 1,
      "header": [
        "Region",
        "Q1",
        "Q2",
        "Q3"
      ],
      "rows": [
        [
          "Europe",
          "1,120",
          "1,180",
          "1,200"
        ],
        [
          "North America",
          "2,210",
          "2,330",
          "2,450"
        ],
        [
          "Asia Pacific",
          "860",
          "910",
          "980"
        ]
      ],
      "n_rows": 3,
      "n_cols": 4,
      "truncated": false
    },
    {
      "page": 1,
      "header": [
        "Team",
        "People",
        "Open roles"
      ],
      "rows": [
        [
          "Engineering",
          "42",
          "5"
        ],
        [
          "Sales",
          "18",
          "3"
        ]
      ],
      "n_rows": 2,
      "n_cols": 3,
      "truncated": false
    }
  ],
  "pages_scanned": 1,
  "strategy_used": "lattice",
  "took_ms": 412
}