How to Check Token DeFi Activities Using Solscan Pro API

The Solscan Pro API allows you to track DeFi activities involving a particular token on the Solana blockchain. Using the Token DeFi Activities endpoint, you can query transactions such as token swaps, liquidity additions/removals, staking, and more. Apply filters for activity types (e.g., direct or aggregated swaps), time periods, platforms, or specific sources to retrieve details like token addresses, amounts, values, and platforms. This guide details the process and includes an example focused on token swaps.

The Process

To retrieve DeFi activities for a specific token using the Solscan Pro API, follow these steps:

  1. Access the Token DeFi Activities Endpoint

    Use the endpoint: GET <https://pro-api.solscan.io/v2.0/token/defi/activities>. This fetches DeFi activities associated with a specified token on the Solana blockchain.

  2. Specify the Token Address

    Include the address parameter with the token’s mint address (e.g., for SOL or USDC). This is required to retrieve all DeFi activities involving the token.

  3. Filter by Activity Type

    Set the activity_type parameter as an array to focus on specific DeFi actions. For token swaps, use ACTIVITY_TOKEN_SWAP for direct swaps or ACTIVITY_AGG_TOKEN_SWAP for aggregated swaps (e.g., via Jupiter). You can include multiple types, such as ["ACTIVITY_TOKEN_SWAP", "ACTIVITY_AGG_TOKEN_SWAP"]. Other supported types include ACTIVITY_TOKEN_ADD_LIQ (add liquidity), ACTIVITY_TOKEN_REMOVE_LIQ (remove liquidity), ACTIVITY_POOL_CREATE (create pool), ACTIVITY_SPL_TOKEN_STAKE (stake), ACTIVITY_SPL_TOKEN_UNSTAKE (unstake), ACTIVITY_TOKEN_DEPOSIT_VAULT (deposit to vault), ACTIVITY_TOKEN_WITHDRAW_VAULT (withdraw from vault), ACTIVITY_SPL_INIT_MINT (initialize mint), and ACTIVITY_ORDERBOOK_ORDER_PLACE (place orderbook order).

  4. Optional: Filter by Specific Tokens

    Use the token parameter to narrow down activities involving an additional token address (e.g., for token pairs in swaps).

  5. Optional: Filter by Time Period

    Add the from_time and to_time parameters to limit results to a specific timeframe. Use Unix timestamps (in seconds) for the start and end of the period. Note: The block_time parameter is deprecated and should be avoided.

  6. Optional: Filter by DeFi Platform

    Include the platform parameter as an array of up to 5 platform program addresses to target activities on specific platforms (e.g., Orca, Raydium). For example, Orca’s Whirlpool program address is whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc.

  7. Optional: Account Filters

    • from: Filter activities originating from a specific wallet address.
    • source: Filter by an array of up to 5 source addresses (e.g., related accounts or programs).
  8. Handle Pagination and Sorting

    Use page (page number) and page_size (10, 20, 30, 40, 60, or 100 items per page) for pagination. Sort results with sort_by=block_time and sort_order=asc or desc.

  9. Review the Response Data

    The API returns a list of activities with details such as:

    • Token addresses: Tokens involved (e.g., input/output for swaps).
    • Amounts and values swapped: Quantities and estimated USD values (for swaps).
    • Platform: The DeFi platform or aggregator involved.
    • Additional metadata like transaction signatures, timestamps, source addresses, and balance changes.
  10. Authenticate the Request

    Include your Solscan Pro API key in the header: -H 'token: <YOUR_API_KEY>'.

Example

Suppose you want to retrieve DeFi activities for the USDC token, focusing on token swaps (direct and aggregated via Jupiter) on Orca, between January 1, 2025, and February 1, 2025.

Sample Request (using cURL):

curl -X GET "<https://pro-api.solscan.io/v2.0/token/defi/activities?address=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&activity_type[]=ACTIVITY_TOKEN_SWAP&activity_type[]=ACTIVITY_AGG_TOKEN_SWAP&token=So11111111111111111111111111111111111111112&platform[]=whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc&from_time=1735689600&to_time=1738368000&page_size=20&sort_by=block_time&sort_order=desc>" \\
-H "accept: application/json" \\
-H "token: <YOUR_API_KEY>"
  • Parameters Explained:
    • address=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v: USDC token address.
    • activity_type[]=ACTIVITY_TOKEN_SWAP&activity_type[]=ACTIVITY_AGG_TOKEN_SWAP: Filters for direct and aggregated token swaps.
    • token=So11111111111111111111111111111111111111112: Additional filter for SOL (e.g., SOL/USDC pairs).
    • 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).
    • page_size=20: Returns 20 items per page.
    • sort_by=block_time&sort_order=desc: Sorts by block time in descending order.
    • <YOUR_API_KEY>: Your Solscan Pro API key.

Sample Response (simplified JSON):

{
  "data": [
    {
      "tx_signature": "3x...abc",
      "block_time": 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",
      "block_time": 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
      }
    }
  ],
  "next_page": 2
}

This response shows two swap activities involving USDC: one direct on Orca (SOL to USDC) and one aggregated via Jupiter (USDC to SOL), with pagination support.

For more advanced usage and full documentation, visit https://pro-api.solscan.io/pro-api-docs/v2.0 to explore API plans, additional endpoints, and detailed references.

Unlock deeper insights into Solana token activities today!

Sinh Nguyen
Sinh Nguyen
Last updated: