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, that pins /v2/build to these numbers.
mode |
Send | Get back |
|---|---|---|
exact_input (default) |
srcAmount |
receive.amount, what the depositor gets |
exact_output |
outcomeAmount |
spend.amount, the smallest deposit that reaches it |
Send exactly the amount mode names: both, neither, or the other one is a 400.
A 200 means the size is fillable now. In exact_input, too small is a 400 carrying detail.minSrcAmount.
In exact_output, inspect spend.amount: the required deposit includes fees even for a small requested outcome.
Too large is a 409 carrying
maxSrcAmount (exact_input) or maxOutcomeAmount (exact_output). 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
42161Source spoke-token address. TRON accepts base58 or hex41.
Example
0xaf88d065e77c8cC2239327C5EDb3A432268e5831Destination spoke chain id.
Example
8453Destination spoke-token address. TRON accepts base58 or hex41.
Example
0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913Which side you fix: exact_input sends srcAmount, exact_output sends outcomeAmount.
Example
exact_inputWhat the depositor spends, in source base units. Required when mode is exact_input; rejected otherwise.
Example
100000000What the depositor should receive, in destination base units. Required when mode is exact_output; rejected otherwise.
Responses
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 receives if the order fills completely, 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.
object
The solver’s rate, 1e18-scaled: 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.
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" }, "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", "signature": "0x60ce0a47bc64e07a5437de5fd4e6008bce46756d4d7c971710283924888b2a137a91ed09461b5848bb2b7341f5c258da3f97853e73662275f047e0c3c20882211b" } }}Invalid query (ValidationError), an unsupported token, or an exact_input 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.
Largest output that would quote, in destination 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.
Largest output that would quote, in destination 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.
Largest output that would quote, in destination 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.
Largest output that would quote, in destination 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 or detail.maxOutcomeAmount.
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.
Largest output that would quote, in destination 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.
Largest output that would quote, in destination 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.