Chargebee provides HTTP based API which follows the essence of REST*. The HTTP protocol's rules are followed thereby enabling simple HTTP client tools like "curl" to be used.
The following client libraries provide a "easy to use" wrapper around the raw HTTP based API.
Please do mail us at support if you need any other language bindings.
The top language bar allows you to see samples in your preferred language.
Want us to generate ready-to-test snippets?
Login to Chargebee and open the API docs from there and you'll find ready-to-test sample codes based on your Chargebee test site's api key and data.Checkout our collection of sample applications with tutorials on integrating with Chargebee.
Refer to our documentation for a detailed definition & description of all the components in Chargebee.
r a detailed definition & description of all the components in Chargebee.Chargebee follows the REST model of exposing resources as urls. For example, subscriptions are exposed as
The HTTP method (like GET,POST) determines the operation type on the resource. Query parameters allow you to provide additional options to the GET requests. POST parameters provide the data to write operations like creation, modification of resource(s).
By default curl uses GET method. Use -X option to specify a specific HTTP method to use. For passing parameters, use -d option. ( Note: cURL automatically uses to POST method if any parameter is sent via -d option ).
The response is in JSON format. Currently Chargebee does not support any other response format.
Note: Sometimes, while working with Chargebee APIs, you may see undocumented attributes returned in the response. Such attributes should be ignored.
# creates a subscription with customer information and billing details. curl https://{site}.chargebee.com/api/v1/subscriptions \ -u {site_api_key}:\ -d plan_id="no_trial" \ -d customer[first_name]="John" \ -d customer[last_name]="Doe" \ -d customer[email]="john@user.com" \ -d billing_address[first_name]="John" \ -d billing_address[last_name]="Doe" \ -d billing_address[line1]="PO Box 9999" \ -d billing_address[city]="Walnut" \ -d billing_address[state]="California" \ -d billing_address[zip]="91789" \ -d billing_address[country]="US" \ -d customer[auto_collection]="off"
# creates a subscription with customer information and billing details. curl https://{site}.chargebee.com/api/v1/subscriptions \ -u {site_api_key}:\ -d plan_id="no_trial" \ -d customer[first_name]="John" \ -d customer[last_name]="Doe" \ -d customer[email]="john@user.com" \ -d billing_address[first_name]="John" \ -d billing_address[last_name]="Doe" \ -d billing_address[line1]="PO Box 9999" \ -d billing_address[city]="Walnut" \ -d billing_address[state]="California" \ -d billing_address[zip]="91789" \ -d billing_address[country]="US" \ -d customer[auto_collection]="off"
You can use cURL to test Chargebee API from a CLI. When you pass input parameters to the API using -d
or --data-urlencode
options, the HTTP POST
method is used:
curl https://{site}.chargebee.com/api/v1/subscriptions/{subscription_id}/change_term_end -u {site_api_key}:\ -d term_ends_at=1601490600
GET
method by default:
curl https://{site}.chargebee.com/api/v1/subscriptions/{subscription_id} \ -u {site_api_key}:
POST
request without providing any input parameters, use the -X POST
option:
curl -X POST https://{site}.chargebee.com/api/v1/exports/subscriptions \ -u {site_api_key}:
GET
requests with parameters, you must use the -G
option:
curl -X POST https://{site}.chargebee.com/api/v1/v2/orders \ -G \ -u {site_api_key}:\ --data-urlencode limit=3 \ --data-urlencode status[is]="queued"