API Overview
The Cropr backend exposes a RESTful API built with NestJS and documented with Swagger/OpenAPI.
Base URL
https://api.cropr.finance
Authentication
Most API endpoints require authentication via JWT Bearer tokens:
Authorization: Bearer <your-jwt-token>
Tokens are obtained through the Authentication endpoint using Google OAuth.
Request Format
- Content-Type:
application/json - Accept:
application/json
Response Format
All responses follow a consistent JSON structure:
{
"statusCode": 200,
"data": { ... },
"message": "Success"
}
Error Response
{
"statusCode": 400,
"message": "Error description",
"error": "Bad Request"
}
Rate Limiting
- 100 requests per 60 seconds per client
- Rate limit headers are included in responses
- Exceeding the limit returns a
429 Too Many Requestsstatus
Common Query Parameters
| Parameter | Type | Description |
|---|---|---|
chainId | number | Blockchain network ID (1, 137, 42161, etc.) |
walletAddress | string | User's wallet address |
protocol | string | DeFi protocol name (aave, compound, uniswap, etc.) |
API Modules
| Module | Base Path | Description |
|---|---|---|
| Authentication | /auth | Google OAuth and JWT management |
| Portfolio | / | Portfolio metrics and analytics |
| Tokens | / | Token balances and prices |
| DEX | /dex | DEX swap, liquidity, and pool data |
| Lending | /lending | Lending and borrowing operations |
| Staking | /stake | Staking operations |
| Bridge | /bridge | Cross-chain bridge operations |
| Vaults | /vaults | Vault deposit/withdraw |
| Exchange | /exchange | CEX integration |
| Referral | /referral | Referral system |
| AI Insights | /ai-insights | AI-powered token analysis and portfolio reports |
WebSocket Events
Real-time updates are delivered via Socket.io:
const socket = io('https://api.cropr.finance');
// Listen for balance updates
socket.on('balanceUpdate', (data) => {
console.log('Balance updated:', data);
});
// Listen for transaction confirmations
socket.on('transactionConfirmed', (data) => {
console.log('Transaction confirmed:', data);
});
Swagger Documentation
Interactive API documentation is available at:
https://api.cropr.finance/api-docs
Powered by @nestjs/swagger, it provides:
- Full endpoint documentation
- Request/response schemas
- Try-it-out functionality