Skip to content

GreenGeorge/go-rajaongkir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go RajaOngkir

Simple way to make requests to the RajaOngkir API. Uses Go's net/http. Inspired by rapito/go-shopify

CircleCI codecov GoDoc goreport

Installation

go get github.com/GreenGeorge/go-rajaongkir

Usage

  ...
  import "github.com/GreenGeorge/go-rajaongkir"
  ...

  const apiKey = "YOUR_API_KEY_HERE"
  const baseURL = "api.rajaongkir.com/starter"

  // Initialize RajaOngkir
  // BYO http.Client if you wish. Pass it as the 3rd parameter
  // otherwise go-rajaongkir will preconfigure one for you
  r := rajaongkir.New(apiKey, baseURL, nil)

  // Get a list of provinces
  // Returns []Province
  provinces, err := r.GetProvinces()

  // Get a list of cities
  // Returns []City
  cities, err := r.GetCities()

  origin      := 501      // origin province code
  destination := 114      // destination province code
  weight      := 1700     // weight in grams
  courier     := "jne"    // delivery service

  // Get the shipping cost
  // Right now you can only pass JNE as courier
  // Returns []Cost
  shippingCosts, err := r.GetCost(origin, destination, weight, courier)
  ...

Contributing

Got ideas? Open an issue for discussion. Contributions are always welcome. Send a PR with tests.

About

Simple RajaOngkir API implementation in Go.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages