Documentation Index
Fetch the complete documentation index at: https://cowswap-mintlify-seo-audit-1777280932.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Authentication
The CoW Protocol BFF API is designed to be accessible without traditional API key authentication for most read operations. However, certain operations require cryptographic signatures to verify ownership.Public Endpoints
Most API endpoints are publicly accessible without authentication:- Token information and pricing
- Market data and slippage calculations
- Pool and yield information
- Transaction simulation
- Account balance queries
- Affiliate statistics (read-only)
Signature-Based Authentication
Affiliate Program Registration
Creating an affiliate code requires EIP-712 signature verification to prove wallet ownership. This ensures that only the wallet owner can bind an affiliate code to their address.EIP-712 Typed Data Structure
When registering an affiliate code, you must sign the following typed data: Domain:Signature Generation Example
Using ethers.js v6:Signature Verification
The API verifies signatures using the following process:- EOA (Externally Owned Account): Standard ECDSA signature verification
- Smart Contract Wallets: ERC-1271 signature verification
Making Authenticated Requests
To register an affiliate code, include the signature in the request body:CORS Policy
The API supports Cross-Origin Resource Sharing (CORS) for browser-based applications:Error Responses
401 Unauthorized
Returned when signature verification fails:400 Bad Request
Returned when wallet address mismatch occurs:409 Conflict
Returned when attempting to register an affiliate code that already exists:Security Considerations
Signature Replay Protection
The API stores signed messages to prevent replay attacks. Each signature can only be used once to register an affiliate code.Chain ID Validation
All affiliate signatures are verified on Ethereum Mainnet (chainId: 1). This prevents cross-chain replay attacks and ensures consistency.Address Normalization
All Ethereum addresses are normalized to lowercase to prevent case-sensitivity issues during verification.Rate Limiting
While the API doesn’t require API keys, reasonable rate limits are enforced to prevent abuse:- Read operations: Higher limits with caching
- Write operations: Lower limits to prevent spam
- SSE connections: Limited concurrent connections per IP
Best Practices
- Cache responses: Respect
Cache-Controlheaders to reduce load - Use appropriate chains: Query data from the correct network
- Handle errors gracefully: Implement retry logic with exponential backoff
- Validate inputs: Ensure addresses and parameters are properly formatted
- Secure signatures: Never share private keys or expose signing mechanisms
Environment Variables
Some features require configuration via environment variables:- CMS_ENABLED: Enable/disable affiliate program features
- DUNE_API_KEY: Enable/disable statistics endpoints
- DATABASE_URL: Required for balance tracking and notifications