Moon Position API - Ruby Gem
Moon Position is a simple tool for getting moon position data. It returns data such as altitude, azimuth, and distance of the moon based on the location provided.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_moonposition'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_moonposition
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_moonposition'
# Initialize the client
client = APIVerve::Moonposition::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({
lat: 37.7749,
lon: -122.4194,
date: "01-16-2026",
time: "14:30"
})
# Print the response
puts response
Error Handling
begin
response = client.execute({ lat: 37.7749, lon: -122.4194, date: "01-16-2026", time: "14:30" })
puts response["data"]
rescue APIVerve::Moonposition::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Moonposition::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Moonposition::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"date": "01-22-2026",
"time": "14:30",
"coordinates": {
"latitude": 37.7749,
"longitude": -122.4194
},
"moon": {
"altitude": -0.407908976399288,
"azimuth": 1.4720499058762104,
"distance": 404332.6834067969
}
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://moonposition.apiverve.com?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.