Introducing RabbitStream⚡, earliest transaction detection from Solana Shreds with gRPC style filtering. Explore Now
shyft logo
Get API Key

Blogs

Dev Guides

How to fetch the liquidity details of a Token on Solana

Shyft Logo

Team Shyft

· January 22, 2026

In this blog, we’ll guide you through the process of getting a token’s liquidity from all major dexes with Shyft’s Solana DeFi APIs.

Get Liquidity Details of Token On Solana: DeFi Solana

Fetching liquidity details from multiple DEXs can be tedious and inefficient for developers using traditional methods like getProgramAccounts. Shyft’s DeFi APIs simplify this process by providing fast, aggregated Solana DeFi data from major protocols like Raydium and Orca. In this blog, we’ll demonstrate how to use Shyft’s APIs to streamline liquidity retrieval and compare them with traditional RPC methods, showcasing their efficiency and ease of use.

Getting Started

To use Shyft’s APIs, follow these simple steps:

  1. Create an Account and Get Your API Key
    Register on Shyft and obtain your x-api-key, which is required to access the APIs.
  2. Set Up Your Development Environment
    Use a development environment like NodeJS to fetch API and RPC data. While this example uses NodeJS, you can use any language supporting API calls, such as Python, Java, or Go.

Here is ready to use Replit code to fork and test them to get started quickly.

Traditional Method: using getProgramAccounts()

You can retrieve liquidity information or related DeFi data for a specific program (or DEX) using getProgramAccounts. This involves applying a memcmp filter to the account data, as demonstrated in the example below.

const accounts = await connection.getProgramAccounts(    RAYDIUM_PROGRAM_ID.AmmV4,     {       commitment: 'confirmed',       filters: [         { dataSize: LIQUIDITY_STATE_LAYOUT_V4.span },         {            memcmp: {              offset: LIQUIDITY_STATE_LAYOUT_V4.offsetOf("baseMint"),              bytes: tokenA.toBase58(),                           },          }        ],      } );

This method works but comes with challenges. It is slow, returns raw data that needs extra processing, and fetching data from multiple DEXs requires separate calls and custom parsing for each. Now, let’s see how Shyft’s DeFi APIs simplify this process.

Introducing DeFi APIs : An improved way to access DeFi data on Solana

Let’s explore how we can query liquidity information for a token on Solana using Shyft’s DeFi APIs. The API endpoint is as follows:

GET https://defi.shyft.to/v0/pools/get_by_token

Parameters required for this API call:

  • **token**: Address of the token for which we are fetching the liquidity pool details
  • **limit**: This is an optional parameter which is used for pagination. Specifies the number of items to display per page. The default value is 100.
  • **page**: Specifies the page number when displaying items specified by limit. This is also optional.
  • **dex**: This accepts an array of string names for dexes for which we need the data for. If not mentioned, data from all dexes is returned. The full list of string names for dexes can be found here.

Please note that like all Shyft APIs, these APIs also needs the **x-api-key** auth parameter in the header section, specifying your Shyft API Key from your dashboard.

If the dex field is not specified, liquidity details is returned for all the supported dexes for the token address specified. This API also supports pagination, and the response returned looks somewhat like this.

