growwapi
Version:
NodeJS SDK for Groww trading APIs
15 lines (14 loc) • 562 B
JavaScript
import { isEpochISO8601 } from '../utils/date';
import { HttpClient } from '../utils/http';
import { buildUrlWithParams } from '../utils/url';
export class HistoricData {
constructor(baseUrl) {
this.http = new HttpClient(baseUrl, '/historical/candle');
}
async get(params) {
if (!isEpochISO8601(params.startTime) || !isEpochISO8601(params.endTime)) {
throw new Error('startTime and endTime must be in Epoch or ISO8601 format');
}
return (await this.http.get(buildUrlWithParams('/range', params)));
}
}