Execute a token swap
Changed onGet executable transactions for token-to-token swaps. Supports same-chain and cross-chain swaps with multiple from/to assets.
Request
- Base URLhttps://api.opensea.io
- AuthAPI key in header x-api-key
- TypeScriptA function with typed inputs. Its response is checked against the schema.
Request body
Example request
{
"address": "0x1234567890abcdef1234567890abcdef12345678",
"from_assets": [
{
"amount": "1000000000000000000",
"chain": "ethereum",
"contract": "0x0000000000000000000000000000000000000000"
}
],
"slippage_tolerance": 0.01,
"to_assets": [
{
"amount": "1000000000000000000",
"chain": "ethereum",
"contract": "0x0000000000000000000000000000000000000000"
}
]
}Response
Swap execution data retrieved successfully
Example response
{
"quote": {
"costs": [
{
"type": "GAS",
"usd": "0.5"
}
],
"estimated_duration_ms": 30000,
"marketplace_fee_bps": 50,
"price_impact": {
"percent": "-0.08",
"usd": "-1.5"
},
"recommended_slippage": 2,
"refresh_after_ms": 2000,
"route_errors": [
{
"type": "INSUFFICIENT_FUNDS"
}
],
"slippage_tolerance": 0.01,
"swap_provider": "RELAY",
"total_cost_usd": 1869,
"total_price_usd": 1850.5
},
"transactions": [
{
"chain": "ethereum",
"svm": {
"instructions": [
{
"accounts": [
{
"pubkey": "So11111111111111111111111111111111111111112"
}
],
"data": "01020304",
"program_id": "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"
}
],
"transaction_config": {
"compute_unit_limit": 200000,
"priority_fee_lamports": "5000"
}
}
}
]
}Changes
- breaking
the response property
/became nullable for the status - breaking
the response property
/became nullable for the status - breaking
the response property
//became nullable for the status - breaking
the response property
//became nullable for the status - breaking
the response property
//became nullable for the status - breaking
the
/response's property type changed fromobjectto no type for status - breaking
removed the required property
//from the response with the status - breaking
removed the required property
//from the response with the status - warning
added the new
EXECUTIONenum value to the///response property for the response status - info
the request property
became nullable - info
the request property
became nullable - info
added the media type
*/*for the response with the status - info
added the optional property
to the response with the status - info
added the optional property
to the response with the status - info
added the optional property
to the response with the status - info
added the optional property
to the response with the status - info
added the optional property
/to the response with the status - info
added the optional property
//to the response with the status - info
added the optional property
//to the response with the status - info
added
subschema #2to the/response propertyanyOflist for the response status
- breaking