> For the complete documentation index, see [llms.txt](https://www.bluegamma.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.bluegamma.io/documentation/integrations/api/how-to-guides/fetching-a-swap-rate.md).

# 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. See the [API Reference](/documentation/integrations/api/api-reference.md) for every parameter.

**✅ Example: Market-Standard Quote**

Pass only `index`, `start_date` and `maturity_date`. When you leave out `fixed_leg_frequency`, the swap is priced at the index's market-standard conventions, so the rate matches the on-screen quote for that index. Use `SPOT` as the start date to start on the index's spot date.

```python
import requests

url = "https://api.bluegamma.io/v1/swap_rate"
headers = {"x-api-key": "your_api_key_here"}
params = {
    "index": "SOFR",
    "start_date": "SPOT",              # The index's spot date
    "maturity_date": "10Y"             # 10 years from the start date
}

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=SPOT&maturity_date=10Y" \
  -H "x-api-key: your_api_key_here"
```

**Response:**

```json
{
  "index": "SOFR",
  "start_date": "2026-10-08",
  "maturity_date": "2036-10-08",
  "fixed_leg_first_payment_date": "2027-10-08",
  "floating_leg_first_payment_date": "2027-10-08",
  "floating_leg_frequency": "12M",
  "floating_leg_day_count": "Actual360",
  "fixed_leg_frequency": "12M",
  "fixed_leg_day_count": "Actual360",
  "valuation_time": "2026-10-06T08:37:41.631278",
  "swap_rate": 4.878,
  "timestamp": "2026-10-06T08:37:17"
}
```

The response shows the conventions that were used. Here the swap starts on the spot date, two business days after the valuation date, with annual fixed and floating legs on Actual/360.

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

To price a swap with your own conventions, pass `fixed_leg_frequency` and any other leg parameters. Passing `fixed_leg_frequency` prices the swap with the conventions you give instead of the market-standard ones.

```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.

**📆 Example: Historical Swap Rate**

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

```python
params["start_date"] = "SPOT"  # the spot date as of the valuation time
params["valuation_time"] = "2025-04-15T12:00:00Z"
```

```bash
curl -X GET "https://api.bluegamma.io/v1/swap_rate?index=SOFR&start_date=SPOT&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). Use `SPOT` or a fixed date as the start date in historical requests: a tenor such as `0D` counts from today, not from the valuation time.

**📦 Example: Several Swap Rates in One Call**

Use `POST /v1/swap_rate/batch` to price up to 50 swaps in one request. Each item takes the same parameters as the GET endpoint, and items can mix indices, conventions and valuation times. Results come back in the order you sent them.

```python
import requests

url = "https://api.bluegamma.io/v1/swap_rate/batch"
headers = {"x-api-key": "your_api_key_here"}
payload = {
    "items": [
        {"index": "SOFR", "start_date": "SPOT", "maturity_date": "5Y"},
        {"index": "6M EURIBOR", "start_date": "SPOT", "maturity_date": "10Y"},
        {"index": "SONIA", "start_date": "0D", "maturity_date": "5Y", "fixed_leg_frequency": "6M"},
        {"index": "SOFR", "start_date": "2026-02-30", "maturity_date": "5Y"}  # Invalid date
    ]
}

response = requests.post(url, headers=headers, json=payload)
print(response.json())
```

```bash
curl -X POST "https://api.bluegamma.io/v1/swap_rate/batch" \
  -H "x-api-key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "items": [
      {"index": "SOFR", "start_date": "SPOT", "maturity_date": "5Y"},
      {"index": "6M EURIBOR", "start_date": "SPOT", "maturity_date": "10Y"},
      {"index": "SONIA", "start_date": "0D", "maturity_date": "5Y", "fixed_leg_frequency": "6M"},
      {"index": "SOFR", "start_date": "2026-02-30", "maturity_date": "5Y"}
    ]
  }'
```

**Response:**

```json
{
  "results": [
    {
      "status": 200,
      "data": {
        "index": "SOFR",
        "start_date": "2026-10-08",
        "maturity_date": "2031-10-08",
        "fixed_leg_first_payment_date": "2027-10-08",
        "floating_leg_first_payment_date": "2027-10-08",
        "floating_leg_frequency": "12M",
        "floating_leg_day_count": "Actual360",
        "fixed_leg_frequency": "12M",
        "fixed_leg_day_count": "Actual360",
        "valuation_time": "2026-10-06T08:37:41.775680",
        "swap_rate": 4.751,
        "timestamp": "2026-10-06T08:37:17"
      }
    },
    {
      "status": 200,
      "data": {
        "index": "6M EURIBOR",
        "start_date": "2026-10-08",
        "maturity_date": "2036-10-08",
        "fixed_leg_first_payment_date": "2027-10-08",
        "floating_leg_first_payment_date": "2027-04-08",
        "floating_leg_frequency": "6M",
        "floating_leg_day_count": "Actual360",
        "fixed_leg_frequency": "12M",
        "fixed_leg_day_count": "Thirty360BondBasis",
        "valuation_time": "2026-10-06T08:37:41.776406",
        "swap_rate": 3.54,
        "timestamp": "2026-10-06T08:37:16"
      }
    },
    {
      "status": 200,
      "data": {
        "index": "SONIA",
        "start_date": "2026-10-06",
        "maturity_date": "2031-10-06",
        "fixed_leg_first_payment_date": "2027-04-06",
        "floating_leg_first_payment_date": "2027-04-06",
        "floating_leg_frequency": "6M",
        "floating_leg_day_count": "Actual365Fixed",
        "fixed_leg_frequency": "6M",
        "fixed_leg_day_count": "Actual365Fixed",
        "valuation_time": "2026-10-06T08:37:41.776983",
        "swap_rate": 4.6459,
        "timestamp": "2026-10-06T08:37:27"
      }
    },
    {
      "status": 422,
      "error": "Invalid start_date format. Must be YYYY-MM-DD or a tenor string matching pattern: [0-9]+[DWMY] (e.g., 1Y, 3M, 2W, 5D)."
    }
  ]
}
```

Each result carries the `status` the GET endpoint would have returned. A failed item doesn't fail the request: it returns its own `status` and `error`, as the fourth item shows, and every other item is still priced.

🧠 **Tips**

* Use `"SPOT"` for the index's spot date, `"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 the full list in [Available Indices](/documentation/data-coverage/whats-available/available-indices.md)

***

Create a key under **API Keys** in the app sidebar. See [Authentication](/documentation/integrations/api/authentication.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
