Fetching a Swap Rate

Use the /swap_rate endpoint to calculate the par rate for a vanilla interest rate swap, given an index, start/maturity, and leg conventions.

This is the most common use case for pulling current or historical market swap rates directly into your software or spreadsheet. For more details: https://www.bluegamma.io/interest-rate-apiarrow-up-right

✅ Example: Live 10Y SOFR Swap Rate

import requests

url = "https://api.bluegamma.io/v1/swap_rate"
headers = {"x-api-key": "your_api_key_here"}
params = {
    "index": "SOFR",
    "start_date": "0D",                 # Today
    "maturity_date": "10Y",            # 10 years from today
    "fixed_leg_frequency": "1Y",
    "floating_leg_frequency": "1Y",
    "fixed_leg_day_count": "Actual360",
    "floating_leg_day_count": "Actual360"
}

response = requests.get(url, headers=headers, params=params)
print(response.json())

Returns the par swap rate based on today's curve.

circle-check

📆 Example: Historical Swap Rate

Add valuation_time to calculate the swap rate as it would have been on a past date/time.

This returns the rate using the market data from that exact point in time (in UTC).

🧠 Tips


Need an API key? 📩 [email protected]envelope | 📅 Book a callarrow-up-right

Last updated

Was this helpful?