Solana Swap Actions API
Subscribe to DEX Swap Actions on Solana with One Single API
Last updated
Subscribe to DEX Swap Actions on Solana with One Single API
Last updated
Listening to Solana transactions and extracting swap actions is a challenging task for developers, as it requires a stable RPC connection and the ability to parse a transaction to understand the swap behavior across multiple DEX protocols. Furthermore, a single transaction can contain multiple swap actions from different DEX pools, adding to the complexity of the task.
BlockSec provides swap action APIs on Solana for developers. Users can subscribe to the WebSocket connection and receive detailed swap actions within a transaction. For example, users can subscribe to smart money accounts to track their swap actions and gain insights into their trading strategies.
Real-Time Data Access: Enables real-time tracking of DEX swap actions, providing immediate updates through WebSocket connections.
Detailed Swap Information: Provides detailed data about individual DEX protocol actions, allowing for in-depth analysis of each swap.
Customizable Subscriptions: Users can subscribe to specific accounts and DEX protocols to tailor the data to their needs.
Support for Multiple DEX Protocols: , ensuring comprehensive data across different decentralized exchanges.
Easy Integration: Seamlessly integrates into user applications, allowing developers to easily track and analyze swap actions.
Scalable and Reliable: Built for scalability, ensuring stable data streams for high-volume applications.
To use this API, you must to obtain an API key. After registering, log in to the dashboard to access your API key. The dashboard also shows the usage of the API.
Get a list of supported protocols.
GET
https://api.blocksec.com/trade/api/v1/protocols
Response
Our API offers a WebSocket connection to subscribe to detailed DEX protocol actions for individual accounts. This means that whenever these accounts (signers) perform a swap in a DEX pool, the detailed information of the swap will be pushed to the WebSocket client.
WebSocket Endpoint
To subscribe to the WebSocket connection, you need to send the following data.
type
String
Valid value: "SUBSCRIBE_SWAP" and "UNSUBSCRIBE_SWAP"
accounts
Array
The DEX actions of the accounts we want to listen to.
protocols
Array
The subscribed DEX protocols.
For each subscribed account, if a DEX action occurs within the subscribed protocol, a message will be sent through the WebSocket connection. The following is an example of the response.
type
String
Response type: Currently, the only expected value is "SWAP."
data.signature
String
The signature of the transaction.
data.swap.user
String
The user who signs the transaction.
data.swap.swaps
Array of swap
The swap actions involved in this transaction. Since multiple swap actions may occur within a single transaction, this is represented as an array.
The Swap structure
protocol
String
The protocol of the swap.
address
String
The protocol's contract address.
pool.market
String
The DEX pool's address involved in this swap. (Optional)
pool.vault_in
String
The address of the vault that provides the input token for the swap. (Optional)
pool.vault_out
String
The address of the vault that receives the output token from the swap. (Optional)
token_in
String
The address of the input token in the swap.
token_out
String
The address of the output token in the swap.
amount_in
Integer
The amount of the input token in the swap.
amount_out
Integer
The amount of the output token in the swap.
decimals_in
Integer
The decimal of the input token in the swap.
decimals_out
Integer
The decimal of the output token in the swap.
height
Integer
The position of the swap instruction in the call stack, starting from 1.
The table lists the supported protocol (48 in total) and contact us (contract@blocksec.com) if you found some protocols are missing.
jupiter_v6
JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4
perps
PERPHjGBqRHArX4DySjwM6UJHiR3sWAatqfdBS2qQJu
raydium_amm
675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8
raydium_clmm
CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK
raydium_cpmm
CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C
raydium_launchpad
LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj
pumpfun
6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P
pumpfun_amm
pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA
metaora
Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB
metaora_dlmm
LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo
metaora_damm_v2
cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG
lifinity_v2
2wT8Yq49kHgDzXuPxZSaeLaH1qbmGXtEyPy64bL7aD3c
orca_v1
DjVE6JNiYqPL2QXyCUUh8rNjHrbz9hXHNYt99MQ59qw1
orca_v2
9W959DqEETiGZocYWCQPaJ6sBmUzgfxXfqGeTEdp3aQP
whirlpool
whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc
flip
6LDad2GqEzvdCRA6DzTfqgRQGjFrQKndzdtRX6HEcTBf
saber
SSwpkEEcbUqx4vtoEByFjSkhKdCT862DNVb52nZg1UZ
saber_decimals
DecZY86MU5Gj7kppfUCEmd4LbXXuyZH1yHaP2NTqdiZB
zerofi
ZERor4xhbUycZ6gb9ntrhqscUcZmAbQDjEAtCf4hbZY
stabble_stable
swapNyd8XiQwJ6ianp9snpu4brUqFxadzvHebnAXjJZ
stabble_weighted
swapFpHZwjELNnjvThjajtiVmkz3yPQEHjLtka2fwHW
solfi
SoLFiHG9TfgtdUXUjWAxi3LtvYuFyDLVhBWxdMZxyCe
moonshot
MoonCVVNZFSYkqNXP6bxHLPL6QQJiMagDL3qcqUQTrG
invariant
HyaB3W9q6XdA5xwpU4XnSZV94htfmbmqJXZcEbRaJutt
phoenix
PhoeNiXZ8ByJGLkxNfZRnkUfjvmuYqLR89jjFHGqdXY
bonkswap
BSwp6bEBihVLdqJRKGgzjcGLHkcTuzmSo1TQkHepzH8p
fluxbeam
FLUXubRmkEi2q6K3Y9kBPg9248ggaZVsoSFhtJHSrm1X
crema
CLMM9tUoggJu2wagPkkqs9eFG4BWhVBZWkP1qv3Sp7tR
cropper
H8W3ctz92svYg6mkn1UtGfu2aQr2fnUFHM1RhScEtQDt
stepn
Dooar9JkhdZ7J3LHN3A7YCuoGRUggXhQaG4kijfLGU2j
1dex
DEXYosS6oEGvk8uCDayvwEZz4qEyDJRf9nFgYCaqPMTm
virtuals
5U3EU2ubXtK84QcRjWVmYt9RaDyA8gKxdUrPFXmZyaki
token_swap
SwaPpA9LAaLfeLi3a68M4DjnLqgtticKg6CnyNwgAC8
sanctum
5ocnV1qiCgaQR8Jb8xWnVbApfaygJ8tNoZfgPwsgx9kx
sanctum_router
stkitrT1Uoy18Dk1fTrgPw8W6MVzoCfYoAFT4MLsmhq
obric_v2
obriQD1zbpyLz95G5n7nJe6a4DPjpFwa5XYPoNm113y
saros
SSwapUtytfBdBn1b9NUGG6foMVPtcWgpRU32HToDUZr
guac
Gswppe6ERWKpUTXvRPfXdzHhiCyJvLadVvXGfdpBqcE1
aldrin
AMM55ShdkoGRB5jVYPjWziwk8m5MpwyDgsMWHaMSQWH6
aldrin_v2
CURVGoZn8zycx6FXwwevgBTB2gVvdbGTEpvMJDbgs2t4
openbook_v2
opnb2LAfJYbRMAHHvqjCwQxanZn7ReEHp1k81EohpZb
dexlab
DSwpgjMvXhtGn6BsbqmacdBZyfLj6jSWf3HJpdJtmg6N
helium
treaf4wWBBty3fHdyBpo35Mz84M8k3heKXmjmi9vFt5
penguin
PSwapMdSai8tjrEXcxFeQth87xC4rRsa4VA5mhGhXkP
token_mill
JoeaRXgtME3jAoz5WuFXGEndfv4NPH9nBxsLq44hk9J
solayer
endoLNCKTqDn8gSVnN2hDdpgACUPWHZTwoYnnMybpAT
marcopolo
9tKE7Mbmj4mxDjWatikzGAtkoWosiiZX9y6J4Hfm2R8H
daofun
5jnapfrAN47UYkLkEf7HnprPPBCQLvkYWGZDeKkaP5hv
mercurial
MERLuDFBMmsHnsBPZw2sDQZHvXFMwp8EdjudcU2HKky
The following shows a Python example of using the API.