Airports Lookup API - Ruby Gem

Airports is a simple tool for getting airport data. It returns the airport name, location, and more.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_airports'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_airports

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_airports'

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

# Make a request
response = client.execute({ iata: "MCI" })

# Print the response
puts response

Error Handling

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

Debug Mode

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

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "icao": "KMCI",
    "iata": "MCI",
    "name": "Kansas City International Airport",
    "city": "Kansas City",
    "state": "Missouri",
    "country": "US",
    "elevation": 1026,
    "lat": 39.2975997925,
    "lon": -94.7138977051,
    "tz": "America/Chicago",
    "city_info": {
      "name": "Kansas City",
      "altName": "",
      "country": "US"
    }
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.