API Integration
The CoW Protocol API provides direct access to the protocol's functionality through RESTful endpoints. This approach offers maximum flexibility and control for backend integrations and custom implementations.
Overview
The API integration allows you to interact with CoW Protocol at the lowest level, giving you complete control over order management, quote fetching, and trade execution. This is ideal for advanced integrations, backend services, and custom trading logic.
Key APIs
Order Book API
The primary API for creating and managing orders on CoW Protocol.
- Base URL:
https://api.cow.fi/ - Purpose: Quote generation, order submission, order management
- Authentication: No API key required for basic operations
Key Endpoints
POST /api/v1/quote- Get trading quotesPOST /api/v1/quote/stream- Stream quotes from individual solvers as they arrive (SSE)POST /api/v1/orders- Submit signed ordersGET /api/v1/orders/{uid}- Get order detailsDELETE /api/v1/orders/{uid}- Cancel ordersGET /api/v1/trades- Get trade history
Quick Start Example
1. Get a Quote
curl -X POST "https://api.cow.fi/mainnet/api/v1/quote" \
-H "Content-Type: application/json" \
-d '{
"sellToken": "0xA0b86a33E6411Ec5d0b9dd2E7dC15A9CAA6C1F8e",
"buyToken": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"sellAmountBeforeFee": "1000000",
"kind": "sell",
"from": "0xYourWalletAddress"
}'
2. Sign and Submit Order
// After getting a quote, sign the order
const order = {
...quoteResponse,
signature: await signOrder(quoteResponse, signer),
signingScheme: "eip712"
}
// Submit the signed order
const response = await fetch('https://api.cow.fi/mainnet/api/v1/orders', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(order)
})
const orderId = await response.text()
3. Monitor Order Status
// Check order status
const orderResponse = await fetch(
`https://api.cow.fi/mainnet/api/v1/orders/${orderId}`
)
const orderDetails = await orderResponse.json()
console.log('Order status:', orderDetails.status)
Streaming Quotes
POST /api/v1/quote/stream takes the same request body as POST /api/v1/quote but returns a Server-Sent Events stream instead of one response. Each solver's quote arrives as its own event, so you can show prices as they come in instead of waiting for the slowest solver.
Each event's data is an OrderQuoteResponse, the same shape POST /api/v1/quote returns, with id set to null. Solvers without a quote send nothing, so you may receive fewer events than there are solvers. If no solver returns a usable quote, the server sends a final error event with a NoLiquidity body, then closes.
curl -N -X POST "https://api.cow.fi/mainnet/api/v1/quote/stream" \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
-d '{
"sellToken": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"buyToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"sellAmountBeforeFee": "1000000000000000000",
"kind": "sell",
"from": "0xYourWalletAddress"
}'
Choosing a timeout
The client side owns this decision. The stream stays open until the request timeout elapses, or every solver has responded, so the value you set determines both how long you wait and which quotes you see. Set timeout (milliseconds) on the request, or close the connection yourself once you have a good-enough quote.
Streaming delivers quotes as they arrive, but it doesn't make any solver respond faster, so it isn't simply a quicker /quote. How much a short timeout helps depends on the pair: fast solvers cover liquid pairs in a few hundred milliseconds, while a thinner pair might rely on a single slower solver that a tight timeout would miss. It's worth tuning the value to the pairs you serve.
Treat the values below as a starting point, not a guarantee. Measure against your own traffic, and raise the timeout for pairs that only slower solvers can price. Quote response times also differ by network. These are guidance as of 2026-06 and shift as solver performance changes.
| Network | timeout (ms) |
|---|---|
| Base, Gnosis Chain, Linea | 1000 |
| Mainnet, BNB Chain | 1800 |
| Arbitrum, Polygon, Avalanche, Ink | 2500 |
Network Endpoints
CoW Protocol APIs are available on multiple networks:
- Mainnet:
https://api.cow.fi/mainnet/api/v1/ - Gnosis Chain:
https://api.cow.fi/xdai/api/v1/ - Arbitrum:
https://api.cow.fi/arbitrum_one/api/v1/ - Base:
https://api.cow.fi/base/api/v1/ - Sepolia (Testnet):
https://api.cow.fi/sepolia/api/v1/
Order Signing
Orders must be cryptographically signed before submission. The signing process involves:
- EIP-712 Domain: Chain-specific domain separator
- Order Struct: Structured order data
- Signature: ECDSA signature or pre-signed order
import { ethers } from 'ethers'
// Example order signing with ethers.js
const domain = {
name: 'Gnosis Protocol',
version: 'v2',
chainId: 1,
verifyingContract: '0x9008D19f58AAbD9eD0D60971565AA8510560ab41'
}
const types = {
Order: [
{ name: 'sellToken', type: 'address' },
{ name: 'buyToken', type: 'address' },
{ name: 'receiver', type: 'address' },
// ... other order fields
]
}
const signature = await signer._signTypedData(domain, types, orderData)
Error Handling
The API returns standard HTTP status codes:
- 200: Success
- 400: Bad Request (invalid parameters)
- 404: Order not found
- 429: Rate limited
- 500: Internal server error
try {
const response = await fetch(apiUrl, requestOptions)
if (!response.ok) {
const error = await response.json()
throw new Error(`API Error: ${error.description}`)
}
return await response.json()
} catch (error) {
console.error('Order submission failed:', error)
}
When to Use the API
- Backend integration: Server-side order management
- Custom trading logic: Advanced order types and strategies
- High-frequency trading: Programmatic order placement
- Multi-chain applications: Cross-chain arbitrage and liquidity
- Analytics platforms: Order and trade data analysis
Rate Limits
- Quote requests: 10 requests/second
- Order submission: 5 requests/second
- General endpoints: 100 requests/minute
Next Steps
For complete API documentation including all endpoints, parameters, and response schemas, see:
- Order Book API Reference - Complete endpoint documentation
- API Documentation - Interactive API explorer
Resources
- Order Book API Reference - Detailed API documentation
- API Explorer - Interactive documentation
- GitHub Examples - Code examples
- Order Signing Guide - Cryptographic signing details