@radar/redshift-api-client

REDSHIFT HTTP & WebSocket Client Library

Installation

npm

npm install @radar/redshift-api-client

yarn

yarn add @radar/redshift-api-client

Usage - REDSHIFT Client

The REDSHIFT client acts as a wrapper for the HTTP & WebSocket clients.

Import

import { RedshiftClient } from '@radar/redshift-api-client';

Instantiation

Mainnet

By default, the REDSHIFT client targets mainnet

If you prefer to be explicit, you can pass RedshiftApiUrl.MAINNET into the constructor

Testnet

Client Access

The http and ws getters can be used to access the HTTP & WebSocket client methods.

http - Get Markets Example

Get the active markets

ws - Connect Example

Establish a connection to the REDSHIFT WebSocket API

Usage - HTTP Client

The HTTP client can be used to interact with the REDSHIFT HTTP endpoints.

Import

Instantiation

Mainnet

By default, the HTTP client targets mainnet

If you prefer to be explicit, you can pass RedshiftApiUrl.MAINNET into the constructor

Testnet

Methods

Get Markets

Get the active markets

Get Orders

Get all swap orders for a specific invoice

Get Order

Get a single swap order

Get Order State

Get the state of a single order

Get Order Fund Details

Get the fund details for an order

Get Order Transactions

Get the transactions relating to an order

Get Order Refund Details

Get the refund details for a single order

Usage - WebSocket Client

The WebSocket client can be used to interact with the REDSHIFT WebSocket endpoints. Many WebSocket interactions are promisified to provide a better developer experience.

Import

Instantiation

Mainnet

By default, the WebSocket client targets mainnet

If you prefer to be explicit, you can pass RedshiftApiUrl.MAINNET into the constructor

Testnet

Methods

Connect

Establish a connection to the REDSHIFT WebSocket API

Disconnect

Disconnect from the REDSHIFT WebSocket API

Request Quote

Request a quote for the provided invoice and selected on-chain asset

Subscribe to Order State

Subscribe to order state updates for the provided order id

On Order State Changed

Execute the callback function when an order state update is received

Unsubscribe from Order State

Unsubscribe from order state updates for the provided order id

Subscribe to Block Height

Subscribe to block height updates for the provided network and subnet

On Block Height Changed

Execute the callback function when a block height update is received

Unsubscribe from Block Height

Unsubscribe from block height updates for the provided network and subnet

Request Refund Details

Request refund details for a specific swap order

Broadcast Transaction

Broadcast signed transaction hex to your network of choice

Last updated

Was this helpful?