LLM prompt — copy and paste into your coding agent
Migrate my Socket API v2 integration to the Socket Swap V3 API.
Use https://docs.socket.tech/llms-full.txt for full context and follow https://docs.socket.tech/integrate/migration-guide-v2.
The Socket Swap V3 API (/v3/swap) replaces the legacy Socket API (/v2). The new API is simpler — a single quote call returns ready-to-send transaction data. No server-side route sessions, no multi-step build flow.
The base URL also changes:
v2 v3 Base URL https://api.socket.tech/v2https://backend.socket.tech/v3/swap
What changed at a glance
v2 (Legacy) v3 (New) Quote GET /v2/quoteGET /v3/swap/quoteTx data POST /v2/route/start + GET /v2/route/build-next-txIncluded in quote response Status GET /v2/route/prepareGET /v3/swap/statusApproval check GET /v2/approval/check-allowanceroute.approval object in quote responseApproval tx data GET /v2/approval/build-txBuild client-side using route.approval Auth header API-KEYx-api-key + affiliateRoute ID activeRouteIdquoteId
Execution flow
Before (v2):
GET /v2/quote → pick a route
POST /v2/route/start → register the route, get activeRouteId
GET /v2/approval/check-allowance → check if approval needed
GET /v2/approval/build-tx → build approval tx
GET /v2/route/build-next-tx?activeRouteId=... → get tx calldata
Submit the transaction on-chain
GET /v2/route/prepare?activeRouteId=&userTxIndex=&txHash= → report tx hash
Repeat steps 5–7 for multi-tx routes
After (v3):
GET /v3/swap/quote → get routes with txData included
If route.approval is present, approve approval.spenderAddress for approval.amount
Submit route.txData.object on-chain
Poll GET /v3/swap/status?quoteId=... until terminal status
All routes are single-transaction. No server-side session required.
Parameter mapping
v2 v3 API-KEY: <key>x-api-key: <key>— affiliate: <affiliate-id> (required)
Query parameters
v2 param v3 param Notes fromChainIdoriginChainIdtoChainIddestinationChainIdfromTokenAddressinputTokentoTokenAddressoutputTokenfromAmountinputAmountuserAddressuserAddressUnchanged recipientreceiverAddressdefaultBridgeSlippage / defaultSwapSlippageslippageSingle unified slippage param includeDexes / includeBridgesincludeProviderComma-separated excludeDexes / excludeBridgesexcludeProviderComma-separated feePercentfeeBpsUnit change: percent → basis points. 0.5% becomes 50feeTakerAddressfeeTakerAddressUnchanged — userOpsRequired. Use tx for standard routes
singleTxOnly, maxUserTxs, uniqueRoutesPerBridge, disableSwapping,
bridgeWithGas, bridgeWithInsurance, isContractCall, and showAutoRoutes
are not supported in v3.
Approval
In v2 you called two separate endpoints to check and build approval transactions. In v3, the quote response tells you everything you need:
"approval" : {
"spenderAddress" : "0x..." ,
"amount" : "1000000" ,
"tokenAddress" : "0xaf88d065e77c8cc2239327c5edb3a432268e5831" ,
"userAddress" : "0x..."
}
If approval is present, approve spenderAddress for amount of tokenAddress before submitting. If approval is null, no approval is needed.
Status
Before:
GET /v2/route/prepare?activeRouteId=<id>&userTxIndex=<idx>&txHash=<hash>
After:
GET /v3/swap/status?quoteId=<quoteId>
Poll until you see a terminal status:
Status Meaning PENDINGNot yet started IN_PROGRESSSource tx seen, destination pending COMPLETEDDone FAILEDFailed EXPIREDQuote window expired REFUNDEDFunds refunded
Quick example
v2 request:
curl "https://api.socket.tech/v2/quote?fromChainId=42161&toChainId=8453&fromTokenAddress=0xaf88d...&toTokenAddress=0x8335...&fromAmount=1000000&userAddress=0x123...&recipient=0x123...&feePercent=0.5&feeTakerAddress=0xabc..." \
-H "API-KEY: <key>"
v3 equivalent:
curl "https://backend.socket.tech/v3/swap/quote?originChainId=42161&destinationChainId=8453&inputToken=0xaf88d...&outputToken=0x8335...&inputAmount=1000000&userAddress=0x123...&receiverAddress=0x123...&userOps=tx&feeBps=50&feeTakerAddress=0xabc..." \
-H "x-api-key: <key>" \
-H "affiliate: <affiliate-id>"
API Reference Full Socket Swap V3 API reference
Get API Access Request production API credentials