> For the complete documentation index, see [llms.txt](https://hinkal-team.gitbook.io/hinkal/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hinkal-team.gitbook.io/hinkal/hinkal-api/api-reference/get-swap-data.md).

# Get Swap Data

## Get a swap quote and calldata

> Returns the best available swap route, its calldata, and the expected output amount.\
> Works for both EVM and Solana chains — for Solana it returns an OKX quote.\
> \
> Read-only — requires an active session. Pass \`sessionId\` and \`nonce\` as query parameters\
> and include \`x-hinkal-request-signature: secp256k1\_sign(SHA256("GET /get-swap-data\n" + queryString))\`\
> in the headers.<br>

```json
{"openapi":"3.0.3","info":{"title":"Hinkal API","version":"1.0.0"},"tags":[{"name":"Get Swap Data"}],"servers":[{"url":"https://api.hinkal.io","description":"Production"}],"paths":{"/get-swap-data":{"get":{"operationId":"getSwapData","summary":"Get a swap quote and calldata","description":"Returns the best available swap route, its calldata, and the expected output amount.\nWorks for both EVM and Solana chains — for Solana it returns an OKX quote.\n\nRead-only — requires an active session. Pass `sessionId` and `nonce` as query parameters\nand include `x-hinkal-request-signature: secp256k1_sign(SHA256(\"GET /get-swap-data\\n\" + queryString))`\nin the headers.\n","tags":["Get Swap Data"],"parameters":[{"$ref":"#/components/parameters/XHinkalRequestSignature"},{"name":"sessionId","in":"query","required":true,"description":"Session identifier UUID from POST /create-session","schema":{"type":"string","format":"uuid"}},{"name":"nonce","in":"query","required":true,"description":"Per-request UUID. Echoed back in the response.","schema":{"type":"string","format":"uuid"}},{"name":"chainId","in":"query","required":true,"description":"Chain ID (e.g. 10 for Optimism, 501 for Solana mainnet, 728126428 for Tron mainnet)","schema":{"type":"string"}},{"name":"inputTokenAddress","in":"query","required":true,"description":"Token address to swap from","schema":{"type":"string"}},{"name":"outputTokenAddress","in":"query","required":true,"description":"Token address to swap to","schema":{"type":"string"}},{"name":"amount","in":"query","required":true,"description":"Input amount as a decimal string (e.g. \"1.2\" for 1.2 USDC)","schema":{"type":"string"}},{"name":"slippagePercentage","in":"query","required":false,"description":"Maximum allowed slippage as a percentage (e.g. 0.5 for 0.5%)","schema":{"type":"number"}}],"responses":{"200":{"description":"Swap quote","headers":{},"content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"swapData":{"type":"string","description":"Swap calldata to pass to POST /swap"},"externalActionId":{"type":"string","description":"External action id string to pass to POST /swap (e.g. \"Lifi\", \"Okx\")"},"outSwapAmount":{"type":"string","description":"Expected output amount in smallest units"},"nonce":{"type":"string","description":"Echoed per-request `nonce` from the request."}},"required":["success","swapData","externalActionId","outSwapAmount","nonce"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}}},"components":{"parameters":{"XHinkalRequestSignature":{"name":"x-hinkal-request-signature","in":"header","required":true,"schema":{"type":"string"},"description":"Hex-encoded compact secp256k1 signature: `secp256k1_sign(SHA256(binding + \"\\n\" + payload))`, where `binding` is `\"<METHOD> <routePath>\"` (this route's own method and path, e.g. `\"POST /refresh-cache\"` or `\"GET /balance\"`) and `payload` is `JSON.stringify(body)` for POST requests or the raw query string for GET requests. Binding the route into the signed digest stops a signature captured for one endpoint from being replayed against another. See [Authentication](/enclave-api/authentication) for the full signing scheme."}},"responses":{"BadRequest":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FailedResponse"}}}},"Unauthorized":{"description":"Invalid signature or reused nonce","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FailedResponse"}}}},"ServerError":{"description":"Server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FailedResponse"}}}}},"schemas":{"FailedResponse":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"string"}},"required":["success","error"]}}}}
```
