> 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/orca-whirlpool/get-positions-for-a-pool.md).

# Get Positions for a Pool

Whenever users interact with liquidity pools, or trade financial assets, they get a position with respect to that particular pool. Once we have the pool address we can query all the positions respect to that particular pool, by filtering the position accounts data using GraphQl.

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

{% 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-KEY`;

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

async function getAllPositionsforWhirlpool(poolAddress) {
    //you can add more fields as per your requirements
    const query = gql`
    query MyQuery {
      ORCA_WHIRLPOOLS_position(
        where: {liquidity: {_gt: "0"}, whirlpool: {_eq: ${JSON.stringify(poolAddress)}}}
      ) {
        liquidity
        positionMint
        pubkey
        whirlpool
      }
    }
    `;

  const response = await graphQLClient.request(query);
  console.dir(response,{depth: null});
}
getAllPositionsforWhirlpool('ASdEzNQWHttmokANHz8DX2UnWsvgcVF2tN7eKe62Aj7o');
//you can enter pool address as per your requirement
```

{% endcode %}
{% endtab %}

{% tab title="Response" %}

```json
{
  "data": {
    "ORCA_WHIRLPOOLS_position": [
      {
        "liquidity": 28985302,
        "positionMint": "7YxirYwUg1KRGspf8WkHefLZNpXDrECLoqoDZKmn2nTp",
        "pubkey": "97sPd53fUJz4kftWo4tVa52tzpCu6GQoCSicjDa1C224",
        "whirlpool": "ASdEzNQWHttmokANHz8DX2UnWsvgcVF2tN7eKe62Aj7o"
      },
      {
        "liquidity": 150449725,
        "positionMint": "GPmxTJHkcGeTpVi4vEkTDZQRi3BdFnvSdz2uySTXZS1f",
        "pubkey": "DQhdQfCGSCtfNeQXbSeyNcaLYeKhfdViZcLTBQp2AxnN",
        "whirlpool": "ASdEzNQWHttmokANHz8DX2UnWsvgcVF2tN7eKe62Aj7o"
      },
      {
        "liquidity": 1172020909,
        "positionMint": "En3QBD1i5erbXtjyMRFET1DwsKVcA9eiovwC64p8Lt1E",
        "pubkey": "7nbdBfSHUKwZSAupKv79ctHJG6LgAngrTw3ANAfpfkrv",
        "whirlpool": "ASdEzNQWHttmokANHz8DX2UnWsvgcVF2tN7eKe62Aj7o"
      },
      {
        "liquidity": 634258,
        "positionMint": "CjCdDdzxuAj6H1Z1vfeHAoW9M8Yx6ZLMi5DSF4PMGxed",
        "pubkey": "Hyse1PSynLPV11xYpYr3upFRLoX3xgyTFv5UwNyfUEXm",
        "whirlpool": "ASdEzNQWHttmokANHz8DX2UnWsvgcVF2tN7eKe62Aj7o"
      },
      {
        "liquidity": 487292309,
        "positionMint": "FtFSiTZ9oVpuhtp4VxXDzAMFHNqQC8jno6q6zf7oqTg9",
        "pubkey": "2T73hb3n94CCi55Bm3Rp9r7huKyaVxbw9L3YS2JPTqGz",
        "whirlpool": "ASdEzNQWHttmokANHz8DX2UnWsvgcVF2tN7eKe62Aj7o"
      },
      {
        "liquidity": 148674040,
        "positionMint": "CTDyBAjP7woy4VraJ8XudPW5wJmFZaezumJaHzzdTX9G",
        "pubkey": "Gm6ipkBCG6j2DhktkvVvfkd9dPcSkqNYEuRM6cjJtg79",
        "whirlpool": "ASdEzNQWHttmokANHz8DX2UnWsvgcVF2tN7eKe62Aj7o"
      },
      {
        "liquidity": 244067,
        "positionMint": "CqDj8UtjRm2S36qWPfoicr1zEXKeEraDRogfC2HaqhDq",
        "pubkey": "BFZZfNKCNbwfVrThVv4ZL1rvBoy92svNPMnFzrCTgy5E",
        "whirlpool": "ASdEzNQWHttmokANHz8DX2UnWsvgcVF2tN7eKe62Aj7o"
      },
      {
        "liquidity": 22549151378,
        "positionMint": "8yULcoKXmWtKRJdRGkR7772XzWAekGXni9k9zGGWyumH",
        "pubkey": "C1V9owm1FWapjge6ErYFayAPxePQzhVGPpkpKWnZeECR",
        "whirlpool": "ASdEzNQWHttmokANHz8DX2UnWsvgcVF2tN7eKe62Aj7o"
      } //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/orca-whirlpool/get-positions-for-a-pool.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.
