-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(): add private cb exchange sample
- Loading branch information
1 parent
4b493e3
commit 8b04193
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { CBExchangeClient } from '../../src/index.js'; | ||
// import { CBExchangeClient } from 'coinbase-api'; | ||
|
||
// Initialize the client, you can pass in api keys here if you have them but they are not required for public endpoints | ||
const client = new CBExchangeClient({ | ||
apiKey: 'yourAPIKeyHere', | ||
apiSecret: 'yourAPISecretHere', | ||
//This is the passphrase you provided when creating this API key. NOT your account password. | ||
apiPassphrase: 'yourAPIPassPhraseHere', | ||
|
||
// Optional, connect to sandbox instead: https://public-sandbox.exchange.coinbase.com/apikeys | ||
// useSandbox: true, | ||
}); | ||
|
||
async function privateExchangeCalls() { | ||
try { | ||
const orders = await client.getOrders(); | ||
console.log('Orders: ', orders); | ||
|
||
const order = await client.getOrder({ | ||
order_id: '0c892cb3-2824-4662-8be3-99c8e879f606', | ||
market_type: 'market', | ||
}); | ||
console.log('Order: ', order); | ||
|
||
const cancelOrderResult = await client.cancelOrder({ | ||
order_id: '0c892cb3-2824-4662-8be3-99c8e879f606', | ||
product_id: 'BTC-GBP', | ||
}); | ||
console.log('cancelOrder result: ', cancelOrderResult); | ||
} catch (e) { | ||
console.error('Error: ', e); | ||
} | ||
} | ||
|
||
privateExchangeCalls(); |