# Query subscriptions

Here is an example of how to query  subscriptions given their respective index using sub2-sdk. As mentioned [here](https://sub2.gitbook.io/sub2/concepts/subscription), subscriptions are stored in one public array called `subscriptions` and are uniquely identified by their index in the array. Since the array is public, we can query all the information of a subscription using their index. Assuming sub2-sdk is installed and initialised like shown [here](https://sub2.gitbook.io/sub2/sdk), we can query the subscription as follows:

<pre class="language-typescript"><code class="lang-typescript"><strong>import { Subscription } from 'sub2-sdk';
</strong><strong>
</strong><strong>const subscriptions: Subscription[] = await sub2SDK.getSubscriptions(indices);
</strong></code></pre>

Here, `indices` has type `bigint[]`.The `getSubscription` function returns a promise with a Subscription\[] array. Each Subscription object contains both the on-chain data and auxiliary information:

```typescript
interface Subscription {
  id: bigint;
  sender: `0x${string}`,
  recipient: `0x${string}`,
  sponsor: `0x${string}`,
  amount: bigint,
  token: `0x${string}`,
  maxProcessingFee: bigint,
  processingFeeToken: `0x${string}`,
  cooldown: number,
  auctionDuration: number,
  paymentCounter: number,
  status: 'canceled' | 'expired' | 'auction' |  'waiting';
  lastPayment: Date,
  nextPaymentAvailable: Date;
  nextPaymentDue: Date;
}
```

Now we have obtained all information about the subscriptions!


---

# 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://sub2.gitbook.io/sub2/sdk/query-subscriptions.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.
