Docs📄 DocumentsPDF to Markdown
POST/api/pdf-to-markdown$0.005

📄 PDF to Markdown

Extract and convert PDF content to clean Markdown format. Supports text extraction, heading detection, table preservation, and list formatting. Supply any publicly accessible PDF URL.

Request Body

ParameterTypeRequiredDescriptionDefault
urlstringrequiredPublicly accessible URL of the PDF file

Response Fields

FieldTypeDescription
markdownstringExtracted PDF content as Markdown
pagesnumberNumber of pages in the PDF
word_countnumberApproximate word count

Code Examples

cURL
bash
curl -X POST https://sparkforge.sh/api/pdf-to-markdown \
  -H "Content-Type: application/json" \
  -H "X-PAYMENT: <x402-payment-token>" \
  -d '{"url": "https://example.com/document.pdf"}'
Python
python
import requests

response = requests.post(
    "https://sparkforge.sh/api/pdf-to-markdown",
    headers={"Content-Type": "application/json", "X-PAYMENT": "<token>"},
    json={"url": "https://example.com/document.pdf"}
)

data = response.json()
print(f"Pages: {data['pages']}, Words: {data['word_count']}")
print(data["markdown"][:500])
TypeScript / Node.js
typescript
const res = await fetch402("https://sparkforge.sh/api/pdf-to-markdown", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ url: "https://example.com/document.pdf" }),
});

const { markdown, pages, word_count } = await res.json();

Example Response

json
{
  "markdown": "# Annual Report 2024\n\n## Executive Summary\n\nThis report covers...",
  "pages": 24,
  "word_count": 8432
}

💳 Payment via x402

This endpoint costs $0.005 per call, paid in USDC on Base, Polygon, or Solana. Use the @x402/fetch library to handle payments automatically, or implement the x402 handshake manually.

bash
# Free demo mode (no payment)
curl https://sparkforge.sh/api/pdf-to-markdown?demo=true

# Or try via MCP (Claude Desktop, Cursor, Windsurf)
# Add to mcp config: { "url": "https://sparkforge.sh/api/mcp" }
Previous
Wallet Analysis
Next
HTML to Markdown