Skip to main content

index/classes/ChartService.md

Chart Service Class

Provides methods for fetching historical chart data.

Example​

const chartService = new ChartService(httpClient);

// Get hourly chart data for last 24 hours
const now = Math.floor(Date.now() / 1000);
const oneDayAgo = now - (24 * 60 * 60);
const chart = await chartService.getChart({
tokenName: 'mytoken',
from: oneDayAgo,
to: now,
resolution: 3600
});

Extends​

  • BaseService

Constructors​

Constructor​

new ChartService(http, debugMode?): ChartService

Parameters​

ParameterType
httpHttpClient
debugMode?boolean

Returns​

ChartService

Overrides​

BaseService.constructor

Methods​

getChart()​

getChart(options): Promise<ChartResult>

Get historical chart data

Retrieve OHLC (Open, High, Low, Close) candlestick data for token price history. Data is aggregated at the specified resolution interval.

Parameters​

ParameterTypeDescription
optionsGetChartOptionsChart fetch options

Returns​

Promise<ChartResult>

Promise resolving to chart data with candlesticks

Example​

// Get hourly data for last 24 hours
const now = Math.floor(Date.now() / 1000);
const oneDayAgo = now - (24 * 60 * 60);
const chart = await chartService.getChart({
tokenName: 'anime',
from: oneDayAgo,
to: now,
resolution: 3600
});
console.log(`Got ${chart.dataPoints.length} candlesticks`);

// Get minute-level data for 1 hour
const oneHourAgo = now - 3600;
const minuteChart = await chartService.getChart({
tokenName: 'anime',
from: oneHourAgo,
to: now,
resolution: 60
});

setJwtAuth()​

setJwtAuth(jwtAuth): void

Set the JWT authentication manager. Allows dynamic configuration of JWT auth after service creation.

Parameters​

ParameterTypeDescription
jwtAuthJwtAuthJWT auth manager instance

Returns​

void

Inherited from​

BaseService.setJwtAuth