| stream_from_api | R Documentation |
Makes a streaming POST request and processes Server-Sent Events (SSE) using httr2. Implements robust error recovery for malformed SSE data.
stream_from_api(
url,
headers,
body,
callback,
max_retries = 5,
initial_delay_ms = 2000,
backoff_factor = 2,
timeout_seconds = NULL,
total_timeout_seconds = NULL,
first_byte_timeout_seconds = NULL,
connect_timeout_seconds = NULL,
idle_timeout_seconds = NULL
)
url |
The API endpoint URL. |
headers |
A named list of HTTP headers. |
body |
The request body (will be converted to JSON). |
callback |
A function called for each parsed SSE data chunk. |
max_retries |
Maximum number of connection/first-event retries before any stream chunk has been delivered (default: 5). |
initial_delay_ms |
Initial delay in milliseconds (default: 2000). |
backoff_factor |
Multiplier for delay on each retry (default: 2). |
timeout_seconds |
Legacy alias for |
total_timeout_seconds |
Optional total stream timeout in seconds.
Defaults to |
first_byte_timeout_seconds |
Optional time-to-first-byte timeout in
seconds. Defaults to |
connect_timeout_seconds |
Optional connection-establishment timeout in
seconds. Defaults to |
idle_timeout_seconds |
Optional stall timeout in seconds. Streams
default to |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.