Gold Price API - Ruby Gem

Gold Price is a simple tool for getting the current price of gold. It returns the current price of gold in any currency and in various units.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_goldprice'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_goldprice

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_goldprice'

# Initialize the client
client = APIVerve::Goldprice::Client.new(api_key: "YOUR_API_KEY")

# Make a request
response = client.execute({
  currency: "USD",
  hourly: true
})

# Print the response
puts response

Error Handling

begin
  response = client.execute({ currency: "USD", hourly: true })
  puts response["data"]
rescue APIVerve::Goldprice::ValidationError => e
  puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Goldprice::APIError => e
  puts "API error: #{e.message}"
  puts "Status code: #{e.status_code}"
end

Debug Mode

# Enable debug logging
client = APIVerve::Goldprice::Client.new(
  api_key: "YOUR_API_KEY",
  debug: true
)

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "currency": "USD",
    "gram": 152.1,
    "kilogram": 152101.49,
    "ounce": 4312,
    "lastUpdated": "2026-02-07T12:00:00.000Z",
    "change24h": 28.5,
    "change24hPct": 0.67,
    "changeDirection": "up",
    "high24h": 4325,
    "low24h": 4278.5,
    "formatted": {
      "ounce": "$4,312.00",
      "gram": "$152.10",
      "kilogram": "$152,101.49",
      "ounceWords": "four thousand three hundred twelve dollars",
      "kilogramWords": "one hundred fifty-two thousand one hundred one dollars"
    }
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.