It introduces a few changes that unify the way one can use this library.
Methods from AuthenticatedClient and PublicClient accept an (optional) object as the first argument and an (optional) callback as the last (second) argument, e.g.
Simplify the way to connect to the sandbox endpoint by using sandbox flag, e.g.
const PublicClient = new CoinbasePro.PublicClient({
sandbox: true,
});
Throw an error when incomplete parameters are provided e.g.
// Throws an error because `granularity` is undefined.
AuthenticatedClient.getProductHistoricRates(callback);
// Throws an error because `id` is undefined.
AuthenticatedClient.cancelOrder(callback);
// Throws an error because `payment_method_id` is undefined.
AuthenticatedClient.depositPayment(
{ amount: '100.00', currency: 'USD' },
callback
);
Remove auto connection from the WebsocketClient constructor. This small modification does not do much but gives the developers(who use this library) more flexibility to establish the connection when they need it. Now, one can separate the declaration of WebsocketClient from the connection to the websocket, e.g.
const websocket = new CoinbasePro.WebsocketClient({
product_ids: 'ETH-DAI',
});
// (somewhere else in your code) when you need you can connect to the websocket.
websocket.connect();
// when you do not need the connection you can disconnect from the websocket.
websocket.disconnect();
// when you need it again
websocket.connect();
Avoid using properties that can be extracted from other arguments, e.g.
const AuthenticatedClient = new CoinbasePro.AuthenticatedClient({
key: 'my-API-key',
secret: 'my-API-secret',
passphrase: 'my-API-passphrase',
product_id: 'ETH-BTC',
});
// You do not define `type`.
// You do not define `product_id` because you saved it in `AuthenticatedClient`.
// buy 1 ETH @ 0.01 (LIMIT because you provide `price`)
const order = AuthenticatedClient.buy({
price: '0.01',
size: '1',
});
// buy ETH (MARKET because you provide `funds`)
const order = AuthenticatedClient.buy({
funds: '0.01',
});
// You do not define `type` because you provide `account_id`.
const report = AuthenticatedClient.createReport({
start_date: 'some_start_date',
end_date: 'some_end_date',
account_id: 'some_account_id',
format: 'csv',
});
Updates the Typescript types to include all supported functions.
What does this PR do?
It introduces a few changes that unify the way one can use this library.
AuthenticatedClient
andPublicClient
accept an (optional) object as the first argument and an (optional) callback as the last (second) argument, e.g.sandbox
flag, e.g.WebsocketClient
constructor. This small modification does not do much but gives the developers(who use this library) more flexibility to establish the connection when they need it. Now, one can separate the declaration ofWebsocketClient
from the connection to the websocket, e.g.Related PRs
productID
by using it in all requests that requireproduct_id
and let the user to drop it, e.g.Other features
README
to match the changes.Backwards compatibility
This PR removes all deprecation warnings that were introduced in https://github.com/coinbase/coinbase-pro-node/pull/178 and contains incompatible changes. So, this PR can be a good start towards
v1.0.0-beta
release.