3commas-ts
v1.1.8
Published
3Commas api wrapper for two type of api keys
Maintainers
Readme
3Commas API provider for TypeScript
Official source documentation here.
Install
npm install 3commas-tsyarn add 3commas-tspnpm add 3commas-tsUsage
import { API } from '3commas-ts';
const GET = async () => {
const apiKey = process.env.API_KEY;
const apiSecret = process.env.API_SECRET;
const api = new API({
apiKeyType: 'selfGenerated',
key: apiKey,
secrets: apiSecret,
forcedMode: 'paper'
});
try {
const response = await api.getSmartTradeHistory({ per_page: 10, status: 'active' });
return Response.json(response);
} catch (error: any) {
console.error(error);
return Response.json(error.message, { status: 500 });
}
};3Commas offers two different approaches to generation API keys:
- System-generated pair (api key + secret)
- Self-generated rsa pair (api-key + public key + private key)
The first one is created automatically. For latter you need to use, for example, official binance key generator. More information for this case here.
Also you can get more understanding of these approaches using the 3commas signature calculator.
Custom Request
customRequest(method: string, version: number, path: string, payload?: any)Websocket
subscribeSmartTrade(callback?: (data: WebSocket.Data) => void)
subscribeDeal(callback?: (data: WebSocket.Data) => void)
unsubscribe()