Skip to main content
POST
getSwap

Understanding getSwap

  • getSwap returns a detailed object containing swap information, a price quote, and a complete transaction object to have the user sign for swap execution. It takes:
    • address - string.
    • Swap information object:
      • fromTokenAddress - string.
      • toTokenAddress - string.
      • amount - string.
      • slippage - integer.

Query example

JSON

Authorizations

Authorization
string
header
required

Basic authentication header of the form Basic <encoded-value>, where <encoded-value> is the base64-encoded string username:password.

Body

application/json

Request to execute a token swap.

jsonrpc
string
default:2.0
required

Version of the JSON-RPC protocol, should be 2.0.

Example:

"2.0"

id
integer
default:1
required

The request identifier.

Example:

1

method
enum<string>
required

API method being called.

Available options:
particle_swap_getSwap
params
(string | object)[]
required

Parameters for executing a swap.

User address.

Example:

"0x369aa8a7a7BE683E1a46d9A056806B2B3FD778C8"

chainId
integer

The blockchain chain ID.

Example:

1

Response

200 - application/json

Successful response with swap transaction details.

jsonrpc
string
default:2.0
required

Version of the JSON-RPC protocol, should be 2.0.

Example:

"2.0"

id
integer
default:1
required

The request identifier.

Example:

1

result
object
required

Swap transaction details.

chainId
integer

The blockchain chain ID.

Example:

1