The Aurora JS Client is a JavaScript library that empowers developers to seamlessly interact with the Aurora REST and WebSocket API. With this library, you can effortlessly access data, retrieve forecast information, and execute various operations using both HTTP requests and WebSocket connections. To get started, please see the Getting Started section in our documentation
Install it using npm or yarn:
npm install aurora-client-js
# or
yarn add aurora-client-js
Our WebSocket and REST APIs are designed around entitlements, ensuring you connect to the right hubs and access the data you need. For personalized examples, including your API key and entitlements, please login.
To utilize the Crypto WebSocket and REST endpoints, there are two key prerequisites that need to be met:
- Subscription Plan: To access our REST API and WebSocket endpoints, you need an active subscription plan. Ensure that your subscription plan is up-to-date and grants you access to the specific API and WebSocket hubs you intend to use.
- API Key: You must possess a valid API key, which serves as your authentication token for accessing both the REST API and WebSocket endpoints. If you haven't generated an API key yet, you can create one by visiting the API Key creation page.
Once you have an API key and an active subscription plan, you are ready to start using both the REST API and WebSocket endpoints to access real-time cryptocurrency data and Forecast insights.
The Aurora JS Client provides an intuitive way to interact with the Aurora REST API.
import { AuroraApiClient } from 'aurora-client-js';
// Create a new API client instance with your API key
const apiKey = 'your-api-key';
const apiClient = new AuroraApiClient(apiKey);
// Use the client to fetch identifiers
apiClient
.getIdentifiers()
.then((identifiers) => {
console.log('Identifiers:', identifiers);
})
.catch((error) => {
console.error('An error happened:', error);
});
// Fetch forecast data
apiClient
.getForecast('X:BTCUSD')
.then((forecastData) => {
console.log('Forecast Data:', forecastData);
})
.catch((error) => {
console.error('An error happened:', error);
});
// Fetch forecast aggregates
apiClient
.getForecastAggregates('X:BTCUSD', {
From: 1695359590,
To: 1695995617,
Interval: 60,
Columns: ['Close'],
ForecastId: 'forecast-id'
})
.then((forecastAggregates) => {
console.log('Forecast Aggregates:', forecastAggregates);
})
.catch((error) => {
console.error('An error happened:', error);
});
The WebSocket client allows real-time interactions with the Aurora WebSocket API.
import { AuroraWSClient } from 'aurora-client-js';
// Create a new WebSocket client instance with your API key
const apiKey = 'your-api-key';
const wsClient = new AuroraWSClient(apiKey);
// Stream forecast aggregates
const { connection, subscription } = wsClient.streamForecastAggregates('your-forecast-id', 'X:BTCUSD', {
next: (data) => console.log('Received forecast aggregate:', data),
complete: () => console.log('SignalR stream completed.'),
error: (err) => console.error('SignalR stream error: ', err),
});
// Disconnect the WebSocket connection
wsClient.disconnect(connection);
// Unsubscribe from stream
wsClient.unsubscribe(subscription);
Method | Arguments | Return Type | Description |
---|---|---|---|
getIdentifiers | callbacks?: ICallbacks[IIdentifier[]> | Promise<IIdentifier[]> | Fetch identifiers for data exploration |
getColumns | callbacks?: ICallbacks<IColumn[]> | Promise<IColumn[]> | Fetch available columns |
getForecast | identifier: string, callbacks?: ICallbacks<IForecast[]> | Promise<IForecast[]> | Retrieve forecast information |
getForecastAggregates | identifier: string, params: IRequestParams, callbacks?: ICallbacks<IForecastAggregate[]> | Promise<IForecastAggregate[]> | Fetch forecast aggregates |
getLatestForecastAggregates | identifier: string, params: ILatestAggregatesRequestParams, callbacks?: ICallbacks | Promise<IForecastAggregate> | Get latest forecast aggregates |
getForecastAccuracy | identifier: string, ForecastId: string, callbacks?: ICallbacks | Promise<IForecastAccuracy> | Retrieve forecast accuracy |
getHistoricalAggregates | identifier: string, params: IHistoricalAggregatesRequestParams, callbacks?: ICallbacks | Promise<ICryptoAggregates> | Fetch crypto aggregates |
streamForecastAggregates | forecastId: string, identifier: string, period: number (minutes), subscriber: IStreamSubscriber<IForecastAggregate> | - | Stream forecast aggregates |
streamCryptoAggregates | identifier: string, subscriber: IStreamSubscriber<WSCryptoAggregate> | - | Stream crypto aggregates |
Type | Description |
---|---|
IIdentifier | Identifier type |
IColumn | Column information |
IForecast | Forecast information |
IAggregate | Aggregate data point |
IForecastAggregate | Forecast aggregate information |
IForecastAccuracy | Forecast accuracy information |
IRequestParams | Request parameters for specific calls |
ILatestAggregatesRequestParams | Request parameters for latest aggregates |
Identifier type.
-
identifier
: string
Column information.
-
name
: string -
type
: string -
isNullable
: boolean
Forecast information.
-
id
: string -
name
: string
Aggregate data point.
-
Close
: number -
Timestamp
: number
Forecast aggregate information.
-
from
: number -
to
: number -
step
: number -
aggregates
: Array of IAggregate.
Forecast accuracy information.
-
Close_mae
: number -
Close_rmse
: number
Request parameters for specific calls.
-
Identifier
: string -
StartDate
(optional): string -
EndDate
(optional): string -
Fields
(optional): string array
Request parameters for latest aggregates.
-
Identifier
: string -
Fields
(optional): string array