cb-pro-api
TypeScript icon, indicating that this package has built-in type declarations

0.0.21 • Public • Published

cb-pro-api

This package is a thin wrapper around the popular HTTP client, Axios, that abstracts the basic request authentication needed for the Coinbase Pro REST API.

Installing

Using npm:

$ npm install cb-pro-api

Using yarn:

$ yarn add cb-pro-api

Usage

Import the createClient function and pass it your API keys to create an Axios HTTP client that will send authenticated requests.

const { createClient } = require('cb-pro-api');

const cb = createClient({
  apiKey: process.env.CB_API_KEY,
  secret: process.env.CB_API_SECRET,
  passphrase: process.env.CB_API_PASSPHRASE,
});

Use the Coinbase Pro REST API docs to see the available methods.

Example

const { createClient } = require('cb-pro-api');

const cb = createClient({
  apiKey: process.env.CB_API_KEY,
  secret: process.env.CB_API_SECRET,
  passphrase: process.env.CB_API_PASSPHRASE,
});

// Place a market order for $5 worth of BTC
await cb.post('/orders', {
  type: 'market',
  funds: 5,
  side: 'buy',
  product_id: 'BTC-USD',
});

// Get the latest ETH-USD ticker
const { data: ticker } = await cb.get('/products/ETH-USD/ticker');
console.log(ticker);
// {
//   ticker: {
//     trade_id: 99415874,
//     price: '2478.9',
//     size: '0.01419161',
//     time: '2021-04-17T06:35:30.077144Z',
//     bid: '2478.69',
//     ask: '2478.86',
//     volume: '243742.21783082'
//   }
// }

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.21
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.21
    0
  • 0.0.1
    0
  • 0.0.2
    0

Package Sidebar

Install

npm i cb-pro-api

Weekly Downloads

0

Version

0.0.21

License

MIT

Unpacked Size

9.16 kB

Total Files

9

Last publish

Collaborators

  • lucas-lin