Best Practices
Battle-tested patterns for building production applications with VecTrade.Architecture
Use Environment Variables for Configuration
Never hardcode API keys or base URLs:Separate Read and Write Paths
Use different API keys with scoped permissions for different concerns:Use Sandbox for Development
Performance
Batch Requests
Reduce latency and rate limit consumption with batch endpoints:Use Field Filtering
Request only the fields you need to reduce payload size and latency:Cache Appropriately
| Data Type | Recommended TTL | Reason |
|---|---|---|
| Fundamentals | 1 hour | Updates quarterly |
| Technicals | 1–5 min | Recalculated on new bars |
| News | 5 min | New articles arrive frequently |
| Quotes | 0 (no cache) | Real-time by nature |
| Analyst Ratings | 15 min | Updates infrequently |
| Options Chains | 1 min | Greeks change with price |
Use Async for Concurrent Fetches
Reliability
Handle All Error Types
Implement Circuit Breakers
For high-throughput applications, wrap API calls with a circuit breaker:Use Idempotency Keys
For webhook creation and other write operations, use idempotency keys to prevent duplicates:Security
Rotate API Keys Regularly
Verify Webhook Signatures
Always verify HMAC signatures on incoming webhooks. Never trust payload data without verification:Use Scoped Keys
Create API keys with minimum required permissions:| Use Case | Recommended Scope |
|---|---|
| Frontend display | quotes:read, news:read |
| Screening tool | screener:read, technicals:read |
| Webhook management | webhooks:write |
| Full admin | All scopes (backend only) |
Monitoring
Track Rate Limit Usage
Log Request IDs
Every response includes arequest_id. Log it for debugging: