# List subscriptions

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


[Eventually Consistent](/docs/api/v1/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/v1/subscriptions \
     -G  \
     -u {site_api_key}:\
     --data-urlencode limit=2
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
ListResult result = Subscription.List()
		.Limit(2)
		.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"
    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),
    }).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),
}
  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)
            .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)
            .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
    });
    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
]);
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
    )
)
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
})

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

## Sample Response

```json
{
  "list": [
    {
      "card": {
        "card_type": "american_express",
        "customer_id": "__test__5SK0bLNFRFuBvJV6x",
        "expiry_month": 12,
        "expiry_year": 2019,
        "gateway": "chargebee",
        "iin": "378282",
        "last4": "0005",
        "masked_number": "***********0005",
        "object": "card",
        "status": "valid"
      },
      "customer": {
        "account_credits": 0,
        "allow_direct_debit": false,
        "auto_collection": "on",
        "card_status": "valid",
        "created_at": 1517506669,
        "excess_payments": 0,
        "id": "__test__5SK0bLNFRFuBvJV6x",
        "object": "customer",
        "payment_method": {
          "gateway": "chargebee",
          "object": "payment_method",
          "reference_id": "tok___test__5SK0bLNFRFuBvJm6y",
          "status": "valid",
          "type": "card"
        },
        "refundable_credits": 0,
        "taxability": "taxable"
      },
      "subscription": {
        "activated_at": 1517506669,
        "created_at": 1517506669,
        "current_term_end": 1519925869,
        "current_term_start": 1517506669,
        "due_invoices_count": 0,
        "has_scheduled_changes": false,
        "id": "__test__5SK0bLNFRFuBvJV6x",
        "object": "subscription",
        "plan_id": "no_trial",
        "plan_quantity": 1,
        "started_at": 1517506669,
        "status": "active"
      }
    },
    {..}
  ],
  "next_offset": "[\"1517506669000\",\"182000000066\"]"
}
```

## URL Format

**GET** https://[site].chargebee.com/api/v1/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.

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