Marine Weather API - Ruby Gem

Marine Weather is a simple tool for getting marine weather data. It returns the current weather conditions in coordinates within the ocean and sea.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_marineweather'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_marineweather

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_marineweather'

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

# Make a request
response = client.execute({
  lat: 29.48003,
  lon: -37.62424
})

# Print the response
puts response

Error Handling

begin
  response = client.execute({ lat: 29.48003, lon: -37.62424 })
  puts response["data"]
rescue APIVerve::Marineweather::ValidationError => e
  puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Marineweather::APIError => e
  puts "API error: #{e.message}"
  puts "Status code: #{e.status_code}"
end

Debug Mode

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

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "location": {
      "lat": 29.48003,
      "lon": -37.62424
    },
    "weather": {
      "maxtempc": 22.9,
      "maxtempf": 73.2,
      "mintempc": 21.8,
      "mintempf": 71.2,
      "avgtempc": 22.5,
      "avgtempf": 72.5,
      "maxwindmph": 11.1,
      "maxwindkph": 17.9,
      "totalprecipmm": 3.29,
      "totalprecipin": 0.13,
      "totalsnowcm": 0,
      "avgviskm": 9.9,
      "avgvismiles": 6,
      "moonphase": "Waning Crescent",
      "moonillumination": 16
    }
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.