Moonrise Moonset API - Ruby Gem

Moonrise Moonset is a simple tool for getting moonrise and moonset times. It returns the moonrise and moonset times based on the location provided.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_moonrisemoonset'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_moonrisemoonset

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_moonrisemoonset'

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

# Make a request
response = client.execute({
  lat: 37.7749,
  lon: -122.4194,
  date: "01-16-2026"
})

# Print the response
puts response

Error Handling

begin
  response = client.execute({ lat: 37.7749, lon: -122.4194, date: "01-16-2026" })
  puts response["data"]
rescue APIVerve::Moonrisemoonset::ValidationError => e
  puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Moonrisemoonset::APIError => e
  puts "API error: #{e.message}"
  puts "Status code: #{e.status_code}"
end

Debug Mode

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

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "coordinates": {
      "latitude": 37.7749,
      "longitude": -122.4194
    },
    "phase": "Waning Crescent",
    "moonrise": "2025-12-16T12:24:41.532Z",
    "moonset": "2025-12-16T22:22:04.027Z",
    "moonAlwaysUp": false,
    "moonAlwaysDown": false
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.