Skip to content

Commit

Permalink
v1.0.4: chore() wrap readme examples in async functions
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagosiebler committed Nov 6, 2024
1 parent 486db19 commit 4095300
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 33 deletions.
76 changes: 46 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,17 @@ const client = new CBAdvancedTradeClient({
apiSecret: advancedTradeCdpAPIKey.privateKey,
});

// Example usage of the CBAdvancedTradeClient
try {
const accounts = await client.getAccounts();
console.log('Get accounts result: ', accounts);
} catch (e) {
console.error('Exception: ', JSON.stringify(e));
async function doAPICall() {
// Example usage of the CBAdvancedTradeClient
try {
const accounts = await client.getAccounts();
console.log('Get accounts result: ', accounts);
} catch (e) {
console.error('Exception: ', JSON.stringify(e));
}
}

doAPICall();
```

#### CBAppClient
Expand Down Expand Up @@ -162,19 +166,23 @@ const client = new CBAppClient({
apiSecret: CBAppKeys.privateKey,
});

try {
// Transfer money between your own accounts
const transferMoneyResult = await client.transferMoney({
account_id: 'your_source_account_id',
type: 'transfer',
to: 'your_destination_account_id',
amount: '0.01',
currency: 'BTC',
});
console.log('Transfer Money Result: ', transferMoneyResult);
} catch (e) {
console.error('Error: ', e);
async function doAPICall() {
try {
// Transfer money between your own accounts
const transferMoneyResult = await client.transferMoney({
account_id: 'your_source_account_id',
type: 'transfer',
to: 'your_destination_account_id',
amount: '0.01',
currency: 'BTC',
});
console.log('Transfer Money Result: ', transferMoneyResult);
} catch (e) {
console.error('Error: ', e);
}
}

doAPICall();
```

#### CBInternationalClient
Expand All @@ -195,13 +203,17 @@ const client = new CBInternationalClient({
// useSandbox: true,
});

try {
// Get asset details
const assetDetails = await client.getAssetDetails({ asset: 'BTC' });
console.log('Asset Details: ', assetDetails);
} catch (e) {
console.error('Exception: ', JSON.stringify(e, null, 2));
async function doAPICall() {
try {
// Get asset details
const assetDetails = await client.getAssetDetails({ asset: 'BTC' });
console.log('Asset Details: ', assetDetails);
} catch (e) {
console.error('Exception: ', JSON.stringify(e, null, 2));
}
}

doAPICall();
```

#### CBExchangeClient
Expand All @@ -222,13 +234,17 @@ const client = new CBExchangeClient({
// useSandbox: true,
});

try {
// Get a single currency by id
const currency = await client.getCurrency('BTC');
console.log('Currency: ', currency);
} catch (e) {
console.error('Exception: ', JSON.stringify(e, null, 2));
async function doAPICall() {
try {
// Get a single currency by id
const currency = await client.getCurrency('BTC');
console.log('Currency: ', currency);
} catch (e) {
console.error('Exception: ', JSON.stringify(e, null, 2));
}
}

doAPICall();
```

See all clients [here](./src/) for more information on all the functions or the [examples](./examples/) for lots of usage examples. You can also check the endpoint function list [here](./docs/endpointFunctionList.md) to find all available functions!
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coinbase-api",
"version": "1.0.3",
"version": "1.0.4",
"description": "Node.js SDK for Coinbase's REST APIs and WebSockets, with TypeScript & strong end to end tests.",
"scripts": {
"clean": "rm -rf dist",
Expand Down

0 comments on commit 4095300

Please sign in to comment.