Conventions (v2)
Base URL and paths
Section titled “Base URL and paths”Every endpoint is under https://api.hyperstream.dev/v2/. The rest of these docs write paths as /v2/….
Requests and responses
Section titled “Requests and responses”- Bodies are JSON. Send
Content-Type: application/jsononPOSTrequests. - Quote shortly before you build. A quote’s
buildexpires atbuild.terms.expiresAt. - Every response carries an
x-request-idheader (a UUID). Log it, and include it with theorderIdand the time of the call when you contact Khalani about a request.
Amounts
Section titled “Amounts”Every amount is a decimal string of integer base units. On a 6-decimal token, "10000000" is 10. Request amounts must match ^[1-9]\d*$.
An amount is in the base units of one token on one chain. The same token can have different decimals on different chains, so read decimals from GET /v2/params.
| Fields | Denominated in |
|---|---|
spend.amount, amount, srcAmount, minSrcAmount, maxSrcAmount, srcAmountSpoke, protocolFee, fullFee, refundSource, accruedFee |
The source token |
receive.amount, receive.minAmount, minOutcome, settledOutcome |
The destination token |
depositFee, withdrawFee (in GET /v2/params) |
The listed token itself. Both are relayer gas costs |
A few fields are JSON numbers: chain ids, decimals, seq, operatorBps, commissionBps, orderTtl, and response timestamps (at, deadline). build.terms.expiresAt in a quote is a string of Unix seconds.
Addresses
Section titled “Addresses”- Tokens are identified by chain id and contract address.
- EVM addresses come back checksummed from
/v2/paramsand/v2/quote, and lowercase in orders. Compare them case-insensitively. - Non-EVM addresses come back in the chain’s native form. On TRON that is base58, and the API accepts base58 or hex41.
depositoris an EVM address. Send it lowercase or EIP-55 checksummed. An order from a non-EVM chain has no depositor: leave it out of the build, and the order showsdepositor: null.
Error bodies
Section titled “Error bodies”Errors come in four JSON shapes. Only the first has an error key, so log error ?? message.
| Source | Body |
|---|---|
The route itself (most 4xx/5xx) |
{ "error": string, "detail"?: object } |
| Request validation | { "message": "Validation failed", "name": "ValidationException", "details": [{ "field", "message", "code" }] } |
Malformed JSON, maintenance, unhandled 500 |
{ "message": string, "name": string } |
| Rate limit | { "errorCode": "RATE_LIMITED", "message": string } |
Errors and retries covers what each status means and whether to retry.