# Markdown Extractor — Agent Guide

## Description

Fetches a public URL and returns clean, token-efficient markdown, paywalled with the x402 v2 protocol on Base Mainnet. Designed for autonomous AI agents to call directly: no API key, no signup — pay per call in USDC.

## Installation

No installation required — this is a plain HTTP endpoint. No SDK, package, API key, or account signup.

## Configuration

There's no client to configure. Per-request options are passed directly as JSON body fields (POST) or query parameters (GET):

- `include_links` (boolean, default `true`): render `<a href>` as markdown `[text](href)` links.
- `strip_images` (boolean, default `false`): drop `<img>` entirely instead of rendering `![alt](src)`.
- `max_chars` (integer, default `50000`, clamped to `[1000, 200000]`): maximum markdown length returned.

No environment variables or headers are required beyond the payment header described under Authentication.

## Usage

1. Call `POST https://markdown-extractor.jannioura.workers.dev/` with a JSON body: `{"url": "https://example.com/article"}`.
   Optional `options`: `include_links` (boolean, default true), `strip_images` (boolean, default false), `max_chars` (integer, clamped to [1000, 200000], default 50000).
   Alternatively, `GET https://markdown-extractor.jannioura.workers.dev/?url=https://example.com/article` performs the identical operation for clients that prefer a plain GET.
2. The first call, with no payment header, returns `402 Payment Required`. The response body and the `PAYMENT-REQUIRED` header both carry an x402 v2 `PaymentRequired` object describing exactly what to pay.
3. Construct and sign an EIP-3009 `TransferWithAuthorization` for the exact amount/asset/payTo given, base64-encode the resulting x402 v2 `PaymentPayload`, and retry the identical request with header `PAYMENT-SIGNATURE: <base64 payload>`.
4. On success you get `200 OK` with `{ title, markdown, source_url, chars, est_tokens, cached, fetched_at }` and a `PAYMENT-RESPONSE` header containing the settlement receipt.

See [https://markdown-extractor.jannioura.workers.dev/openapi.json](https://markdown-extractor.jannioura.workers.dev/openapi.json) for the full machine-readable schema.

## Authentication

There is no API key and no account. Authentication is the payment itself: a valid, signed EIP-3009 transfer authorization for 0.01 USDC (atomic amount `10000`) on Base Mainnet (`eip155:8453`), asset `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`, paid to `0x86256e25d4e5511eb6dcc474a4e779970267e903`. Payments are verified and settled through the facilitator at `https://x402.primer.systems`. See [https://markdown-extractor.jannioura.workers.dev/.well-known/x402](https://markdown-extractor.jannioura.workers.dev/.well-known/x402) for the machine-readable manifest.
