Swap APIs & SDKs

A price quote is not always a transaction payload

Identify whether a response is an indicative price, a route for encoding, an executable transaction or a signed order.

Ask what the response authorizes the application to do. A price can populate a comparison table. A route describes how funds might move. A transaction contains the call a wallet can submit. A signable order belongs to another execution path entirely.

Use a discriminated response model

A useful application model has separate variants such as indicative, needsBuild, transaction and order. Each variant exposes only the actions it supports. This is a proposed client design, not a standardized provider schema.

VariantPermitted next actionMissing evidence
Indicative priceDisplay estimateExecutable call
Route descriptionRequest encodingFinal recipient-bound payload
TransactionValidate and simulateWallet consent and receipt
OrderValidate signing requestSignature, acceptance and fill

0x separates indicative price from firm quote. PancakeSwap distinguishes an agg route from a pcsx signable order. Both examples demonstrate why a single optional calldata field is an inadequate execution contract.

Handle missing payloads deliberately

Do not enable a wallet button merely because outputAmount exists. Require the fields for the selected variant, check their units and bind them to the input request. If a build call fails, preserve the displayed estimate with an explicit unavailable-execution state rather than fabricating a transaction from route details.

During an adapter migration, save response fixtures for every variant. A fixture containing an excellent price but no transaction should never reach sendTransaction. A new unknown execution type should stop at the adapter boundary until its lifecycle is implemented.

Sources & verification (2)

Source-check date is recorded in the article details. URLs are provided for manual verification. Use Copy to keep this page open.

  1. Get Started with Swap API

    AllowanceHolder sequence, request parameters and transaction payload

    https://docs.0x.org/docs/introduction/quickstart/swap-tokens-with-0x-swap-api
  2. Response payloads

    Candidate response shapes

    https://developer.pancakeswap.finance/contracts/unified-swap-api/payloads

Continue reading

Swap API integration: quote, approve, simulate, submit