PDF to text

$0.01 per call · USDC via x402 · POST /api/pdf

Fetch a PDF from a URL and extract its text content. Send POST /api/pdf with the required field url and pay $0.01 per call over x402 or MPP (there is no free tier). It returns a JSON object with url, pages, info, wordCount and text.

Returns page count, document info, and the full text (up to 20MB PDFs).

Category: Web & documents · Tags: pdf documents text-extraction

TRY IN PLAYGROUND →

Parameters

NameTypeRequiredDescription
urlstringyesPublic http(s) URL of a PDF Also accepted as link, uri, href, page.

Example request

curl -i -X POST https://agent402.tools/api/pdf \
  -H "Content-Type: application/json" \
  -d '{"url":"https://agent402.tools/fixtures/sample-invoice.pdf"}'

Without payment this returns HTTP 402 Payment Required with the exact price for pdf; any x402 v2 or MPP client pays it and retries.

Example response

{
  "url": "https://agent402.tools/fixtures/sample-invoice.pdf",
  "pages": 1,
  "info": {
    "title": null
  },
  "wordCount": 13,
  "text": "Agent402 sample invoice. Invoice 402-0001. Total 12.34 USD.\n…"
}
FieldTypeAlways presentIn the example
urlstringyeshttps://agent402.tools/fixtures/sample-invoice.pdf
pagesnumberyes1
infoobjectyes1 field: title
wordCountnumberyes13
textstringyesAgent402 sample invoice. Invoice 402-0001. Total 12.34 USD. …

From an MCP client

catalog.call {
  "slug": "pdf",
  "params": {
    "url": "https://agent402.tools/fixtures/sample-invoice.pdf"
  }
}

The hosted connector at https://agent402.tools/mcp needs a payment for pdf; the stdio package pays it from a wallet or from AGENT402_CREDITS_KEY. Local install: npx -y agent402-mcp.

Errors and behavior

Paid call (JavaScript agent)

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

const client = new x402Client();
client.setSpendControls?.(false); // keep your own spending ceiling in code
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agent402.tools/api/pdf", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "url": "https://agent402.tools/fixtures/sample-invoice.pdf"
  }),
});

Related tools

Summarize a PDF

$0.030 · POST /api/pdf-summarize

Fetch a PDF from a URL, extract its text, and return a concise AI-generated summary - factual, no information added beyo…

Images to PDF

$0.004 · POST /api/images-to-pdf

Combine PNG/JPEG images into a single PDF, one image per page. Body: {"urls":["https://…/1.png","https://…/2.jpg"]}. Ret…

Extract / split PDF pages

$0.003 · POST /api/pdf-extract-pages

Pull a subset of pages into a new PDF (split). Body: {"url":"https://…/file.pdf","pages":"1-3,5"}. Returns the new PDF a…

PDF info

$0.001 · POST /api/pdf-info

Inspect a PDF without downloading the whole thing into your model: page count, title, author, subject, creator, producer…

Merge PDFs

$0.004 · POST /api/pdf-merge

Combine several PDFs into one, in order. Body: {"urls":["https://…/a.pdf","https://…/b.pdf"]}. Returns the merged PDF as…

Rotate PDF

$0.003 · POST /api/pdf-rotate

Rotate pages by 90/180/270°. Body: {"url":"https://…/file.pdf","degrees":90,"pages":"1-3"?}. Omit "pages" to rotate all.…