Document streaming quote API with per-network timeout guidance#638
Document streaming quote API with per-network timeout guidance#638squadgazzz wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
Next review available in: 53 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughDocumentation for the CoW Protocol API integration page adds the ChangesAPI Integration Docs
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
fleupold
left a comment
There was a problem hiding this comment.
Generally, for markdown PRs it's suggested to use a single line per sentence, so that updates later create cleaner diffs.
|
|
||
| The client side owns this decision. The stream stays open until the request `timeout` elapses, or every solver has responded, so the value you set determines both how long you wait and which quotes you see. Set `timeout` (milliseconds) on the request, or close the connection yourself once you have a good-enough quote. | ||
|
|
||
| Streaming delivers quotes as they arrive, but it doesn't make any solver respond faster, so it isn't simply a quicker `/quote`. How much a short timeout helps depends on the pair: fast solvers cover liquid pairs in a few hundred milliseconds, while a thinner pair might rely on a single slower solver that a tight timeout would miss. It's worth tuning the value to the pairs you serve. |
There was a problem hiding this comment.
The first sentence is weird. We are marketing it as a faster quote precisely because before the request takes as long as the slowest solver would take, whereas now you can show quotes as soon as the fastest solver responds. So it is a faster version of /quote
There was a problem hiding this comment.
Rephrased a bit.
|
|
||
| `POST /api/v1/quote/stream` takes the same request body as `POST /api/v1/quote` but returns a [Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events) stream instead of one response. Each solver's quote arrives as its own event, so you can show prices as they come in instead of waiting for the slowest solver. | ||
|
|
||
| Each event's `data` is an `OrderQuoteResponse`, the same shape `POST /api/v1/quote` returns, with `id` set to `null`. Solvers without a quote send nothing, so you may receive fewer events than there are solvers. If no solver returns a usable quote, the server sends a final `error` event with a `NoLiquidity` body, then closes. |
There was a problem hiding this comment.
It's weird that we don't return a quote id. How are integrators supposed to use these quotes when placing orders if they don't have an ID?
| "buyToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", | ||
| "sellAmountBeforeFee": "1000000000000000000", | ||
| "kind": "sell", | ||
| "from": "0xYourWalletAddress" |
There was a problem hiding this comment.
Would be useful to add the timeout in the example, as otherwise this behaves like a regular quote, no?
There was a problem hiding this comment.
It doesn't behave as a regular quote in any case. The events are coming as solvers respond.
Description
The new streaming quote endpoint (
POST /api/v1/quote/stream) needs to be covered with docs. Integrators need to know it streams per-solver quotes over SSE, that they control thetimeout, and that it is not simply a faster/quote: on a thin pair that only a slow solver can price, a short timeout drops that quote.Changes
POST /api/v1/quote/streamto the Key Endpoints listSummary by CodeRabbit
Summary by CodeRabbit
POST /api/v1/quote/streamendpoint.