Coinbase (CB)

This Lib make integration with coinbase.com in easy way.

Initial setup

  1. Go to this page and generate new key. Select needed rights:

Install lib and make /setup command with code:

Libs.Coinbase.setup();

3. Go to Admin Panel and fill Api Key and Secret Api Key:

4. If you need notifications copy Notifications url and fill it on step 2

5. Fill command to be called on notifications if you need it

Call API methods

All Coinbase API method available here.

For example for method create new address we need 2 commands: /create and /onCreate

/create command:

let account_id = "YOU ACCOUNT ID"
// you can see your all accounts in https://www.coinbase.com/accounts/
// just select needed account and copy it ID from url:
// https://www.coinbase.com/accounts/ID

Libs.Coinbase.apiCall({
  method: "POST",   // method can be GET and POST
  path: "accounts/" + account_id + "/addresses",
  body: { name: "myAddress" },
  onSuccess: "/onApi",
  // onError: "/onApiError"  // onError command
  // background: true // perform api call in background for big timeout limit
  // apiKey - if you need custom Api Key
  // secretApiKey - if you need custom Api Key
})

In body you can pass all fields from Coinbase api.

/onApi command:

Bot.inspect(options.result)

/onApiError command:

Bot.sendMessage(
  "We have error with Coinbase API. Please try later. " +
  options.error // error message from Coinbase Api
)

Bot.sendMessage(
  options.http_status + " " + JSON.stringify(options.result)
)

if you do not have onError command error will be tracked in Eror Tab.

Typical errors

You need to setup Api key. Please see step 3 in setup.

Last updated