Swap APIs & SDKs

Read a PancakeSwap Unified Swap API candidate

Interpret the PancakeSwap Unified Swap best candidate without confusing normalized comparison fields with its executable artifact.

The Unified Swap response's best field identifies a candidate, not a universal transaction object. Determine whether it contains agg or pcsx before choosing the next operation.

The endpoint reference describes candidates and best, with quote identity and expiry on each candidate. The payload reference explains that the underlying route or order carries the execution-specific meaning.

Read in a deliberate order

  1. Match chain, input context and recipient with the request.
  2. Check candidate expiry and amount units.
  3. Identify the engine from its payload.
  4. Render normalized amounts for comparison.
  5. Pass the intact engine artifact to its supported execution path.

Do not reconstruct a candidate from the few fields visible in a comparison card. An amount rounded for display is not a replacement for its integer-string source, and a gateway quote ID should not be confused with a nested engine identifier.

Optional means optional

Gas and impact information may be absent for an engine. Keep the absence explicit rather than replacing it with zero. Likewise, asking for inline calldata does not guarantee every winning candidate can supply it. A signed order uses a different process.

Keep a provider-specific validated type behind the UI. An exhaustive branch should reject an unknown or ambiguous engine rather than guessing from whether a hex-looking string happens to exist.

A useful fixture pair

Use one aggregator winner and one X winner with the same visible token pair. The first should lead toward transaction building and simulation; the second should lead toward typed-data validation and order submission. If both reach sendTransaction directly, the adapter has erased the API's central distinction.

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. Endpoints

    Quote, calldata, submit and status contracts

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

    Candidate response shapes

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

Continue reading

Swap API integration: quote, approve, simulate, submit