Treasury Yields API - Ruby Gem
Treasury Yields provides current and historical US Treasury constant-maturity market yields across the full curve (1-month through 30-year), plus TIPS real yields. Essential data for yield curve analysis and fixed income research.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_treasuryyields'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_treasuryyields
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_treasuryyields'
# Initialize the client
client = APIVerve::Treasuryyields::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({
date: "2025-06",
type: "10yr"
})
# Print the response
puts response
Error Handling
begin
response = client.execute({ date: "2025-06", type: "10yr" })
puts response["data"]
rescue APIVerve::Treasuryyields::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Treasuryyields::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Treasuryyields::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"date": "2024-02-01",
"bills": 5.24,
"notes": 4.35,
"bonds": 4.67,
"tips": 2.15,
"frn": 5.31,
"changes": {
"bills": {
"change1d": 0.02,
"direction": "up"
},
"notes": {
"change1d": -0.03,
"direction": "down"
},
"bonds": {
"change1d": 0.01,
"direction": "up"
},
"tips": {
"change1d": 0,
"direction": "unchanged"
},
"frn": {
"change1d": 0.02,
"direction": "up"
}
},
"previousDate": "2024-01-31"
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://treasuryyields.apiverve.com?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.