Scope
How to get the last subscription of each individual customer via API?
Is there any way to get the recent subscription using API?
What is the parameter to get each customer's subscription by month via API?
Summary
You can make use of the List Subscription API call and use the parameter 'sort_by[<sort-order>]' to filter the subscription by period.
Solution
Step 1: You can make use of this API call to list subscriptions.
Step 2: To filter the subscription by period.
sort_by[<sort-order>]
optional, string filter
Sorts based on the specified attribute.
Supported attributes: created_at, updated_at
Supported sort-orders: asc, desc
Example → sort_by[asc] = "created_at"
This will sort the result based on the 'created_at' attribute in ascending(earliest first) order.
Step 3: To filter the subscription by customer.
id[<operator>]
optional, string filter
A unique and immutable identifier for the subscription. If not provided, it is autogenerated.
Supported operators: is, is_not, starts_with, in, not_in
Example → id[is] = "8gsnbYfsMLds"
customer_id[<operator>]
optional, string filter
Identifier of the customer with whom this subscription is associated.
Supported operators: is, is_not, starts_with, in, not_in
Example → customer_id[is_not] = "8gsnbYfsMLds"
Step 4: To filter the subscription by Plan.
item_id[<operator>]
optional, string filter
The plan item code.
Supported operators: is, is_not, starts_with, in, not_in
Example → item_id[is] = "silver"
item_price_id[<operator>]
optional, string filter
The plan item price code.
Supported operators : is, is_not, starts_with, in, not_in
Example → item_price_id[is] = "silver-USD-monthly"
Step 5: To filter the subscription by subscription status.
status[<operator>]
optional, enumerated string filter
The current state of the subscription. Possible values are: future, in_trial, active, non_renewing, paused, cancelled.
Supported operators: is, is_not, in, not_in
Example → status[is] = "active"
Related Articles
How to list more than 10 items when listing information via API?
How to view the details of changes to the unbilled charges via the API ?
Request Payment Method via the API
What are the Chargebee API limits?