Overview
The o1.exchange Trading API enables programmatic trading with enterprise-grade features including built-in MEV protection, Permit2 support for gasless approvals, and automatic slippage handling.Key Benefits
- MEV Protection: Private mempool routing to prevent sandwich attacks
- Gasless Approvals: One-time Permit2 signatures for unlimited trading
- Automatic Slippage: Built-in slippage protection with customizable limits
Prerequisites
Wallet
Ethereum wallet with private key
Gas Fees
ETH for transaction costs
Runtime
Node.js environment
Quick Start
1. Generate API Key
Navigate to API Trading
2. Create Transaction Batch
- Request
- Response
Endpoint: Body:
POST https://api.o1.exchange/api/v2/orderHeaders:3. Sign Transaction and Permit2
Implementation Details
Implementation Details
For each transaction in the response:
-
Sign Permit2 (if present):
- Extract the EIP-712 typed data from
permit2.eip712 - Sign using wallet’s
signTypedDatamethod - Replace the signature placeholder in transaction data
- Extract the EIP-712 typed data from
-
Sign the transaction:
- Create transaction object from the unsigned data
- Sign using wallet’s
signTransactionmethod
4. Submit Transaction
- Request
- Response
Endpoint: Body:
POST https://api.o1.exchange/api/v2/order/completeHeaders:Sample Scripts & Examples
Complete Sample Repository
GitHub Repository: https://github.com/CohumanSpace/o1-apiThis repository contains complete sample scripts for using the o1.exchange API, including:
- Interactive CLI trading application
- Complete integration examples
- Proper error handling patterns
- Environment setup guides
Interactive Example
Complete CLI Trading App
See
execute-trade-interactive.js in the sample repository for a fully functional CLI trading application that demonstrates all integration steps with proper error handling and user interaction.Setup Environment
Create a.env.local file:
Run Interactive CLI
Advanced Features
Permit2 Integration
Gasless token approvals using EIP-712 signatures
- Automatic signature placeholder replacement
- One-time approval for unlimited trading
- Reduced gas costs for frequent traders
MEV Protection
Protection against sandwich attacks
- Private mempool routing
- Reduced slippage from MEV bots
- Enable with
mevProtection: true
Slippage Control
Specify
slippageBps in basis points where 100 bps = 1%Recommendations:- Normal conditions: 300 bps (3%)
- Volatile tokens: 500-1000 bps (5-10%)
- Large trades: Increase as needed
