Tools for Aspens Development¶
Aspens offers tools and SDKs to help you build and interact with an Aspens Markets Stack.
aspens-cli¶
The aspens-cli
lets you interact with an Aspens Markets Stack from the command line. It has two modes:
REPL Mode¶
REPL mode gives you an interactive shell:
# Start in REPL mode
aspens-cli repl --endpoint https://api.your-ams-instance.com
# Once in REPL mode
> connect --api-key your-api-key
Connected to Aspens Markets Stack at api.your-ams-instance.com
> markets list
ID | Base Token | Quote Token | Status
--------------|-----------|-----------|---------
USDT:USDC | USDT (ETH) | USDC (HBAR) | ACTIVE
ETH:USDC | ETH (ETH) | USDC (POLY) | ACTIVE
CLI Mode¶
CLI mode runs single commands for scripts and automation:
# List all markets
aspens-cli --endpoint https://api.your-ams-instance.com markets list --api-key your-api-key
# Get orderbook for a specific market
aspens-cli --endpoint https://api.your-ams-instance.com orderbook get USDT:USDC --depth 10 --api-key your-api-key
# Execute a trade
aspens-cli --endpoint https://api.your-ams-instance.com trade place --market USDT:USDC --side buy --price 1.001 --quantity 100 --api-key your-api-key
Features¶
- Market Management: Create, modify, and monitor markets
- Order Management: Place, cancel, and query orders
- Wallet Integration: Connect and manage multiple blockchain wallets
- Batch Operations: Execute multiple operations in sequence
- Scriptable: Use in shell scripts and automated workflows
- Output Formats: Get results in text, JSON, or CSV
Software Development Kits (SDKs)¶
Rust SDK¶
The Rust SDK provides a type-safe library for Aspens integration:
use aspens_sdk::{
AmsClient, AmsConfig, MarketId, OrderSide, OrderType, TradeRequest
};
async fn place_order() -> Result<(), Box<dyn Error>> {
// Initialize client
let config = AmsConfig::new("https://api.your-ams-instance.com")
.with_api_key("your-api-key");
let client = AmsClient::new(config)?;
// Place an order
let request = TradeRequest::new(
MarketId::from("USDT:USDT"),
OrderSide::Buy,
OrderType::Limit,
"1.0000".parse()?, // price
"100".parse()?, // quantity
);
let order_result = client.place_order(request).await?;
println!("Order placed: {}", order_result.order_id);
Ok(())
}
TypeScript SDK¶
The TypeScript SDK works for web and Node.js applications:
import { AmsClient, OrderSide, OrderType } from '@aspens/sdk';
async function placeOrder() {
// Initialize client
const client = new AmsClient({
endpoint: 'https://api.your-ams-instance.com',
apiKey: 'your-api-key'
});
// Place an order
try {
const orderResult = await client.placeOrder({
marketId: 'USDT:USDT',
side: OrderSide.Buy,
type: OrderType.Limit,
price: '1.0000',
quantity: '100'
});
console.log(`Order placed: ${orderResult.orderId}`);
} catch (error) {
console.error('Failed to place order:', error);
}
}
SDK Benefits¶
- Type Safety: Catch errors at compile time
- Async Support: Works with modern async patterns
- Error Handling: Specific error types for easier debugging
- Wallet Integration: Connect to multiple blockchain wallets
- Documentation: Includes examples and inline docs
Getting Started¶
Install the tools with:
# Install the CLI
npm install -g @aspens/cli
# Or install the TypeScript SDK
npm install @aspens/sdk
# Or add the Rust SDK to your Cargo.toml
# [dependencies]
# aspens-sdk = "0.1.0"
Find more documentation at: - CLI Documentation - Rust SDK Documentation - TypeScript SDK Documentation