How to Check Token Swap Activities on a Wallet Using Solscan Pro API
The Solscan Pro API empowers users to monitor token swap activities for any Solana wallet. By leveraging the Account DeFi Activities endpoint, you can retrieve detailed swap data, filter by time, DeFi platforms, specific tokens, or even aggregate swap activities across protocols like Jupiter. This guide provides a clear process and a practical example to help you get started.
The Process
To retrieve token swap activities for a wallet using the Solscan Pro API, follow these steps:
-
Access the Account DeFi Activities Endpoint
Use the endpoint:
GET <https://pro-api.solscan.io/v2.0/account/defi/activities
>. This endpoint fetches DeFi-related activities for a specified Solana wallet. -
Specify the Wallet Address
Include the
address
parameter with the Solana wallet address you want to query. This is required to retrieve all associated DeFi activities. -
Filter by Activity Type
Set the
activity_type
parameter toACTIVITY_TOKEN_SWAP
to focus on individual token swap transactions. Alternatively, useACTIVITY_AGG_TOKEN_SWAP
to retrieve aggregated swap history, which includes swaps executed through aggregators like Jupiter. You can pass these as an array (e.g.,["ACTIVITY_TOKEN_SWAP","ACTIVITY_AGG_TOKEN_SWAP"]
) to include both. -
Optional: Filter by Specific Tokens
Use the
filter
parameter to narrow down swaps involving specific tokens. Provide the token address(es) to focus on swaps involving those tokens (e.g., SOL, USDC). This parameter accepts an array of token addresses for precise filtering. -
Optional: Filter by Time Period
Add the
from_time
andto_time
parameters to limit results to a specific timeframe. Use Unix timestamps (in seconds) to define the start and end of the period. -
Optional: Filter by DeFi Platform
To target swaps on a specific platform (e.g., Orca, Raydium), include the
platform
parameter with the platform’s program address (up to 5 addresses in an array). Find program addresses in Solscan’s documentation or the platform’s resources—for example, Orca’s Whirlpool program iswhirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc
. -
Review the Response Data
The API returns detailed data, including:
- Swap token addresses: Tokens involved in the input and output of the swap.
- Amounts and values swapped: Quantities of tokens exchanged and their estimated USD values.
- Platform: The DeFi platform or aggregator (e.g., Jupiter for
ACTIVITY_AGG_TOKEN_SWAP
) where the swap occurred. - Additional metadata like transaction signatures and timestamps.
-
Authenticate the Request
Include your Solscan Pro API key in the header:
-H 'token: <YOUR_API_KEY>'
to authenticate the request.
Example
Suppose you want to retrieve token swap activities for a wallet, including swaps through Orca and Jupiter, involving SOL and USDC, between January 1, 2025, and February 1, 2025.
Sample Request (using cURL):
curl -X GET "<https://pro-api.solscan.io/v2.0/account/defi/activities?address=><WALLET_ADDRESS>&activity_type[]=ACTIVITY_TOKEN_SWAP&activity_type[]=ACTIVITY_AGG_TOKEN_SWAP&filter[]=So11111111111111111111111111111111111111112&filter[]=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&platform=whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc&from_time=1735689600&to_time=1738368000" \\
-H "accept: application/json" \\
-H "token: <YOUR_API_KEY>"
- Parameters Explained:
address
: Replace<WALLET_ADDRESS>
with the target Solana wallet (e.g.,5oNDLrU6qw9Q3KJu2zEqufZ3gqU1n4JUoWVvoMGvmiDa
).activity_type[]=ACTIVITY_TOKEN_SWAP&activity_type[]=ACTIVITY_AGG_TOKEN_SWAP
: Includes both direct swaps and aggregated swaps (e.g., via Jupiter).filter[]=So11111111111111111111111111111111111111112&filter[]=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
: Filters for SOL and USDC.platform=whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc
: Orca’s Whirlpool program address.from_time=1735689600
: Unix timestamp for January 1, 2025 (00:00:00 UTC).to_time=1738368000
: Unix timestamp for February 1, 2025 (00:00:00 UTC).<YOUR_API_KEY>
: Your Solscan Pro API key.
Sample Response (simplified JSON):
{
"data": [
{
"tx_signature": "3x...abc",
"timestamp": 1736000000,
"activity_type": "ACTIVITY_TOKEN_SWAP",
"platform": "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc",
"tokens_in": {
"token_address": "So11111111111111111111111111111111111111112",
"amount": 1.5,
"value_usd": 150.0
},
"tokens_out": {
"token_address": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"amount": 150.0,
"value_usd": 150.0
}
},
{
"tx_signature": "4y...xyz",
"timestamp": 1736100000,
"activity_type": "ACTIVITY_AGG_TOKEN_SWAP",
"platform": "JUP4Fb2cqiRUcaTHdrPC8h2gNsA2ETXiPDD33Zr9hX",
"tokens_in": {
"token_address": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"amount": 100.0,
"value_usd": 100.0
},
"tokens_out": {
"token_address": "So11111111111111111111111111111111111111112",
"amount": 0.9,
"value_usd": 90.0
}
}
]
}
This response shows two swaps: one on Orca (SOL to USDC) and an aggregated swap via Jupiter (USDC to SOL).
Ready to explore more Solana blockchain analytics? Visit https://pro-api.solscan.io/pro-api-docs/v2.0 to dive into the full Solscan Pro API documentation, explore additional endpoints, and choose the API plan that fits your needs.
Start building powerful tools to analyze on-chain activities today!