shrimpy-node
The official Node.js library for the Shrimpy Developer API https://developers.shrimpy.io/docs
Installation
npm install shrimpy-node
You can learn about the API responses of each endpoint by reading our documentation.
Quick Start
All asynchronous methods return promises.
Promise Example
client
.getTicker('kucoin')
.then(data => {
})
.catch(error => {
});
Async Example
The promises can be used as expected in async
functions in ES2017+ environments:
async function yourFunction() {
try {
const ticker = await client.getTicker('kucoin');
} catch (error) {
}
}
Public Client
const Shrimpy = require('shrimpy-node');
const publicClient = new Shrimpy.ShrimpyApiClient();
The public client can only use public methods.
Private Client
const publicKey = 'your_public_key';
const privateKey = 'your_private_key';
const Shrimpy = require('shrimpy-node');
const privateClient = new Shrimpy.ShrimpyApiClient(publicKey, privateKey);
The private client can use public and private methods.
Public Methods
const ticker = await client.getTicker(
'kucoin'
);
User Methods
const users = await client.getUsers();
const user = await client.getUser(
'701e0d16-1e9e-42c9-b6a1-4cada1f395b8'
);
const userId = await client.createUser();
await client.enableUser(
'701e0d16-1e9e-42c9-b6a1-4cada1f395b8'
);
await client.disableUser(
'701e0d16-1e9e-42c9-b6a1-4cada1f395b8'
);
User API Keys Methods
const publicKeys = await client.getApiKeys(
'701e0d16-1e9e-42c9-b6a1-4cada1f395b8'
);
const apiKeys = await client.createApiKeys(
'701e0d16-1e9e-42c9-b6a1-4cada1f395b8'
);
const apiKeys = await client.deleteApiKeys(
'701e0d16-1e9e-42c9-b6a1-4cada1f395b8',
'51ac18b7d208f59b3c88acbb1ecefe6ba6be6ea4edc07e7a2450307ddc27ab80'
);
const permissions = await client.getPermissions(
'701e0d16-1e9e-42c9-b6a1-4cada1f395b8',
'51ac18b7d208f59b3c88acbb1ecefe6ba6be6ea4edc07e7a2450307ddc27ab80'
);
await client.setPermissions(
'701e0d16-1e9e-42c9-b6a1-4cada1f395b8',
'51ac18b7d208f59b3c88acbb1ecefe6ba6be6ea4edc07e7a2450307ddc27ab80',
true,
false
);
Account Methods
const accounts = await client.getAccounts(
'701e0d16-1e9e-42c9-b6a1-4cada1f395b8'
);
const account = await client.getAccount(
'701e0d16-1e9e-42c9-b6a1-4cada1f395b8',
123
);
const accountId = await client.createAccount(
'701e0d16-1e9e-42c9-b6a1-4cada1f395b8',
'binance',
'GOelL5FT6TklPxAzICIQK25aqct52T2lHoKvtcwsFla5sbVXmeePqVJaoXmXI6Qd',
'SelUuFq1sF2zGd97Lmfbb4ghITeziKo9IvM5NltjEdffatRN1N5vfHXIU6dsqRQw'
);
Note: The createAccount
method accepts a fifth optional parameter: passphrase. The passphrase is only required for some exchanges, such as Coinbase Pro.
await client.deleteAccount(
'701e0d16-1e9e-42c9-b6a1-4cada1f395b8',
456
);
Trading Methods
const balance = await client.getBalance(
'701e0d16-1e9e-42c9-b6a1-4cada1f395b8',
123
);
await client.rebalance(
'701e0d16-1e9e-42c9-b6a1-4cada1f395b8',
123
);
const rebalancePeriodHours = await client.getRebalancePeriod(
'701e0d16-1e9e-42c9-b6a1-4cada1f395b8',
123
);
await client.setRebalancePeriod(
'701e0d16-1e9e-42c9-b6a1-4cada1f395b8',
123,
24
);
const strategy = await client.getStrategy(
'701e0d16-1e9e-42c9-b6a1-4cada1f395b8',
123
);
await client.setStrategy(
'701e0d16-1e9e-42c9-b6a1-4cada1f395b8',
123,
{ isDynamic: false, allocations: [{ symbol: 'BTC', percent: '50' }, { symbol: 'ETH', percent: '50' }] }
);
await client.allocate(
'701e0d16-1e9e-42c9-b6a1-4cada1f395b8',
123,
{ isDynamic: false, allocations: [{ symbol: 'USDT', percent: '100' }] }
);
const tradeId = await client.createTrade(
'701e0d16-1e9e-42c9-b6a1-4cada1f395b8',
123,
'BTC',
'ETH',
new Decimal('0.01')
);
const trade = await client.getTrade(
'701e0d16-1e9e-42c9-b6a1-4cada1f395b8',
123,
'72dff099-54c0-4a32-b046-5c19d4f55758'
);
const activeTrades = await client.getActiveTrades(
'701e0d16-1e9e-42c9-b6a1-4cada1f395b8',
123,
);