Rate Limits & Best Practices
Rate limits and best practices for using the BlueGamma API efficiently.
This guide covers rate limits, caching strategies, and best practices for integrating with the BlueGamma API.
Rate Limits
BlueGamma applies rate limits to ensure fair usage and service reliability. The limits below apply to paid API plans.
Requests per second
20
Burst allowance
50 requests
Monthly volume
1,000,000 requests (soft limit)
The burst allowance lets you make up to 50 requests in a short burst before rate limiting kicks in. After that, requests are throttled to 20 per second.
If you exceed the per-second limits, you'll receive a 429 Too Many Requests response with a Retry-After header: wait that many seconds before retrying. The monthly figure is a soft limit: sustained usage beyond it prompts a conversation about your plan rather than hard blocking.
Keys you create in the app on a trial or a self-serve subscription have lower limits: 5 requests per second, bursts of up to 20, and a daily quota.
Limits are set per API key. Every response carries your key's limits in the RateLimit-Policy header, and a request over any of them returns 429.
Best Practices
1. Cache Responses
Curve data doesn't change every second. Cache responses to reduce API calls:
import requests
from functools import lru_cache
from datetime import datetime
API_KEY = "your_api_key"
@lru_cache(maxsize=100)
def _fetch_swap_rate(index: str, maturity: str, cache_minute: str):
response = requests.get(
"https://api.bluegamma.io/v1/swap_rate",
params={
"index": index,
"start_date": "0D",
"maturity_date": maturity,
"fixed_leg_frequency": "6M",
},
headers={"x-api-key": API_KEY}
)
return response.json()
def get_swap_rate(index: str, maturity: str):
# The cache key changes every minute, so a cached rate is at most a minute old
return _fetch_swap_rate(index, maturity, datetime.now().strftime("%Y-%m-%d %H:%M"))Recommended cache durations:
Swap rates
1-5 minutes
Forward curves
1-5 minutes
Historical data
24 hours or longer
Government yields (US)
1-5 minutes
Government yields (other)
24 hours (updated daily)
2. Batch Your Requests
Instead of making separate calls for each tenor, use curve endpoints that return multiple data points:
❌ Inefficient — 8 separate calls:
✅ Efficient — 1 call:
✅ Efficient: many individual swap rates in 1 call
When you need swap rates a curve endpoint doesn't cover, such as different indices, start dates or conventions, send them together to POST /v1/swap_rate/batch, up to 50 per request:
Each item takes the same parameters as /swap_rate, and results come back in the order you sent them. See Fetching a Swap Rate for the full response.
3. Use Appropriate Endpoints
Single swap rate
/swap_rate
Several single swap rates
/swap_rate/batch (POST, up to 50 items)
Full swap curve
/get_swap_curve
Single forward rate
/forward_rate
Full forward curve
/forward_curve
Single discount factor
/discount_factor
Full discount curve
/discount_curve
4. Handle Errors Gracefully
Implement retry logic with backoff. On a 429, wait the number of seconds in the Retry-After header before retrying:
5. Use Valuation Time for Consistency
When building a model that requires multiple data points, use the same valuation_time parameter across all requests to ensure consistency:
This ensures all data points are from the same market snapshot. Use start_date="SPOT" with valuation_time: a tenor such as 0D counts from today, not from the valuation time.
Common Mistakes to Avoid
Calling API in a tight loop
Batch requests or add delays
Not caching historical data
Cache historical queries — they won't change
Fetching full curves when you need 1 point
Use single-point endpoints for one-off queries
Not handling 429 responses
Wait the Retry-After seconds, then retry
Last updated
Was this helpful?

