Stream quotes (SSE)
Endpoint Details
Streaming Quotes
Stream quote results in real-time as each protocol responds via Server-Sent Events
GET
Stream quotes (SSE)
Overview
The streaming-quotes endpoint emits Server-Sent Events as each protocol returns a quote, instead of waiting for all protocols to complete. Use this for snappy UI — display the first quote in ~200ms instead of waiting 5+ seconds for the slowest aggregator. For a hands-on walkthrough see the Streaming Quotes guide.Endpoint
Request
Authentication
EventSource cannot set custom headers reliably, so authentication accepts both styles:| Method | Example |
|---|---|
Api-Key header | Api-Key: YOUR_API_KEY (preferred when possible) |
api_key query parameter | ?api_key=YOUR_API_KEY |
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
from_asset | string | Yes | Source asset in CHAIN.SYMBOL-ADDRESS format |
to_asset | string | Yes | Destination asset in CHAIN.SYMBOL-ADDRESS format |
amount | string | Yes | Amount in source-asset base units (wei, sats, etc.) |
origin | string | No | Source wallet address (improves quote accuracy) |
destination | string | No | Destination wallet address |
streaming_interval | number | No | THORChain/MAYAChain streaming interval (default 1) |
streaming_quantity | number | No | THORChain/MAYAChain streaming sub-swap count |
api_key | string | No | Alternative to Api-Key header (see above) |
Response
Headers
Event Sequence
Events are sent asdata: <json>\n\n chunks (legacy SSE format — no named event: fields).
| Order | Event payload type | Description |
|---|---|---|
| 1 | init | Stream opened, includes quote_id and total protocols being queried |
| 2..N | quote | One per protocol that returns a valid quote |
| N+1 | final | Aggregated, sorted, deduplicated payload (after all settle) |
| N+2 | finished | Stream closing |
error event is sent in place of final.
Event Payloads
- init
- quote
- final
- error
- finished
Quote Object Fields (in final event)
| Field | Description |
|---|---|
expectedAmountOutNum | Numeric expected output (for sorting) |
totalFeesUsd | Total combined fees in USD |
totalSwapSeconds | Estimated time-to-settle |
flags | Tags like FASTEST, CHEAPEST, BEST_OUTPUT |
Timeouts
- Total budget: 8 seconds. Protocols that haven’t responded by then are dropped.
- Per-protocol circuit breaker: 5 seconds. Protocols that fail repeatedly are skipped.
Examples
Browser (EventSource)
Server (fetch)
Errors
| Status | Code | Description |
|---|---|---|
400 | BAD_REQUEST | Missing or malformed from_asset, to_asset, or amount |
400 | INVALID_ASSET_FORMAT | Asset string not in CHAIN.SYMBOL-ADDRESS format |
401 | INVALID_API_KEY | Missing or invalid API key |
UNABLE_TO_RETRIEVE_QUOTES error is delivered inside the SSE stream as a type: "error" event, not as an HTTP error.
See the error codes catalog for the full list.Authorizations
Demo API-Key (Sandbox): 7037d2b3-9c76-4f62-b730-c544f7570fa4
Query Parameters
Input asset identifier.
Output asset identifier.
From wallet address.
To wallet address.
Amount to swap.
Alternative to Api-Key header (useful for EventSource which cannot set headers).
Response
Server-Sent Events stream. Events are sent as data: {json}\n\n format.
SSE stream with events: init, quote (per protocol), final (sorted), finished.