{"uid":"cap_vKSTqaEE4J0ELjsCXiY7Z","slug":"fetchweb-extract-and-optimize-d13fcb17","name":"FetchWeb Extract and Optimize","description":"Fetch a URL and return context already fitted to your token budget, with token counts and an omission manifest.","url":"https://fetchweb.net/api/public/extract-and-optimize?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method"],"properties":{"type":{"type":"string","const":"http"},"method":{"enum":["GET"],"type":"string"},"headers":{"type":"object","additionalProperties":{"type":"string"}},"queryParams":{"type":"object","required":["url"],"properties":{"url":{"type":"string"},"query":{"type":"string"},"max_tokens":{"type":"number","default":2000},"preserve_code":{"type":"boolean","default":true},"preserve_links":{"type":"boolean","default":true},"preserve_tables":{"type":"boolean","default":true}}}}},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object","properties":{"report":{"type":"object","properties":{"tokensIn":{"type":"number"},"estimated":{"type":"boolean"},"tokensOut":{"type":"number"},"tokensSaved":{"type":"number"},"budgetTokens":{"type":"number"},"reductionPercent":{"type":"number"}}},"charged":{"type":"boolean"},"content":{"type":"string"},"outline":{"type":"array"},"omissions":{"type":"array"}}}}}}},"responseSchema":{"type":"object","properties":{"report":{"type":"object","properties":{"tokensIn":{"type":"number"},"estimated":{"type":"boolean"},"tokensOut":{"type":"number"},"tokensSaved":{"type":"number"},"budgetTokens":{"type":"number"},"reductionPercent":{"type":"number"}}},"charged":{"type":"boolean"},"content":{"type":"string"},"outline":{"type":"array"},"omissions":{"type":"array"}}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.004","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.004/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.004","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.004","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_dnIMdSPtik1a8uPBdRttv","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.004","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Fetches a URL, extracts its content, and trims it to fit a specified token budget while reporting what was omitted and how many tokens were saved.","exampleAgentPrompt":"Fetch https://en.wikipedia.org/wiki/Transformer_(machine_learning_model) and return the content optimized to fit within 3000 tokens, keeping code and tables, and focus on the architecture section.","exampleUseCases":[{"title":"Research digest for LLM pipeline","prompt":"Pull the content from https://arxiv.org/abs/2307.09288 and compress it to 2000 tokens max, preserving any tables — I want to feed it into my next prompt without blowing my context window."},{"title":"Competitive intel from a product page","prompt":"Fetch https://openai.com/pricing and return the page content trimmed to 1500 tokens, keeping all tables intact, with a query focus on pricing tiers so the most relevant info survives the cut."},{"title":"Documentation lookup for an agent","prompt":"Get the content of https://docs.stripe.com/api/charges and optimize it to 2500 tokens so I can pass it to my coding agent — keep the code examples and tell me what got omitted."}],"resultDescription":"Returns a JSON object containing: the optimized page content as a string, a token report (tokens in, tokens out, tokens saved, reduction percent, budget), a page outline, and an omissions array listing what was dropped to meet the token budget. Also includes a charged boolean.","failureModes":["URL is unreachable or returns non-200 status — content field may be empty or error returned","max_tokens set too low to return meaningful content — heavy omissions with minimal output","Page is paywalled or requires JavaScript rendering — extracted content may be incomplete","Token count estimation may be flagged as estimated=true rather than exact","Payment not processed — charged:false and no content returned"],"whenToPreferThis":"Choose this endpoint when you need to fetch a web page and immediately fit it into a tight LLM context window, especially when you care about knowing exactly what was dropped. It is ideal for agentic pipelines that need token-budget-aware web retrieval with an omission manifest, as opposed to raw scraping or simple text extraction endpoints that ignore token limits.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-10T06:34:34.945Z","isFirstParty":false,"canonicalSlug":"fetchweb-extract-and-optimize-d13fcb17"}