Streaming
Show results as they are verified instead of waiting for the slowest article.
Set stream: true on POST /v1/search or POST /v1/search/site and the response becomes a stream of
Server-Sent Events. The first results
arrive about a second in, in every mode.
With the SDKs
const stream = ts.searchStream('el dólar', { mode: 'deep' });
for await (const event of stream) {
if (event.type === 'step') console.log('·', event.step.text);
if (event.type === 'partial') render(event.response.results);
if (event.type === 'result') render(event.response.results, { final: true });
}Only need the end? finalResponse() in TypeScript and final_response() in Python consume the stream
and return the result.
Events
| Event | data | When |
|---|---|---|
step | { id, text, status, detail } | A step starts or finishes: judging headlines, reading articles, classifying tone… |
partial | A search response | Results judged so far. Each one is confirmed in place as its article is read. |
result | A search response | The final result. The stream ends after it. |
error | Problem details | Something failed. The stream ends after it. The SDKs throw it as an error. |
Results in a partial keep their position while articles are read, so you can render them straight away
without the list jumping. The final order comes with result.
The raw stream
event: step
data: {"id":"juicio-indice","text":"El modelo lee 160 titulares del índice","status":"running","detail":null}
event: partial
data: {"id":"req_…","object":"search","results":[…]}
event: result
data: {"id":"req_…","object":"search","results":[…]}Step text is meant to be shown to people, is currently written in Spanish and can change; use id and
status in code.