Scraping guides
Choose how to read pages, discover URLs and turn matching pages into records.
Visit and raw artifacts#
Request the output you need with include. Markdown preserves readable text and links. For raw HTML, use delivery: "artifact" with include: ["raw"]. Follow results[0].raw.link with your bearer key. The API redirects to a short-lived signed object URL. Send the bearer only to the API host. The manifest includes bytes and sha256.
curl -sS https://api.fetchfox.ai/api/visit \
-H "Authorization: Bearer $FETCHFOX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html","include":["raw"],"delivery":"artifact"}'Crawl within a budget#
Choose a starting URL and a target pattern. * matches within one path segment and ** can cross segments. maxVisits limits fetched pages. At maxDepth: 0 a seed can still yield links. Use priority to favor important paths when the budget is small. Matching URLs appear in results.hits.
curl -sS https://api.fetchfox.ai/api/crawl \
-H "Authorization: Bearer $FETCHFOX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"startUrls":["https://books.toscrape.com/"],"pattern":"https://books.toscrape.com/catalogue/*/index.html","maxVisits":2,"maxDepth":0}'Extract one or many records#
Use perPage: "one" for detail pages and "many" for listings. Use one template and an array of URLs for pages with the same layout. The default extraction path can learn a reusable Boost from successful examples. For Lambda extraction, choose extractExecution: "lambda", an object template and explicit perPage. Use the default model and slim HTML, without pagination or Boost.
curl -sS https://api.fetchfox.ai/api/extract \
-H "Authorization: Bearer $FETCHFOX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"urls":["https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html"],"template":{"title":"Exact book title","price":"Displayed price with currency"},"perPage":"one","extractExecution":"lambda","useBoost":false}'Discover and extract in one job#
Scrape combines the Crawl inputs with an extraction template. Bound both maxVisits and maxExtracts to control the amount of work.
curl -sS https://api.fetchfox.ai/api/scrape \
-H "Authorization: Bearer $FETCHFOX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"startUrls":["https://books.toscrape.com/"],"pattern":"https://books.toscrape.com/catalogue/*/index.html","maxVisits":2,"maxDepth":0,"template":{"title":"Exact book title","price":"Displayed price with currency"},"perPage":"one","maxExtracts":2,"detach":true}'Run or save an agent#
Send a prompt to agent for a one-off task. Use create_agent to save an agent, list_agents to find it, and run_agent to run it again with named inputs.
curl -sS https://api.fetchfox.ai/api/agent \
-H "Authorization: Bearer $FETCHFOX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt":"Read the featured book titles at https://books.toscrape.com/","detach":true}'Poll and export results#
With detach: true, the initial response includes a job ID. Poll GET /api/jobs/{id} using your bearer key. Read state until completed or failed. Get paginated records from /api/jobs/{id}/items or export CSV and JSONL. Use stop_job to request cancellation.
curl -sS https://api.fetchfox.ai/api/jobs/$JOB_ID \
-H "Authorization: Bearer $FETCHFOX_API_KEY"Page loading and proxies#
The default auto mode selects a connection for each visit. Use proxy: "none" for a direct connection to a public page. Page structure and loading behavior can affect completeness and runtime. Test representative pages before a large batch.
Understand cost and runtime#
FetchFox tracks work per job. Inspect metrics.cost.total and the reported operation, network and model breakdowns when present. The balance endpoint reports credit units. One US dollar corresponds to 1,000 credits. Limits on visits, extracts and returned fields help control cost.
curl -sS https://api.fetchfox.ai/api/credits/balance \
-H "Authorization: Bearer $FETCHFOX_API_KEY"