growwapi
Version:
NodeJS SDK for Groww trading APIs
38 lines (37 loc) • 1.37 kB
JavaScript
import snakecaseKeys from 'snakecase-keys';
import { HttpClient } from '../utils/http';
import { buildUrlWithParams } from '../utils/url';
export class Orders {
constructor(baseUrl) {
this.http = new HttpClient(baseUrl, '/order');
}
async create(params) {
return await this.http.post('/create', snakecaseKeys(params));
}
async modify(params) {
return await this.http.post('/modify', snakecaseKeys(params));
}
async cancel(params) {
return await this.http.post('/cancel', snakecaseKeys(params));
}
async getTrades(params) {
const url = buildUrlWithParams(`/trades/${params.growwOrderId}`, params);
return (await this.http.get(url)).tradeList;
}
async status(params) {
const url = buildUrlWithParams(`/status/${params.growwOrderId}`, params);
return await this.http.get(url);
}
async statusByReference(params) {
const url = buildUrlWithParams(`/status/reference/${params.orderReferenceId}`, params);
return await this.http.get(url);
}
async getOrders(params) {
const url = buildUrlWithParams('/list', params);
return (await this.http.get(url)).orderList;
}
async details(params) {
const url = buildUrlWithParams(`/detail/${params.growwOrderId}`, params);
return await this.http.get(url);
}
}