Skip to main content

Overview

A live request takes anywhere from one to thirty seconds: the page has to load in a browser before anything can be read from it. Send Accept: text/event-stream and Prefetch tells you each stage as it happens, then sends the same result you would have got as JSON.
Streaming works on /brand, /enrich, /classify, /company, /screenshot, /styleguide, /scrape (GET and POST), /map and /answers. It costs nothing extra: a streamed request is billed exactly like the same request as JSON.

Events

A progress event’s status is one of: Lines starting with : are keep-alives sent every 15 seconds. Ignore them.

Stages by endpoint

Stage ids are stable; code against them. Labels are written for people and may be reworded, so show them rather than compare them. Stages only move forward. When Prefetch has to retry a site, the current stage stays current until the retry passes it, so a slow stage can mean a site that took some persuading.

What is and isn’t a stream

  • Refused before any work starts (invalid parameters, a missing or bad key, no credits left, a rate or concurrency limit, a busy service): a plain JSON error with its real HTTP status, exactly as without streaming. Check the status before reading the stream.
  • Every 200 is a stream. A request answered from cache is a stream with only the result event.
  • A failure after the stream has opened arrives as an error event. The HTTP status is already 200 by then, so read status from the event.

Reading the stream

The browser’s EventSource cannot send the X-API-Key header, only makes GET requests, and reconnects by itself when a stream ends, which would run (and bill) the request again. Read the response body with fetch instead:
If the connection drops partway through, the request still finishes and is billed. Send it again only if you need the result; a repeat within the cache window is answered from cache.

Over MCP

An MCP client that sends a progressToken with tools/call receives the same stages as notifications/progress. message is the stage’s label, or the detail of an /answers update. progress counts the stages already passed, out of total. Most MCP clients show these on their own; nothing else is needed. See MCP.

Good to know

  • Streaming is not available through RapidAPI: requests made there are answered as JSON whatever they ask for.
  • Through a proxy of your own, turn off response buffering for these requests, or the events arrive together at the end. Prefetch sends X-Accel-Buffering: no and Cache-Control: no-cache, no-transform for proxies that honour them.