Aori SDK Reference

The recommended way to interact with the Aori API is by using one of our SDKs. Today, Aori offers fine-tuned Typescript and Rust libraries to make your integration as easy as possible and give you the best experience when interacting with Aori.

Installation

Aori-TS

A TypeScript library for interacting with the Aori API.

npm install @aori/aori-ts

Aori-RS

A Rust library for interacting with the Aori API.

cargo install aori-rs

Types Reference

All TypeScript types and interfaces available in the Aori SDK:

TypeDescription
OrderCore order structure for cross-chain swaps
QuoteRequestParameters for requesting a quote
QuoteResponseQuote details returned by the API
SwapRequestData needed to submit a signed order
SwapResponseDetails of a submitted swap order
ChainInfoMetadata about supported blockchain networks
QueryOrdersParamsParameters for filtering order queries
QueryOrdersResponseResponse from querying orders
OrderQueryResultSingle order result from queries
OrderStatusUnion type for different order states
OrderDetailsDetailed order information with events
WSEventWebSocket event payload

Helper Functions

FunctionDescriptionCategory
getQuoteRequest a quote for a cross-chain swapCore
signOrderSign an order using a private keySigning
signReadableOrderSign an order using EIP-712 typed dataSigning
submitSwapSubmit a signed swap order for executionCore
getOrderStatusGet the current status of an orderStatus
pollOrderStatusPoll an order status until completionStatus
getOrderDetailsGet detailed information about an orderQuery
queryOrdersQuery historical orders with filtersQuery
AoriWebSocketWebSocket class for real-time order eventsWebSocket
getChainsGet the list of supported chainsUtility

Aori Instance Usage

The Aori class provides a stateful interface for interacting with the Aori protocol. It manages chain information, domain data, and token metadata.

Creating an Instance

Instance Creation

import { Aori } from '@aori-io/aori-ts';

// Basic usage
const aori = await Aori.create();

// With API key and token pre-loading
const aori = await Aori.create(
  'https://api.aori.io',
  'wss://api.aori.io', 
  'your_api_key',
  true // Load tokens during initialization
);

Core Operations

Essential Methods

// Chain information
const allChains = aori.getAllChains();
const ethereum = aori.getChain('ethereum');

// Token management
await aori.loadTokens('ethereum');
const tokens = aori.getTokens('ethereum');
const allTokens = aori.getAllTokens();

// Trading operations
const quote = await aori.getQuote(quoteRequest);
const { signature } = await aori.signReadableOrder(quote, signer, userAddress);
const result = await aori.executeSwap(quote, swapConfig);

// Order tracking
const status = await aori.getOrderStatus(orderHash);
const orders = await aori.queryOrders({ offerer: userAddress });

Integration Examples

Basic Swap Flow

Complete Swap Example

import { getQuote, signOrder, submitSwap } from '@aori/aori-ts';

// 1. Request a quote
const quote = await getQuote({
  offerer: '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b',
  recipient: '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b',
  inputToken: '0x4200000000000000000000000000000000000006',
  outputToken: '0xaf88d065e77c8cc2239327c5edb3a432268e5831',
  inputAmount: '1000000000000000000',
  inputChain: 'base',
  outputChain: 'arbitrum'
});

// 2. Sign the order
const signature = await signOrder(quote, { privateKey: 'your-private-key' });

// 3. Submit the swap
const swap = await submitSwap({
  orderHash: quote.orderHash,
  signature: signature
});

console.log('Swap submitted:', swap.orderHash);

Status Monitoring

Track Order Status

import { getOrderStatus, pollOrderStatus } from '@aori/aori-ts';

// Get current status
const status = await getOrderStatus('0x1234567890abcdef...');
console.log('Current status:', status.status);

// Poll until completion
const finalStatus = await pollOrderStatus('0x1234567890abcdef...', {
  interval: 5000,
  timeout: 300000
});
console.log('Final status:', finalStatus.status);

Real-time Events

WebSocket Streaming

import { AoriWebSocket } from '@aori/aori-ts';

const ws = new AoriWebSocket('wss://api.aori.io');

ws.on('order', (event) => {
  console.log(`Order ${event.order.orderHash}: ${event.eventType}`);
});

await ws.connect();

Detailed Documentation

For comprehensive documentation on each function and type, visit the dedicated pages: