0.0.18 • Published 7 months ago

aurora-client-js v0.0.18

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Aurora JS Client

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

Table of Contents

Installation

Install it using npm or yarn:

npm install aurora-client-js
# or
yarn add aurora-client-js

Usage

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:

  1. 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.
  2. 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.

REST API

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);
	});

WebSocket API

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);

API Reference

MethodArgumentsReturn TypeDescription
getIdentifierscallbacks?: ICallbacks[IIdentifier[]>Promise<IIdentifier[]>Fetch identifiers for data exploration
getColumnscallbacks?: ICallbacks<IColumn[]>Promise<IColumn[]>Fetch available columns
getForecastidentifier: string, callbacks?: ICallbacks<IForecast[]>Promise<IForecast[]>Retrieve forecast information
getForecastAggregatesidentifier: string, params: IRequestParams, callbacks?: ICallbacks<IForecastAggregate[]>Promise<IForecastAggregate[]>Fetch forecast aggregates
getLatestForecastAggregatesidentifier: string, params: ILatestAggregatesRequestParams, callbacks?: ICallbacksPromise<IForecastAggregate>Get latest forecast aggregates
getForecastAccuracyidentifier: string, ForecastId: string, callbacks?: ICallbacksPromise<IForecastAccuracy>Retrieve forecast accuracy
getHistoricalAggregatesidentifier: string, params: IHistoricalAggregatesRequestParams, callbacks?: ICallbacksPromise<ICryptoAggregates>Fetch crypto aggregates
streamForecastAggregatesforecastId: string, identifier: string, period: number (minutes), subscriber: IStreamSubscriber<IForecastAggregate>-Stream forecast aggregates
streamCryptoAggregatesidentifier: string, subscriber: IStreamSubscriber<WSCryptoAggregate>-Stream crypto aggregates

Type Definitions

TypeDescription
IIdentifierIdentifier type
IColumnColumn information
IForecastForecast information
IAggregateAggregate data point
IForecastAggregateForecast aggregate information
IForecastAccuracyForecast accuracy information
IRequestParamsRequest parameters for specific calls
ILatestAggregatesRequestParamsRequest parameters for latest aggregates

IIdentifier

Identifier type.

  • identifier: string

IColumn

Column information.

  • name: string
  • type: string
  • isNullable: boolean

IForecast

Forecast information.

  • id: string
  • name: string

IAggregate

Aggregate data point.

  • Close: number
  • Timestamp: number

IForecastAggregate

Forecast aggregate information.

  • from: number
  • to: number
  • step: number
  • aggregates: Array of IAggregate.

IForecastAccuracy

Forecast accuracy information.

  • Close_mae: number
  • Close_rmse: number

IRequestParams

Request parameters for specific calls.

  • Identifier: string
  • StartDate (optional): string
  • EndDate (optional): string
  • Fields (optional): string array

ILatestAggregatesRequestParams

Request parameters for latest aggregates.

  • Identifier: string
  • Fields (optional): string array
0.0.18

7 months ago

0.0.17

7 months ago

0.0.16

8 months ago

0.0.15

8 months ago

0.0.14

8 months ago

0.0.13

8 months ago

0.0.12

8 months ago

0.0.11

8 months ago

0.0.10

8 months ago

0.0.9

8 months ago

0.0.8

8 months ago

0.0.7

8 months ago

0.0.6

8 months ago

0.0.5

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago