# Get Pool by Token Address

Orca Whirlpool allows users to provide liquidity for token pairs. We can get all pool addresses involving a particular token, by filtering the <mark style="color:yellow;">tokenMintA</mark> and <mark style="color:yellow;">tokenMintB</mark> fields using GraphQl.

You can directly copy paste this code on <mark style="color:yellow;">replit</mark> and see it in action.

#### Fetch pools with Jito token

{% tabs %}
{% tab title="Code Snippet" %}
{% code overflow="wrap" %}

```typescript
import { gql, GraphQLClient } from 'graphql-request';

const endpoint = `https://programs.shyft.to/v0/graphql?api_key=YOUR-API-KEY`; //Shyft's gQl endpoint

const graphQLClient = new GraphQLClient(endpoint, {
  method: `POST`,
  jsonSerializer: {
    parse: JSON.parse,
    stringify: JSON.stringify,
  },
}); //Initialize gQL Client

async function getWhirlpoolsforToken(tokenAddress) {
    //you can cherry pick fields as per your requirements
    const query = gql`
    query MyQuery {
      ORCA_WHIRLPOOLS_whirlpool(
        where: {liquidity: {_gt: "0"}, tokenMintB: {_eq: ${JSON.stringify(tokenAddress)}}}
      ) {
        tokenMintA
        tokenMintB
        rewardInfos
        tickCurrentIndex
        liquidity
        whirlpoolsConfig
        pubkey
      }
    }
    `;

  const response = await graphQLClient.request(query);
  console.dir(response,{depth: null});
}
getWhirlpoolsforToken('J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn');
//replace this with token address for which you want to get Pools
```

{% endcode %}
{% endtab %}

{% tab title="Response" %}

```json
{
    "data": {
      "ORCA_WHIRLPOOLS_whirlpool": [
        {
          "tokenMintA": "jtojtomepa8beP8AuQc6eXt5FriJwfFMwQx2v2f9mCL",
          "tokenMintB": "J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn",
          "rewardInfos": [
            {
              "mint": "jtojtomepa8beP8AuQc6eXt5FriJwfFMwQx2v2f9mCL",
              "vault": "Atxdnj1ULzXv8gbubezUiEbA4x65x8LWRCozb7xshBhz",
              "authority": "DjDsi34mSB66p2nhBL6YvhbcLtZbkGfNybFeLDjJqxJW",
              "growthGlobalX64": "0",
              "emissionsPerSecondX64": "0"
            },
            {
              "mint": "orcaEKTdK7LKz57vaAYr9QeNsVEPfiu6QeMU1kektZE",
              "vault": "DV7ktPrVK5kpj81uc4sb8Tqo4AZrZ9RxU6V3Mp3G7cKz",
              "authority": "DjDsi34mSB66p2nhBL6YvhbcLtZbkGfNybFeLDjJqxJW",
              "growthGlobalX64": "0",
              "emissionsPerSecondX64": "0"
            },
            {
              "mint": "11111111111111111111111111111111",
              "vault": "11111111111111111111111111111111",
              "authority": "DjDsi34mSB66p2nhBL6YvhbcLtZbkGfNybFeLDjJqxJW",
              "growthGlobalX64": "0",
              "emissionsPerSecondX64": "0"
            }
          ],
          "tickCurrentIndex": -39741,
          "liquidity": 460828171242077,
          "whirlpoolsConfig": "2LecshUwdy9xi7meFgHtFJQNSKk4KdTrcpvaB56dP2NQ",
          "pubkey": "G2FiE1yn9N9ZJx5e1E2LxxMnHvb1H3hCuHLPfKJ98smA"
        },
        {
          "tokenMintA": "So11111111111111111111111111111111111111112",
          "tokenMintB": "J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn",
          "rewardInfos": [
            {
              "mint": "11111111111111111111111111111111",
              "vault": "11111111111111111111111111111111",
              "authority": "DjDsi34mSB66p2nhBL6YvhbcLtZbkGfNybFeLDjJqxJW",
              "growthGlobalX64": "0",
              "emissionsPerSecondX64": "0"
            },
            {
              "mint": "11111111111111111111111111111111",
              "vault": "11111111111111111111111111111111",
              "authority": "DjDsi34mSB66p2nhBL6YvhbcLtZbkGfNybFeLDjJqxJW",
              "growthGlobalX64": "0",
              "emissionsPerSecondX64": "0"
            },
            {
              "mint": "11111111111111111111111111111111",
              "vault": "11111111111111111111111111111111",
              "authority": "DjDsi34mSB66p2nhBL6YvhbcLtZbkGfNybFeLDjJqxJW",
              "growthGlobalX64": "0",
              "emissionsPerSecondX64": "0"
            }
          ],
          "tickCurrentIndex": -963,
          "liquidity": 12119877,
          "whirlpoolsConfig": "2LecshUwdy9xi7meFgHtFJQNSKk4KdTrcpvaB56dP2NQ",
          "pubkey": "8bDeibmKzTmVpcB8QZf1UtMJgu7UmFgrG4eiNnxCSQb3"
        }
      ]   
    }
}
```

{% endtab %}
{% endtabs %}

Please note that, the filter liquidity `{_gt: "0"}` is optional and has been added to get Whirlpools which have a liquidity greater than 0.

#### Fetch Token Pairs SOL-USDC

You can also fetch a particular token pair, for example SOL-USDC. Here you need to apply where filter on both tokenA and tokenB.

{% code overflow="wrap" %}

```typescript

import { gql, GraphQLClient } from 'graphql-request';

const endpoint = `https://programs.shyft.to/v0/graphql?api_key={YOUR-API-KEY}`; //Shyft's gQl endpoint

const graphQLClient = new GraphQLClient(endpoint, {
  method: `POST`,
  jsonSerializer: {
    parse: JSON.parse,
    stringify: JSON.stringify,
  },
}); //Initialize gQL Client

async function getWhirlpoolsforToken(tokenA, tokenB) {
    //you can cherry pick fields as per your requirements
    const query = gql`
    query MyQuery {
      ORCA_WHIRLPOOLS_whirlpool(
        where: {tokenMintA: {_eq: ${JSON.stringify(tokenA)}}, tokenMintB: {_eq: ${JSON.stringify(tokenB)}}}
      ) {
        tokenMintA
        tokenMintB
        rewardInfos
        tickCurrentIndex
        liquidity
        whirlpoolsConfig
        pubkey
      }
    }
    `;

  const response = await graphQLClient.request(query);
  console.dir(response,{depth: null});
}

await getWhirlpoolsforToken('So11111111111111111111111111111111111111112', 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v');
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.shyft.to/solana-indexers/case-studies/orca-whirlpool/get-pool-by-token-address.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
