Coinbase (CB)
​
This Lib make integration with coinbase.com in easy way.

Initial setup

    1.
    ​Register​
    2.
    Go to this page and generate new key. Select needed rights:
Install lib and make /setup command with code:
1
Libs.Coinbase.setup();
Copied!
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:
1
let account_id = "YOU ACCOUNT ID"
2
// you can see your all accounts in https://www.coinbase.com/accounts/
3
// just select needed account and copy it ID from url:
4
// https://www.coinbase.com/accounts/ID
5
​
6
Libs.Coinbase.apiCall({
7
method: "POST", // method can be GET and POST
8
path: "accounts/" + account_id + "/addresses",
9
body: { name: "myAddress" },
10
onSuccess: "/onApi",
11
// onError: "/onApiError" // onError command
12
// background: true // perform api call in background for big timeout limit
13
// apiKey - if you need custom Api Key
14
// secretApiKey - if you need custom Api Key
15
})
Copied!
In body you can pass all fields from Coinbase api.
/onApi command:
1
Bot.inspect(options.result)
Copied!
​
/onApiError command:
1
Bot.sendMessage(
2
"We have error with Coinbase API. Please try later. " +
3
options.error // error message from Coinbase Api
4
)
5
​
6
Bot.sendMessage(
7
options.http_status + " " + JSON.stringify(options.result)
8
)
Copied!
if you do not have onError command error will be tracked in Eror Tab.
Last modified 1yr ago