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
const client = new RedshiftClient(RedshiftApiUrl.MAINNET);
const client = new RedshiftClient(RedshiftApiUrl.TESTNET);
const markets = await client.http.getMarkets();
await client.ws.connect();
import { HttpClient } from '@radar/redshift-api-client';
const client = new HttpClient();
const client = new HttpClient(RedshiftApiUrl.MAINNET);
const client = new HttpClient(RedshiftApiUrl.TESTNET);
const markets = await client.getMarkets();
const orders = await client.getOrders(invoice);
// Or filter by the on-chain asset used to fund the swap
const orders = await client.getOrders(invoice, OnChainTicker.ETH);
const order = await client.getOrder(orderId);
const state = await client.getOrderState(orderId);
const state = await client.getOrderFundDetails(orderId);
const state = await client.getOrderTransactions(orderId);