Skip to content


Switch branches/tags


Failed to load latest commit information.
Latest commit message
Commit time

Xendit API Go Client reference Coverage Status Go Report Card

This library is the abstraction of Xendit API for access from applications written with Go.


For the API documentation, check Xendit API Reference.

For the details of this library, see the GoDoc.


Install xendit-go with:

go get -u

Then, import it using:

import (

with $product$ is the product of Xendit such as invoice and balance.

Go Module Support

This library supports Go modules by default. Simply require xendit-go in go.mod with a version like so:


go 1.13

require ( v1.0.0

And use the same style of import paths as above:

import (

with $product$ is the product of Xendit such as invoice and balance.

Using xendit-go with $GOPATH

If you are still using $GOPATH and not planning to migrate to go mod, installing xendit-go would require installing its (only) dependency validator via

go get -u

Please note that this means you are using master of validator and effectively miss out on its versioning that's gomod-based.

After installing validator, xendit-go can be installed normally.


The following pattern is applied throughout the library for a given $product$:

Without Client

If you're only dealing with a single secret key, you can simply import the packages required for the products you're interacting with without the need to create a client.

import (

// Setup
xendit.Opt.SecretKey = "examplesecretkey"

xendit.SetAPIRequester(apiRequester) // optional, useful for mocking

// Create
resp, err := $product$.Create($product$.CreateParams)

// Get
resp, err := $product$.Get($product$.GetParams)

// GetAll
resp, err := $product$.GetAll($product$.GetAllParams)

With Client

If you're dealing with multiple secret keys, it is recommended you use client.API. This allows you to create as many clients as needed, each with their own individual key.

import (

// Basic setup
xenCli := client.New("examplesecretkey")

// or with optional, useful-for-mocking `exampleAPIRequester`
xenCli := client.New("examplesecretkey").WithAPIRequester(exampleAPIRequester)

// Create
resp, err := xenCli.$product$.Create($product$.CreateParams)

// Get
resp, err := xenCli.$product$.Get($product$.GetParams)

// GetAll
resp, err := xenCli.$product$.GetAll($product$.GetAllParams)

Sub-Packages Documentations

The following is a list of pointers to documentations for sub-packages of xendit-go.


For any requests, bugs, or comments, please open an issue or submit a pull request.


After modifying the code, please make sure that the code passes all test cases.

Run all tests

go test ./...

Run tests for a package

go test ./invoice

Run a single test

go test ./invoice -run TestCreateInvoice

Run integration tests

SECRET_KEY=<your secret key> go run -race ./integration_test


Before making any commits, please install pre-commit. To install pre-commit, follow the installation steps.

After installing the pre-commit, please install the needed dependencies:

make init

After the code passes everything, please submit a pull request.