Coinbase Pro Node
DEPRECATED — The official Node.js library for Coinbase Pro
Install / Use
npx skills add coinbase/coinbase-pro-nodeInstalls into whichever agent you are using.
README
Coinbase Pro

Note: The gdax package is deprecated and might have to be removed from NPM.
Please migrate to the coinbase-pro package to ensure future compatibility.
The official Node.js library for Coinbase's Pro API.
Features
- Easy functionality to use in programmatic trading
- A customizable, websocket-synced Order Book implementation
- API clients with convenient methods for every API endpoint
- Abstracted interfaces – don't worry about HMAC signing or JSON formatting; the library does it for you
Installation
npm install coinbase-pro
You can learn about the API responses of each endpoint by reading our documentation.
Quick Start
The Coinbase Pro API has both public and private endpoints. If you're only interested in
the public endpoints, you should use a PublicClient.
const CoinbasePro = require('coinbase-pro');
const publicClient = new CoinbasePro.PublicClient();
All methods, unless otherwise specified, can be used with either a promise or callback API.
Using Promises
publicClient
.getProducts()
.then(data => {
// work with data
})
.catch(error => {
// handle the error
});
The promise API can be used as expected in async functions in ES2017+
environments:
async function yourFunction() {
try {
const products = await publicClient.getProducts();
} catch (error) {
/* ... */
}
}
Using Callbacks
Your callback should accept three arguments:
error: contains an error message (string), ornullif no error was encounteredresponse: a generic HTTP response abstraction created by therequestlibrarydata: contains data returned by the Coinbase Pro API, orundefinedif an error was encountered
publicClient.getProducts((error, response, data) => {
if (error) {
// handle the error
} else {
// work with data
}
});
NOTE: if you supply a callback, no promise will be returned. This is to
prevent potential UnhandledPromiseRejectionWarnings, which will cause future
versions of Node to terminate.
const myCallback = (err, response, data) => {
/* ... */
};
const result = publicClient.getProducts(myCallback);
result.then(() => {
/* ... */
}); // TypeError: Cannot read property 'then' of undefined
Optional Parameters
Some methods accept optional parameters, e.g.
publicClient.getProductOrderBook('BTC-USD', { level: 3 }).then(book => {
/* ... */
});
To use optional parameters with callbacks, supply the options as the first parameter(s) and the callback as the last parameter:
publicClient.getProductOrderBook(
'ETH-USD',
{ level: 3 },
(error, response, book) => {
/* ... */
}
);
The Public API Client
const publicClient = new CoinbasePro.PublicClient(endpoint);
productIDoptional - defaults to 'BTC-USD' if not specified.endpointoptional - defaults to 'https://api.pro.coinbase.com' if not specified.
Public API Methods
publicClient.getProducts(callback);
// Get the order book at the default level of detail.
publicClient.getProductOrderBook('BTC-USD', callback);
// Get the order book at a specific level of detail.
publicClient.getProductOrderBook('LTC-USD', { level: 3 }, callback);
publicClient.getProductTicker('ETH-USD', callback);
publicClient.getProductTrades('BTC-USD', callback);
// To make paginated requests, include page parameters
publicClient.getProductTrades('BTC-USD', { after: 1000 }, callback);
Wraps around getProductTrades, fetches all trades with IDs >= tradesFrom and
<= tradesTo. Handles pagination and rate limits.
const trades = publicClient.getProductTradeStream('BTC-USD', 8408000, 8409000);
// tradesTo can also be a function
const trades = publicClient.getProductTradeStream(
'BTC-USD',
8408000,
trade => Date.parse(trade.time) >= 1463068e6
);
publicClient.getProductHistoricRates('BTC-USD', callback);
// To include extra parameters:
publicClient.getProductHistoricRates(
'BTC-USD',
{ granularity: 3600 },
callback
);
publicClient.getProduct24HrStats('BTC-USD', callback);
publicClient.getCurrencies(callback);
publicClient.getTime(callback);
The Authenticated API Client
The private exchange API endpoints require you
to authenticate with a Coinbase Pro API key. You can create a new API key in your
exchange account's settings. You can also specify
the API URI (defaults to https://api.pro.coinbase.com).
const key = 'your_api_key';
const secret = 'your_b64_secret';
const passphrase = 'your_passphrase';
const apiURI = 'https://api.pro.coinbase.com';
const sandboxURI = 'https://api-public.sandbox.pro.coinbase.com';
const authedClient = new CoinbasePro.AuthenticatedClient(
key,
secret,
passphrase,
apiURI
);
Like PublicClient, all API methods can be used with either callbacks or will
return promises.
AuthenticatedClient inherits all of the API methods from
PublicClient, so if you're hitting both public and private API endpoints you
only need to create a single client.
Private API Methods
authedClient.getCoinbaseAccounts(callback);
authedClient.getPaymentMethods(callback);
authedClient.getAccounts(callback);
const accountID = '7d0f7d8e-dd34-4d9c-a846-06f431c381ba';
authedClient.getAccount(accountID, callback);
const accountID = '7d0f7d8e-dd34-4d9c-a846-06f431c381ba';
authedClient.getAccountHistory(accountID, callback);
// For pagination, you can include extra page arguments
authedClient.getAccountHistory(accountID, { before: 3000 }, callback);
const accountID = '7d0f7d8e-dd34-4d9c-a846-06f431c381ba';
authedClient.getAccountTransfers(accountID, callback);
// For pagination, you can include extra page arguments
authedClient.getAccountTransfers(accountID, { before: 3000 }, callback);
const accountID = '7d0f7d8e-dd34-4d9c-a846-06f431c381ba';
authedClient.getAccountHolds(accountID, callback);
// For pagination, you can include extra page arguments
authedClient.getAccountHolds(accountID, { before: 3000 }, callback);
// Buy 1 BTC @ 100 USD
const buyParams = {
price: '100.00', // USD
size: '1', // BTC
product_id: 'BTC-USD',
};
authedClient.buy(buyParams, callback);
// Sell 1 BTC @ 110 USD
const sellParams = {
price: '110.00', // USD
size: '1', // BTC
product_id: 'BTC-USD',
};
authedClient.sell(sellParams, callback);
// Buy 1 LTC @ 75 USD
const params = {
side: 'buy',
price: '75.00', // USD
size: '1', // LTC
product_id: 'LTC-USD',
};
authedClient.placeOrder(params, callback);
const orderID = 'd50ec984-77a8-460a-b958-66f114b0de9b';
authedClient.cancelOrder(orderID, callback);
// Cancels "open" orders
authedClient.cancelOrders(callback);
// `cancelOrders` may require you to make the request multiple times until
// all of the "open" orders are deleted.
// `cancelAllOrders` will handle making these requests for you asynchronously.
// Also, you can add a `product_id` param to only delete orders of that product.
// The data will be an array of the order IDs of all orders which were cancelled
authedClient.cancelAllOrders({ product_id: 'BTC-USD' }, callback);
authedClient.getOrders(callback);
// For pagination, you can include extra page arguments
// Get all orders of 'open' status
authedClient.getOrders({ after: 3000, status: 'open' }, callback);
const orderID = 'd50ec984-77a8-460a-b958-66f114b0de9b';
authedClient.getOrder(orderID, callback);
const params = {
product_id: 'LTC-USD',
};
authedClient.getFills(params, callback);
// For pagination, you can include extra page arguments
authedClient.getFills({ before: 3000 }, callback);
- [
getFundings](https://docs.pro
Related Skills
node-connect
385.5kDiagnose OpenClaw Android, iOS, or macOS node pairing, QR/setup code, route, auth, and connection failures.
blender-python-addon
40.5kBlender Python add-on rules for operators, panels, properties, registration, testing, and API-safe scripting
flutter-development-guidelines-cursorrules-prompt-file
40.5kCursor rules for Flutter development with MVVM architecture, Riverpod state management, Material widgets, and Dart style guidelines.
commit-push-pr
140.7kCommit, push, and open a PR
