Quote a trade
const url = 'https://api.hyperstream.dev/v2/quote?fromChainId=42161&from=0xaf88d065e77c8cC2239327C5EDb3A432268e5831&toChainId=8453&to=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913&mode=exact_input&srcAmount=100000000';const options = {method: 'GET', headers: {'X-API-Key': '<X-API-Key>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url 'https://api.hyperstream.dev/v2/quote?fromChainId=42161&from=0xaf88d065e77c8cC2239327C5EDb3A432268e5831&toChainId=8453&to=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913&mode=exact_input&srcAmount=100000000' \ --header 'X-API-Key: <X-API-Key>'Prices one direction and size without creating an order. Nothing is stored: build carries a signed attestation, valid
for five minutes (60 seconds on a pair with 50 bps or more of slippage), that pins /v2/build to these numbers.
Send srcAmount, what the depositor spends. You get back receive.amount, what the depositor is expected to get, and
receive.minAmount, the least.
A 200 means the size is fillable now. Too small is a 400 carrying detail.minSrcAmount; too large is a 409
carrying detail.maxSrcAmount. Re-quote at the returned figure.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”Source spoke chain id.
Example
42161Destination spoke chain id.
Example
8453Only exact_input: you fix srcAmount.
Example
exact_inputWhat the depositor spends, in source base units. At most 2^128 - 1.
Example
100000000Responses
Section titled “Responses”Fillable now. Show spend and receive; send build to /v2/build.
A price for one direction and size. A 200 means the amount is fillable now. Nothing is stored.
object
What the depositor sends, in source base units. Includes every fee.
object
Spoke chain id.
Address in the chain’s native display form: EVM 0x hex, TRON base58.
What the depositor is expected to receive if the order fills completely, and the most a fill pays, in destination base units. Truncated, never rounded up.
object
Spoke chain id.
Address in the chain’s native display form: EVM 0x hex, TRON base58.
The least a complete fill pays, enforced on-chain; a partial fill pays at least the same per unit. Equals amount when slippageBps is 0.
The order’s slippage tolerance, in bps.
When true, an order built from this quote cannot be cancelled before its deadline: it settles when it fills or the deadline passes. Always true when either token is on a non-EVM chain.
object
The solver’s rate, 1e18-scaled, less slippageBps: the floor the order enforces. Destination per source unit of the published amount (after fees), not of the deposit. Not a token amount.
The flat fee plus Khalani’s bps, in source base units. Your commission is not included.
The /v2/build request, already assembled. Send it back with depositor (and recipients where required) added.
object
object
Spoke chain id.
Address in the chain’s native display form: EVM 0x hex, TRON base58.
object
Spoke chain id.
Address in the chain’s native display form: EVM 0x hex, TRON base58.
The deposit, in source base units.
The rate the order will publish at, 1e18-scaled.
Attestation that pins /v2/build to this quote. Always send it back.
object
Flat fee in 18-decimal hub units. Signed over, so echo it unchanged.
Unix seconds. The attestation is valid for five minutes, or 60 seconds on a pair with 50 bps or more of slippage.
The slippage the attestation covers, in bps. Echo it unchanged.
Khalani’s EIP-712 attestation over the quoted trade.
Example
{ "spend": { "chainId": 42161, "token": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", "symbol": "USDC", "decimals": 6, "amount": "100000000" }, "receive": { "chainId": 8453, "token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "symbol": "USDC", "decimals": 6, "amount": "99620254", "minAmount": "99620254" }, "slippageBps": 0, "earlyCancelDisabled": false, "details": { "intentOutcomeRate": "999700000000000000", "protocolFee": "329910" }, "build": { "srcToken": { "chainId": 42161, "token": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831" }, "dstToken": { "chainId": 8453, "token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" }, "amount": "100000000", "intentOutcomeRate": "999700000000000000", "terms": { "flatFee": "300000000000000000", "expiresAt": "1787000000", "slippageBps": 0, "signature": "0x60ce0a47bc64e07a5437de5fd4e6008bce46756d4d7c971710283924888b2a137a91ed09461b5848bb2b7341f5c258da3f97853e73662275f047e0c3c20882211b" } }}Invalid query (ValidationError), an unsupported token, or a size below the minimum (Error with detail.minSrcAmount).
The request failed schema validation. Carries message, not error.
object
object
An error raised by the route itself.
object
object
Smallest deposit that would quote, in source base units.
Largest deposit that would quote, in source base units.
The deployment setting this direction needs.
Example
{ "error": "Requested amount is below what the solver will fill", "detail": { "minSrcAmount": "5000000" }}The X-API-Key header is missing.
An error raised by the route itself.
object
object
Smallest deposit that would quote, in source base units.
Largest deposit that would quote, in source base units.
The deployment setting this direction needs.
Example
{ "error": "X-API-Key required"}The key is unknown or past its rotation window, or your integrator registry row is disabled or invalid. A 403 is always about your account: do not retry.
An error raised by the route itself.
object
object
Smallest deposit that would quote, in source base units.
Largest deposit that would quote, in source base units.
The deployment setting this direction needs.
Example
{ "error": "Unknown or inactive integrator"}Source and destination are the same asset.
An error raised by the route itself.
object
object
Smallest deposit that would quote, in source base units.
Largest deposit that would quote, in source base units.
The deployment setting this direction needs.
Example
{ "error": "Source and destination resolve to the same mToken"}Larger than what can be filled now. Re-quote at detail.maxSrcAmount.
An error raised by the route itself.
object
object
Smallest deposit that would quote, in source base units.
Largest deposit that would quote, in source base units.
The deployment setting this direction needs.
Example
{ "error": "Requested amount exceeds what the solver can fill", "detail": { "maxSrcAmount": "250000000000" }}Rate limited per integrator and per IP. No Retry-After; back off and retry.
Rate limited. No Retry-After; back off and retry.
object
Example
{ "errorCode": "RATE_LIMITED", "message": "Too many requests, please retry later"}Unhandled failure. Retry once, then escalate with the x-request-id response header.
Maintenance, a malformed JSON body, or an unhandled failure. Carries message, not error.
object
MaintenanceException (503), BadRequestException (malformed JSON) or InternalErrorException (500).
Example
{ "message": "Internal Error", "name": "InternalErrorException"}Temporarily unavailable: your terms could not be read, a price or fee configuration is missing, or no solver can serve the direction (Error), or the API is in maintenance (NamedError with Retry-After). The variants cannot be told apart reliably, so cap your retries.
An error raised by the route itself.
object
object
Smallest deposit that would quote, in source base units.
Largest deposit that would quote, in source base units.
The deployment setting this direction needs.
Maintenance, a malformed JSON body, or an unhandled failure. Carries message, not error.
object
MaintenanceException (503), BadRequestException (malformed JSON) or InternalErrorException (500).
Example
{ "name": "MaintenanceException", "message": "SystemMaintenance"}Headers
Section titled “Headers”Seconds to wait. Sent only by the maintenance response.