Fetching a Government Bond Curve
Use the /gov_yield endpoint to retrieve government bond yields and construct yield curves for risk-free rate benchmarking.
Example: US Treasury Curve
import requests
url = "https://api.bluegamma.io/v1/gov_yield"
headers = {"x-api-key": "your_api_key_here"}
tenors = ["1Y", "2Y", "3Y", "5Y", "7Y", "10Y", "20Y", "30Y"]
curve_data = []
for tenor in tenors:
params = {
"country_code": "US",
"maturity": tenor
}
response = requests.get(url, headers=headers, params=params)
data = response.json()
curve_data.append({
"tenor": tenor,
"yield": data["yield"] * 100 # Convert to percentage
})
for point in curve_data:
print(f"{point['tenor']}: {point['yield']:.2f}%")Understanding the Response
Field
Description
Visualizing the Curve

Historical Government Bond Yields
Forward-Starting Bond Yields
Available Government Bond Curves
Country Code
Description
Currency
Complete Example: Building a Treasury Curve DataFrame
Key Conventions
Last updated
Was this helpful?

