> 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-discount-curve.md).

# Fetching a Discount Curve

Use the /discount\_curve endpoint to get a full schedule of discount factors for cash flow discounting, loan valuation, and DCF models.

The `/discount_curve` endpoint returns a schedule of discount factors between two dates at a specified frequency. Use this when you need to discount multiple future cash flows back to present value.

***

## Basic Example

```python
import requests

url = "https://api.bluegamma.io/v1/discount_curve"
headers = {"x-api-key": "your_api_key"}

params = {
    "index": "SOFR",
    "start_date": "0D",
    "end_date": "5Y",
    "frequency": "6M"
}

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

for point in data["curve"]:
    print(f"{point['date']}: {point['discount_factor']:.6f}")
```

```bash
curl -X GET "https://api.bluegamma.io/v1/discount_curve?index=SOFR&start_date=0D&end_date=5Y&frequency=6M" \
  -H "x-api-key: your_api_key_here"
```

**Response:**

```json
{
  "start_date": "2026-04-01",
  "end_date": "2031-04-01",
  "index": "SOFR",
  "valuation_time": "2026-04-01T20:57:50.523152",
  "is_end_of_month": true,
  "frequency": "6M",
  "curve": [
    { "date": "2026-04-01", "discount_factor": 1.0 },
    { "date": "2026-04-30", "discount_factor": 0.997063 },
    { "date": "2026-10-31", "discount_factor": 0.978594 },
    { "date": "2027-04-30", "discount_factor": 0.960977 },
    { "date": "2027-10-31", "discount_factor": 0.943836 },
    { "date": "2028-04-30", "discount_factor": 0.927581 },
    { "date": "2028-10-31", "discount_factor": 0.911458 },
    { "date": "2029-04-30", "discount_factor": 0.895746 },
    { "date": "2029-10-31", "discount_factor": 0.879728 },
    { "date": "2030-04-30", "discount_factor": 0.863909 },
    { "date": "2030-10-31", "discount_factor": 0.847782 },
    { "date": "2031-04-30", "discount_factor": 0.831898 }
  ],
  "timestamp": "2026-04-01T20:57:27"
}
```

### Response fields

| Field             | Description                                             |
| ----------------- | ------------------------------------------------------- |
| `start_date`      | Start date of the curve                                 |
| `end_date`        | End date of the curve                                   |
| `index`           | The interest rate index used                            |
| `valuation_time`  | When the curve was calculated                           |
| `is_end_of_month` | Whether dates are aligned to month-ends                 |
| `frequency`       | Spacing between curve points                            |
| `curve`           | Array of points, each with `date` and `discount_factor` |
| `timestamp`       | When the underlying market data was captured            |

### Curve point fields

| Field             | Description                                                                                           |
| ----------------- | ----------------------------------------------------------------------------------------------------- |
| `date`            | The future date (ISO 8601 format)                                                                     |
| `discount_factor` | The present value of 1 unit of currency received on that date. Starts at 1.0 and decreases over time. |

***

## Parameters

| Parameter         | Required | Description                                                                |
| ----------------- | -------- | -------------------------------------------------------------------------- |
| `index`           | Yes      | Interest rate index (e.g., `SOFR`, `SONIA`, `6M EURIBOR`)                  |
| `start_date`      | Yes      | Start of the curve. Relative (`0D`, `1Y`) or absolute (`2026-04-01`)       |
| `end_date`        | Yes      | End of the curve. Relative (`5Y`, `10Y`, `30Y`) or absolute (`2031-04-01`) |
| `frequency`       | Yes      | Spacing between points: `1M`, `3M`, `6M`, or `1Y`                          |
| `valuation_time`  | No       | Historical timestamp (ISO 8601) for reproducibility                        |
| `is_end_of_month` | No       | Align dates to month-ends. Defaults to `true`                              |

***

## Practical example: Discounting a loan schedule

```python
import requests

url = "https://api.bluegamma.io/v1/discount_curve"
headers = {"x-api-key": "your_api_key"}

# Get semi-annual discount factors for the next 3 years
params = {
    "index": "SOFR",
    "start_date": "0D",
    "end_date": "3Y",
    "frequency": "6M"
}

response = requests.get(url, headers=headers, params=params)
curve = response.json()["curve"]

# Semi-annual loan payments
payments = [50000] * 6  # 6 payments of 50,000

total_pv = 0
for i, payment in enumerate(payments):
    # Skip the first curve point (date = today, DF = 1.0)
    df = curve[i + 1]["discount_factor"]
    pv = payment * df
    total_pv += pv
    print(f"{curve[i + 1]['date']}: {payment:>10,} x {df:.6f} = {pv:>10,.2f}")

print(f"\nTotal Present Value: {total_pv:,.2f}")
```

***

## `/discount_curve` vs `/discount_factor`

|               | `/discount_curve`                                  | `/discount_factor`                          |
| ------------- | -------------------------------------------------- | ------------------------------------------- |
| **Returns**   | Full schedule of discount factors                  | A single discount factor                    |
| **API calls** | 1 call for the entire curve                        | 1 call per date                             |
| **Best for**  | Loan/bond valuation, DCF models, batch discounting | Quick lookups, single cash flow discounting |

Use `/discount_curve` when you need discount factors for multiple dates. Use [`/discount_factor`](/documentation/integrations/api/how-to-guides/getting-discount-factors.md) when you only need one.

***

## Visualising a discount curve

<figure><img src="https://3184259219-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmmQPefoflG1RwUnUKKBR%2Fuploads%2Fgit-blob-ae5889202f1dffa0a0ff6c590b871a8744ae5794%2Fdiscount-curve-sofr-10y.png?alt=media" alt="Discount curves for SOFR, SONIA, and 6M EURIBOR over 10 years"><figcaption><p>SOFR, SONIA, and 6M EURIBOR discount curves: 10-year, quarterly frequency</p></figcaption></figure>

***

## Related Endpoints

| If you need...                       | Use                                                                                              |
| ------------------------------------ | ------------------------------------------------------------------------------------------------ |
| A single discount factor             | [`/discount_factor`](/documentation/integrations/api/how-to-guides/getting-discount-factors.md)  |
| Discount factors for a list of dates | [`/discount_factors`](/documentation/integrations/api/how-to-guides/getting-discount-factors.md) |
| Zero rates                           | [`/zero_rate`](/documentation/integrations/api/how-to-guides/fetching-zero-rates.md)             |
| Forward rates                        | [`/forward_rate`](/documentation/integrations/api/how-to-guides/getting-forward-rates.md)        |
| A forward curve                      | [`/forward_curve`](/documentation/integrations/api/how-to-guides/getting-a-forward-curve.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-discount-curve.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.
