Skip to main content

Installation

Install the Aries JavaScript SDK using npm or yarn:
npm install @aries-exchange/sdk
# or
yarn add @aries-exchange/sdk

Quick Start

import { AriesClient } from '@aries-exchange/sdk';

// Initialize the client
const client = new AriesClient({
  clientId: 'your_client_id',
  clientSecret: 'your_client_secret'
});

// Get account information
const accounts = await client.accounts.getUserAccounts();
console.log(accounts);

// Place an order
const order = await client.orders.placeOrder({
  symbol: 'AAPL',
  quantity: 10,
  side: 'buy',
  orderType: 'market'
});
console.log(order);

Authentication

The JavaScript SDK supports OAuth2 authentication:
import { AriesClient } from '@aries-exchange/sdk';

const client = new AriesClient({
  clientId: 'your_client_id',
  clientSecret: 'your_client_secret'
});

// The SDK handles token management automatically

Making API Calls

Get Market Data

// Search for securities
const results = await client.marketData.search('AAPL');

// Get equity details
const equity = await client.marketData.getEquityDetails('AAPL');

Manage Orders

// Place a limit order
const order = await client.orders.placeOrder({
  symbol: 'AAPL',
  quantity: 10,
  side: 'buy',
  orderType: 'limit',
  limitPrice: 150.00
});

// Cancel an order
await client.orders.cancelOrder('order_123');

WebSocket Support

Stream real-time data using WebSockets:
import { AriesWebSocket } from '@aries-exchange/sdk';

const ws = new AriesWebSocket({
  clientId: 'your_client_id',
  clientSecret: 'your_client_secret'
});

// Subscribe to market data
ws.on('marketData', (data) => {
  console.log('Received:', data);
});

ws.subscribeMarketData(['AAPL', 'GOOGL']);
ws.connect();

TypeScript Support

The SDK is written in TypeScript and includes full type definitions:
import { AriesClient, Order, OrderSide } from '@aries-exchange/sdk';

const client = new AriesClient({
  clientId: 'your_client_id',
  clientSecret: 'your_client_secret'
});

const order: Order = await client.orders.placeOrder({
  symbol: 'AAPL',
  quantity: 10,
  side: 'buy' as OrderSide,
  orderType: 'market'
});

Error Handling

import { AriesClient, AriesAPIError } from '@aries-exchange/sdk';

const client = new AriesClient({ clientId: '...', clientSecret: '...' });

try {
  const order = await client.orders.placeOrder({...});
} catch (error) {
  if (error instanceof AriesAPIError) {
    console.error('API Error:', error.message);
    console.error('Status Code:', error.statusCode);
  }
}

Requirements

  • Node.js 14 or higher
  • Works in browser environments with bundlers (Webpack, Vite, etc.)

Additional Resources