npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@zufans/coinbase-advanced-trade

v1.0.0

Published

A comprehensive Node.js SDK for Coinbase Advanced Trade API

Downloads

17

Readme

Coinbase Advanced Trade SDK

A comprehensive Node.js SDK for the Coinbase Advanced Trade API, providing easy-to-use methods for trading, account management, and market data retrieval.

Installation

npm install @zufans/coinbase-advanced-trade

Quick Start

import CoinbaseAdvancedTrade from '@zufans/coinbase-advanced-trade';

// Initialize the client
const client = new CoinbaseAdvancedTrade(
  'your-api-key-name',
  'your-api-secret'
);

// List accounts
const accounts = await client.listAccounts();
console.log(accounts);

// Get product information
const product = await client.getProduct('BTC-USD');
console.log(product);

// Create a market order
const order = await client.createOrder(
  'unique-client-order-id',
  'BTC-USD',
  'BUY',
  {
    market_market_ioc: {
      quote_size: '100.00'
    }
  }
);
console.log(order);

Authentication

You'll need to obtain API credentials from Coinbase:

  1. Go to Coinbase Advanced Trade
  2. Create a new API key
  3. Save your API Key Name and Private Key securely

API Reference

Initialization

const client = new CoinbaseAdvancedTrade(apiKeyName, apiSecret);

Account Methods

listAccounts(params?)

List trading accounts.

const accounts = await client.listAccounts({
  limit: 250,
  cursor: 'optional-cursor'
});

getAccount(accountUUID)

Get details of a specific account.

const account = await client.getAccount('account-uuid-here');

Order Methods

createOrder(clientOrderId, productId, side, orderConfiguration, options?)

Create a new order.

// Market order
const marketOrder = await client.createOrder(
  'client-order-id',
  'BTC-USD',
  'BUY',
  {
    market_market_ioc: {
      quote_size: '100.00'
    }
  }
);

// Limit order
const limitOrder = await client.createOrder(
  'client-order-id',
  'BTC-USD',
  'BUY',
  {
    limit_limit_gtc: {
      base_size: '0.001',
      limit_price: '50000.00',
      post_only: false
    }
  }
);

cancelOrders(orderIds)

Cancel one or more orders.

const result = await client.cancelOrders(['order-id-1', 'order-id-2']);

listOrders(filters?)

List historical orders with optional filters.

const orders = await client.listOrders({
  product_ids: ['BTC-USD'],
  order_status: ['FILLED'],
  limit: 100
});

getOrder(orderId, clientOrderId?)

Get details of a specific order.

const order = await client.getOrder('order-id');

editOrder(orderId, price, size, clientOrderId?)

Edit an existing order.

const result = await client.editOrder('order-id', '51000.00', '0.002');

Product Methods

listProducts(queryParams?)

List available trading products.

const products = await client.listProducts({
  limit: 100,
  offset: 0
});

getProduct(productId)

Get details of a specific product.

const product = await client.getProduct('BTC-USD');

getBestBidAsk(productId?, params?)

Get best bid/ask for products.

const bidAsk = await client.getBestBidAsk('BTC-USD');

getCandles(productId, queryParams)

Get historical candle data.

const candles = await client.getCandles('BTC-USD', {
  start: Math.floor(Date.now() / 1000) - 86400, // 24 hours ago
  end: Math.floor(Date.now() / 1000),
  granularity: 'ONE_HOUR',
  limit: 24
});

Available granularities: ONE_MINUTE, FIVE_MINUTE, FIFTEEN_MINUTE, THIRTY_MINUTE, ONE_HOUR, TWO_HOUR, SIX_HOUR, ONE_DAY

getMarketTrades(productId, queryParams)

Get recent market trades.

const trades = await client.getMarketTrades('BTC-USD', {
  limit: 100
});

Utility Methods

getKeyPermissions()

Check API key permissions.

const permissions = await client.getKeyPermissions();

getCurrency(base)

Get currency information.

const currency = await client.getCurrency('BTC');

Order Configuration Types

The SDK supports all Coinbase Advanced Trade order types:

  • Market Orders: market_market_ioc
  • Limit Orders: limit_limit_gtc, limit_limit_gtd, limit_limit_fok
  • Stop Limit Orders: stop_limit_stop_limit_gtc, stop_limit_stop_limit_gtd
  • Bracket Orders: trigger_bracket_gtc, trigger_bracket_gtd

Error Handling

try {
  const order = await client.createOrder(/* ... */);
} catch (error) {
  console.error('Order creation failed:', error.message);
  // Handle error appropriately
}

Individual Function Imports

You can also import individual functions:

import { 
  listAccounts, 
  createOrder, 
  getProduct,
  cbToken 
} from '@zufans/coinbase-advanced-trade';

// Use with your own credentials
const accounts = await listAccounts('api-key', 'api-secret');

Requirements

  • Node.js 16+
  • Valid Coinbase Advanced Trade API credentials

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Support

For API-related questions, refer to the Coinbase Advanced Trade API Documentation.

For SDK issues, please open an issue on GitHub.