# Fetching a Swap Rate

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-api>

**✅ Example: Live 10Y SOFR Swap Rate**

```python
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())
```

```bash
curl -X GET "https://api.bluegamma.io/v1/swap_rate?index=SOFR&start_date=0D&maturity_date=10Y&fixed_leg_frequency=1Y&floating_leg_frequency=1Y&fixed_leg_day_count=Actual360&floating_leg_day_count=Actual360" \
  -H "x-api-key: your_api_key_here"
```

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

{% hint style="success" %}
**Want to integrate swap rates into your pricing models?** Book a 15-minute call and we'll help you get started.

[Book a demo →](https://app.lemcal.com/@alivohra/website-demo?back=1)
{% endhint %}

**📆 Example: Historical Swap Rate**

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

```python
params["valuation_time"] = "2025-04-15T12:00:00Z"

```

```bash
curl -X GET "https://api.bluegamma.io/v1/swap_rate?index=SOFR&start_date=0D&maturity_date=10Y&fixed_leg_frequency=1Y&floating_leg_frequency=1Y&fixed_leg_day_count=Actual360&floating_leg_day_count=Actual360&valuation_time=2025-04-15T12%3A00%3A00Z" \
  -H "x-api-key: your_api_key_here"
```

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

🧠 **Tips**

* Use `"0D"` for today, or `"2025-12-31"` for a fixed date
* Make sure fixed and floating legs are consistent with your internal pricing
* Supported indices include: `SOFR`, `SONIA`, `6M EURIBOR`, `3M NIBOR`, and more. See a full list here <https://www.bluegamma.io/interest-rate-api>

***

**Need an API key?**\
📩 <support@bluegamma.io> | 📅 [Book a call](https://app.lemcal.com/@alivohra/website-demo?back=1)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bluegamma.io/documentation/integrations/api/how-to-guides/fetching-a-swap-rate.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
