Chargebee provides an HTTP-based API that follows the principles of REST. The HTTP rules followed allow simple HTTP clients like cURL to be used as well. The URLs are resource-oriented, the request format is form-encoded, and the responses are in JSON.
Depending on the type of operation, the endpoints use one of two HTTP methods:
GET
: Used for all read-only operations such as retrieving a resource or listing a group of resources.POST
: Used for all write operations. Such operations modify the state of a resource.A history of changes to the API is provided in the API Changelog.
Note
Sometimes, while working with Chargebee APIs, you may see undocumented attributes returned in the response. Such attributes should be ignored.
Some features in the API are part of the Early Access Program and are labeled "EAP," "Beta," or "Early Access." Please review the terms and conditions that apply to these features before using them.
Chargebee follows the REST model of exposing resources as urls. For example, subscriptions are exposed as
The Typescript client library provide a corresponding class representation of the resource. For example, subscriptions are represented by
chargebee.subscription
All operations specific to that resource are exposed as class methods in the corresponding resource class. The methods accepts the input params as hash. You could also pass the environment configuration specific to that request as an additional parameter.
The response is in JSON format. Currently Chargebee does not support any other response format. The class wraps the response sent by the server. It has methods that allow you to fetch the specific resource from the result. The class is used to wrap list responses.
Note: Sometimes, while working with Chargebee APIs, you may see undocumented attributes returned in the response. Such attributes should be ignored.
import { ChargeBee, _subscription } from 'chargebee-typescript'; var chargebee = new ChargeBee(); chargebee.configure({site : "{site}", api_key : "{site_api_key}"}); chargebee.subscription.create_with_items("__test__8asz8Ru9WhHOJO",{ subscription_items : [ { item_price_id : "day-pass-USD", unit_price : 100 }, { item_price_id : "basic-USD", billing_cycles : 2, quantity : 1 }] }).request(function(error,result) { if(error){ //handle error console.log(error); }else{ console.log(`${result}`); var subscription: typeof chargebee.subscription = result.subscription; var customer: typeof chargebee.customer = result.customer; var card: typeof chargebee.card = result.card; var invoice: typeof chargebee.invoice = result.invoice; var unbilled_charges: Array<typeof chargebee.unbilled_charge> = result.unbilled_charges; } });
import { ChargeBee, _subscription } from 'chargebee-typescript'; var chargebee = new ChargeBee(); chargebee.configure({site : "{site}", api_key : "{site_api_key}"}); chargebee.subscription.create_with_items("__test__8asz8Ru9WhHOJO",{ subscription_items : [ { item_price_id : "day-pass-USD", unit_price : 100 }, { item_price_id : "basic-USD", billing_cycles : 2, quantity : 1 }] }).request(function(error,result) { if(error){ //handle error console.log(error); }else{ console.log(`${result}`); var subscription: typeof chargebee.subscription = result.subscription; var customer: typeof chargebee.customer = result.customer; var card: typeof chargebee.card = result.card; var invoice: typeof chargebee.invoice = result.invoice; var unbilled_charges: Array<typeof chargebee.unbilled_charge> = result.unbilled_charges; } });
Chargebee provides the following open-source client libraries as a wrapper around the HTTP API:
To view this API reference tailored to the programming language of your choice, select the language in the “Library” dropdown above. Reach out to us at Chargebee Support if you’d like to request any other language bindings.Note
Select the programming language of your choice from the “Library” dropdown at the top of the page.
Note: This library is intended for use on the server, not on the client.
The library can be installed using npmnpm install chargebee-typescript@">=2"Then import the library as:
import {ChargeBee} from 'chargebee-typescript'; var chargebee = new ChargeBee();
The source code for the client library is available as a public repository at github. The code is provided with MIT license. So in case you need any modifications please feel free to do so. If you think it would be useful for other users please do let us know.
Newer versions of client library are released whenever there are new additions to the API. The version
numbering format is major-version.minor-version(s). All
minor releases are backward compatible. Please check the
change notes
for more details.
The latest version details for API V2 are:
Version: 2.24.0
Released On: 2023-07-31
As part of our commitment to enhance the developer experience, we're thrilled to introduce the Chargebee OpenAPI specification. It's the first step in a series of planned improvements.
The Chargebee OpenAPI specification is a version of our API spec that is fully compliant with the OpenAPI Specification v3.0.1. Stay tuned for more updates!