# 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 %}
