> For the complete documentation index, see [llms.txt](https://docs.shyft.to/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.shyft.to/solana-indexers/case-studies/fluxbeam/get-pool-by-token-addresses.md).

# Get Pool by Token Addresses

Liquidity pools rely on <mark style="color:yellow;">liquidity</mark> token <mark style="color:yellow;">pairs</mark>. These pairs are the two tokens that users contribute in equal value to the pool. In Fluxbeam, the liquidity pairs denoted by the <mark style="color:yellow;">mintA</mark> and <mark style="color:yellow;">mintB</mark> fields. \
For instance we are trying to get liquidity pools involving USDC and SOL, so we filter `mintA` and `mintB` fields using the *\_in* filter.

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

#### Fetch Pool by Liquidity Pair (USDC-SOL)

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

```javascript
async function getPoolByPair(mintAddressA,mintAddressB) {
  const SHYFT_API_KEY = "YOUR_SHYFT_API_KEY";
  //get a fluxbeam Pool details using a liquidity pool pair
  const operationsDoc = `
      query MyQuery {
        Fluxbeam_TokenSwap(
          where: {mintA: {_in: ${JSON.stringify([mintAddressA,mintAddressB])}}, mintB: {_in: ${JSON.stringify([mintAddressA,mintAddressB])}}}
        ) {
          tokenPool
          mintB
          mintA
          pubkey
          curveType
        }
      }
      `; //graphQl query
  const result = await fetch(
    `https://programs.shyft.to/v0/graphql/accounts?api_key=${SHYFT_API_KEY}&network=mainnet-beta`, //SHYFT's GQL endpoint
    {
      method: "POST",
      body: JSON.stringify({
        query: operationsDoc,
        variables: {},
        operationName: "MyQuery",
      }),
    },
  );

  const { errors, data } = await result.json();

  console.dir(data, { depth: null });
}

getPoolByPair("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v","So11111111111111111111111111111111111111112")
//for getting the SOL-USDC pool, however you can enter your own liquidity pool pair as well
```

{% endcode %}
{% endtab %}

{% tab title="Response" %}

```json
{
  "data": {
    "Fluxbeam_TokenSwap": [
      {
        "tokenPool": "GDX61hU9HdW45LgQ36tzXYDQVMLyRjWX1tpAKyvSgxgR",
        "mintB": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
        "mintA": "So11111111111111111111111111111111111111112",
        "pubkey": "CZEZDGDkzsn4zTfdw6XRm4U1o6GatotMhhRmVEzdwGS3",
        "curveType": 0
      }
    ]
  }
}
```

{% endtab %}
{% endtabs %}

We can also query liquidity pool involving a particular <mark style="color:yellow;">token address</mark>, for that we would have to filter the `mintA` or `mintB` field using the *\_in* filter.

#### Fetch Pool For a Token (SOL)

{% tabs %}
{% tab title="Code Snippet" %}

```javascript
async function getPoolByMint(mintAddress) {
  const SHYFT_API_KEY = "YOUR_SHYFT_API_KEY";
  //get a fluxbeam Pool details based on a particular token address
  const operationsDoc = `
      query MyQuery {
        Fluxbeam_TokenSwap(
          where: {_or: [{_or: {mintB: {_eq: ${JSON.stringify(mintAddress)}}}},{_or: {mintA: {_eq: ${JSON.stringify(mintAddress)}}}}]}
        ) {
          tokenPool
          mintB
          mintA
          pubkey
          curveType
        }
      }
      `; //graphQl query
  const result = await fetch(
    `https://programs.shyft.to/v0/graphql/accounts?api_key=${SHYFT_API_KEY}&network=mainnet-beta`, //SHYFT's GQL endpoint
    {
      method: "POST",
      body: JSON.stringify({
        query: operationsDoc,
        variables: {},
        operationName: "MyQuery",
      }),
    },
  );

  const { errors, data } = await result.json();

  console.dir(data, { depth: null });
}

getPoolByMint("So11111111111111111111111111111111111111112")
// for getting all Pool involving SOL as a token
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
  "data": {
    "Fluxbeam_TokenSwap": [
      {
        tokenPool: 'BdXwXmhLCBzGULhG9yGfJc6EPxqcPJwoEWLkaPTERTHR',
        mintB: 'So11111111111111111111111111111111111111112',
        mintA: 'HhbuZj7GG8WDBGnWyt2UoUCufnUxEitmX1Fxoe8TERjR',
        pubkey: 'HLFgVNY5eudftJGtuYpcTLMYua2TzdQKKRWqFt2poUvk',
        curveType: 0
      },
      {
        tokenPool: 'FCz6tDQfmCyW5X5tjbgy6M5JDZZZvK3JDag6fzRMJJgc',
        mintB: 'So11111111111111111111111111111111111111112',
        mintA: '9EgZ6bnksPCzFjGCCUCpP8iERaS6YGsRJ4P5iYfFo6jR',
        pubkey: 'E329DVSedmpW5cE1M4okThqnHJvsLYtLYD7kNRzhJfbS',
        curveType: 0
      },
      {
        tokenPool: '6d5SibaRhTdVEpBv3DyGKAdBhDgxFpeFoJaUBwoVWCtm',
        mintB: '9nUbcaM8B56XDMKToCQGvMCbq8xtX7NrvL2FytTeMqWU',
        mintA: 'So11111111111111111111111111111111111111112',
        pubkey: '6a9MMnJPS1EbzvPQ4X8uq6GLmLM6gyj2Qfp5eejdbKXa',
        curveType: 0
      }
    //response shortened for visibility
    ] 
  }
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.shyft.to/solana-indexers/case-studies/fluxbeam/get-pool-by-token-addresses.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
