npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aurora-client-js

v0.0.18

Published

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 b

Downloads

19

Readme

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

| 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 Definitions

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

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