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 Go client library provide a corresponding class representation of the resource. For example, subscriptions are represented by
subscription.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 Result class wraps the response sent by the server. It has methods that allow you to fetch the specific resource from the result. The ResultList 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.
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.CreateWithItems("__test__8asz8Ru9WhHOJO",&subscription.CreateWithItemsRequestParams { SubscriptionItems : []*subscription.CreateWithItemsSubscriptionItemParams { { ItemPriceId : "day-pass-USD", UnitPrice : chargebee.Int64(100), }, { ItemPriceId : "basic-USD", BillingCycles : chargebee.Int32(2), Quantity : chargebee.Int32(1), }, }, }).Request() if err != nil { fmt.Println(err) }else{ Subscription := res.Subscription Customer := res.Customer Card := res.Card Invoice := res.Invoice UnbilledCharges := res.UnbilledCharges } }
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.CreateWithItems("__test__8asz8Ru9WhHOJO",&subscription.CreateWithItemsRequestParams { SubscriptionItems : []*subscription.CreateWithItemsSubscriptionItemParams { { ItemPriceId : "day-pass-USD", UnitPrice : chargebee.Int64(100), }, { ItemPriceId : "basic-USD", BillingCycles : chargebee.Int32(2), Quantity : chargebee.Int32(1), }, }, }).Request() if err != nil { fmt.Println(err) }else{ Subscription := res.Subscription Customer := res.Customer Card := res.Card Invoice := res.Invoice UnbilledCharges := res.UnbilledCharges } }
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.
go get github.com/chargebee/chargebee-go/v32. Import the package in your code:
import "github.com/chargebee/chargebee-go/v3"
Eventually, v2 will become inactive, after which it will no longer receive any new updates. We encourage you to upgrade to v3 at the earliest.
go get github.com/chargebee/chargebee-go2. Import the package in your code:
import "github.com/chargebee/chargebee-go"