{    "success": true,    "message": "Pools fetched successfully",    "result": {        "page": 1,        "limit": 1,        "dexes": {            "meteoraAmm": {                "pools": [                    {                        "lpMint": "9ZgdREVJDG5apT7gPt6CAPBYvfhUcDecFUvbXaxoKunj",                        "tokenAMint": "7Z3thA2ZmMuapEmEGiB6rxoYmDDnnEv717NydgeoXhex",                        "tokenBMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",                        "aVault": "6Fzmt8UixGEK6sJkjc6ET2VUqK3wkvBoJGHB85J2ek7M",                        "bVault": "3ESUFCnRNgZ7Mn2mPPUMmXYaKU8jpnV9VtA17M7t2mHQ",                        "aVaultLp": "8gyv8AwYqCNKC2FkFMzZy4pPeQazM9Svad29XcXDYcrk",                        "bVaultLp": "9C7fTkTBczhsdhjNWSJdLX27gSizyoTHdmQAVH1ZNZgg",                        "aVaultBump": 255,                        "enabled": true,                                            }                ],                "programId": "Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB"            },            "openbookV2": {                "pools": [                    {                        "pubkey": "2ZNDYtUpfenGZcjhcrQeNJ8Bs4ecVJKQEE4oNBCkejxj",                        "lamports": 6792960,                        "bump": 255,                        "baseDecimals": 9,                        "quoteDecimals": 6,                        "padding1": 0,                        "marketAuthority": "BY68afooPNzRE6n9iQmpGwioLU7fzAfUsMXmThjmkYa9",                        "timeExpiry": 1713753898,                        "collectFeeAdmin": "7ihN8QaTfNoDTRTQGULCzbUT3PHwPDTu5Brcu4iT2paP",                                            }                ],                "programId": "opnb2LAfJYbRMAHHvqjCwQxanZn7ReEHp1k81EohpZb"            },            "orca": {                "pools": [                    {                        "whirlpoolsConfig": "2LecshUwdy9xi7meFgHtFJQNSKk4KdTrcpvaB56dP2NQ",                        "feeRate": 3000,                        "protocolFeeRate": 1300,                        "liquidity": 0,                        "sqrtPrice": 178194428756287260,                        "tickCurrentIndex": -92800,                        "protocolFeeOwedA": 0,                        "protocolFeeOwedB": 0,                        "tokenMintA": "5PmpMzWjraf3kSsGEKtqdUsCoLhptg4yriZ17LKKdBBy",                        "tokenVaultA": "Dy6ktGLX9So2jwUAGzJA811b2XxXVfP4NfRvgvAUXkZ5",                        "feeGrowthGlobalA": 102588657235574930000,                        "tokenMintB": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",                        "tokenVaultB": "AVxMdgRUUt28vrMjvq1jR2CxdcRtA2sqBdotrjrgNCiy",                                        ],                "programId": "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc"            },            "raydiumAmm": {                "pools": [                    {                        "pubkey": "5oAvct85WyF7Sj73VYHbyFJkdRJ28D8m4z4Sxjvzuc6n",                        "lamports": 7124800,                        "status": 6,                        "nonce": 254,                        "maxOrder": 7,                        "depth": 3,                        "baseDecimal": 9,                        "quoteDecimal": 6,                        "state": 1,                                           }                ],                "programId": "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"            }              }}

How is it better than the traditional getProgramAccounts()?

When compared to the traditionalgetProgramAccounts RPC call to retrieve liquidity details, Shyft’s DeFi APIs offer several key benefits that make DeFi data more accessible:

  • Lightning-Fast Response Times: Unlike the slower getProgramAccounts method, Shyft’s DeFi APIs provide data with exceptional response times (under 500ms), ensuring timely access to critical information.
  • Single API Call for All DEXes: Instead of making separate requests for each DEX, Shyft’s APIs consolidate liquidity data from multiple platforms into a single API call, streamlining the process.
  • Pre-Parsed, Ready-to-Use Data: Shyft’s APIs return structured, parsed data, eliminating the need for manual processing and allowing you to focus directly on trading and development tasks.

More over, this API also supports pagination, so the data received is not overwhelming. These enhancements make Shyft’s DeFi APIs the more powerful and efficient alternative for accessing DeFi data on Solana.

You can find all the code related to this article on our replit here. You can fork it and use it to build innovative solutions.

You can explore our other related articles: Streaming Real-Time Data on Solana, Real-Time Data Streaming with gRPC: Accounts, Transactions, Blocks, How to Stream Real-Time Pump.fun Updates on Solana, and Tracking New Pools on Raydium.

Get Team Shyft’s stories in your inbox

Join Medium for free to get updates from this writer.

For additional support, join our Discord Server or follow us on Twitter for the latest updates. Our team is here to assist you in utilizing this innovative technology.

Resources

Related Posts

How to reconnect and replay slots with Solana Yellowstone gRPC
Shyft

How to reconnect and replay slots with Solana Yellowstone gRPC

In this article you will learn how to implement a reconnect logic for your Solana gRPC streams with replay functionality...

January 24, 2026

How to modify Solana Yellowstone gRPC subscribe requests without disconnecting
Shyft

How to modify Solana Yellowstone gRPC subscribe requests without disconnecting

Learn how to modify your yellowstone gRPC Subscribe Requests on Solana without stopping your stream or losing data ...

January 24, 2026

Real-Time Solana Data Streaming with gRPC: Accounts, Transactions, Blocks
Shyft

Real-Time Solana Data Streaming with gRPC: Accounts, Transactions, Blocks

A comprehensive guide on how to stream Transactions, Accounts, and Block updates swiftly using Shyft’s gRPC Services ...

January 22, 2026

Get in touch with our discord community and keep up with the latest feature
releases. Get help from our developers who are always here to help you take off.

GithubTwitterLinked inDiscordTelegramBlogsBlogs

Products

RabbitStreamgRPC NetworkSuperIndexerSolana APIs
Contact Us|Email: genesis@shyft.to