# List subscriptions

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


[Eventually Consistent](/docs/api/read-consistency)

Returns a list of subscriptions meeting **all** the conditions specified in the filter parameters below.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/subscriptions \
     -G  \
     -u {site_api_key}:\
     --data-urlencode limit=2 \
     --data-urlencode "item_id[in]"='["basic"]'
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;
using Newtonsoft.Json.Linq;

ApiConfig.Configure("{site}","{site_api_key}");
ListResult result = Subscription.List()
		.Limit(2)
		.ItemId().In("basic")
		.Request();

foreach (var listItem in result.List){
  Subscription subscription = listItem.Subscription;
  Customer customer = listItem.Customer;
  Card card = listItem.Card;
}
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    "github.com/chargebee/chargebee-go/v3/filter"
    subscriptionAction "github.com/chargebee/chargebee-go/v3/actions/subscription"
    "github.com/chargebee/chargebee-go/v3/models/subscription"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := subscriptionAction.List(&subscription.ListRequestParams{
        Limit : chargebee.Int32(2),
        ItemId : &filter.StringFilter{
            In : []string{"basic"},
        },
    }).ListRequest()
    if err != nil {
        fmt.Println(err)
    } else {
        for idx := 0; idx < len(res.List); idx++ {
            Subscription := res.List[idx].Subscription
            Customer := res.List[idx].Customer
            Card := res.List[idx].Card
        }
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.SubscriptionListRequest{
    Limit : chargebee.Int32(2),
    ItemId : &chargebee.StringFilter{
        In : []string{"basic"},
    },
}
  res, err := client.Subscription.List(req)
      if err != nil {
        fmt.Println(err)
    } else {
        for idx := 0; idx < len(res.List); idx++ {
            Subscription := res.List[idx].Subscription
            Customer := res.List[idx].Customer
            Card := res.List[idx].Card
        }
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;
import java.util.List;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        ListResult result = Subscription.list()
            .limit(2)
            .itemId().in("basic")
            .request();

        for (ListResult.Entry entry : result) {
            Subscription subscription = entry.subscription();
            Customer customer = entry.customer();
            Card card = entry.card();
        }
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.card.Card;
import com.chargebee.v4.models.customer.Customer;
import com.chargebee.v4.models.subscription.Subscription;
import com.chargebee.v4.models.subscription.params.SubscriptionListParams;
import com.chargebee.v4.models.subscription.responses.SubscriptionListResponse;
import java.util.List;

public class SubscriptionList {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        SubscriptionListParams params = SubscriptionListParams.builder()
            .limit(2)
            .itemId()
            .in("[\"basic\"]")
            .build();

        SubscriptionListResponse response = client.subscriptions().list(params);
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.subscription.list({
        limit: 2,
        item_id: {
            in: ["basic"]
        }
    });
    result.list.forEach((entry) => {
        console.log(entry);
        const subscription = entry.subscription;
        const customer = entry.customer;
        const card = entry.card;
    });
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->subscription()->all([
    "limit" => 2,
    "item_id" => [
        "in" => ["basic"]
    ]
]);
foreach($result->list as $entry) {
    $subscription = $entry->subscription;
    $customer = $entry->customer;
    $card = $entry->card;
}
```

#### Python

```python
from chargebee import Chargebee, Filters

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
entries = cb_client.Subscription.list(
    cb_client.Subscription.ListParams(
        limit=2,
        item_id=Filters.StringFilter(IN=["basic"])
    )
)
for entry in entries.list:
    subscription = entry.subscription
    customer = entry.customer
    card = entry.card
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

list = ChargeBee::Subscription.list({
  :limit => 2,
  "item_id[in]" => "[\"basic\"]"
})

list.each do |entry|
  subscription = entry.subscription
  customer = entry.customer
  card = entry.card
end
```

## Sample Response

```json
{
  "list": [
    {
      "customer": {
        "allow_direct_debit": false,
        "auto_collection": "off",
        "card_status": "no_card",
        "created_at": 1612890919,
        "deleted": false,
        "excess_payments": 0,
        "first_name": "John",
        "id": "__test__8asukSOXdvg4PD",
        "last_name": "Doe",
        "net_term_days": 0,
        "object": "customer",
        "pii_cleared": "active",
        "preferred_currency_code": "USD",
        "promotional_credits": 0,
        "refundable_credits": 0,
        "resource_version": 1612890919000,
        "taxability": "taxable",
        "unbilled_charges": 0,
        "updated_at": 1612890919
      },
      "subscription": {
        "activated_at": 1612890920,
        "billing_period": 1,
        "billing_period_unit": "month",
        "created_at": 1612890920,
        "currency_code": "USD",
        "current_term_end": 1615310120,
        "current_term_start": 1612890920,
        "customer_id": "__test__8asukSOXdvg4PD",
        "deleted": false,
        "due_invoices_count": 1,
        "due_since": 1612890920,
        "has_scheduled_changes": false,
        "id": "__test__8asukSOXdvliPG",
        "mrr": 0,
        "next_billing_at": 1615310120,
        "object": "subscription",
        "remaining_billing_cycles": 1,
        "resource_version": 1612890920000,
        "started_at": 1612890920,
        "status": "active",
        "subscription_items": [
          {
            "amount": 1000,
            "billing_cycles": 1,
            "free_quantity": 0,
            "item_price_id": "basic-USD",
            "item_type": "plan",
            "object": "subscription_item",
            "quantity": 1,
            "unit_price": 1000
          },
          {..}
        ],
        "total_dues": 1100,
        "updated_at": 1612890920
      }
    },
    {..}
  ],
  "next_offset": "[\"1612890918000\",\"230000000081\"]"
}
```

## URL Format

**GET** https://[site].chargebee.com/api/v2/subscriptions

## Input Parameters

- `limit` (optional, integer, default=10, min=1, max=100)
  The number of resources to be returned.

- `offset` (optional, string, max chars=1000)
  Determines your position in the list for pagination. To ensure that the next page is retrieved correctly, always set `offset` to the value of `next_offset` obtained in the previous iteration of the API call.

- `include_deleted` (optional, boolean, default=false)
  Indicates whether to include deleted objects in the list. The deleted objects have the attribute `deleted` as `true` .

## Returns

- `next_offset` (optional, string, max chars=1000)
  This attribute is returned only if more resources are present. To fetch the next set of resources use this value for the input parameter `offset`.

- `subscription` (Subscription object)
  Resource object representing subscription

- `customer` (Customer object)
  Resource object representing customer

- `card` (Card object)
  Resource object representing card
