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. SendAccept: text/event-stream and Prefetch tells you each stage as it happens, then sends the same result you would have got as JSON.
/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
200is a stream. A request answered from cache is a stream with only theresultevent. - A failure after the stream has opened arrives as an
errorevent. The HTTP status is already200by then, so readstatusfrom the event.
Reading the stream
The browser’sEventSource 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:
Over MCP
An MCP client that sends aprogressToken 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: noandCache-Control: no-cache, no-transformfor proxies that honour them.