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:
Type | Description |
---|---|
Order | Core order structure for cross-chain swaps |
QuoteRequest | Parameters for requesting a quote |
QuoteResponse | Quote details returned by the API |
SwapRequest | Data needed to submit a signed order |
SwapResponse | Details of a submitted swap order |
ChainInfo | Metadata about supported blockchain networks |
QueryOrdersParams | Parameters for filtering order queries |
QueryOrdersResponse | Response from querying orders |
OrderQueryResult | Single order result from queries |
OrderStatus | Union type for different order states |
OrderDetails | Detailed order information with events |
WSEvent | WebSocket event payload |
Helper Functions
Function | Description | Category |
---|---|---|
getQuote | Request a quote for a cross-chain swap | Core |
signOrder | Sign an order using a private key | Signing |
signReadableOrder | Sign an order using EIP-712 typed data | Signing |
submitSwap | Submit a signed swap order for execution | Core |
getOrderStatus | Get the current status of an order | Status |
pollOrderStatus | Poll an order status until completion | Status |
getOrderDetails | Get detailed information about an order | Query |
queryOrders | Query historical orders with filters | Query |
AoriWebSocket | WebSocket class for real-time order events | WebSocket |
getChains | Get the list of supported chains | Utility |
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:
- Quotes - Request and manage price quotes
- Swaps - Submit and execute cross-chain swaps
- Orders - Work with order structures and lifecycle
- Status Tracking - Monitor order execution progress
- Signatures - Sign orders securely
- Data & Querying - Query historical order data
- WebSocket Streaming - Real-time order events
- Supported Chains - Blockchain network information