Airport Code Converter API - Ruby Gem

Airport Code Converter is a simple tool for converting between IATA (3-letter) and ICAO (4-letter) airport codes. Submit either format and get the corresponding code back.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_airportcodeconverter'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_airportcodeconverter

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_airportcodeconverter'

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

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

# Print the response
puts response

Error Handling

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

Debug Mode

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

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "input": "MCI",
    "inputType": "IATA",
    "iata": "MCI",
    "icao": "KMCI",
    "name": "Kansas City International Airport",
    "city": "Kansas City",
    "state": "Missouri",
    "country": "US",
    "elevation": 1026,
    "latitude": 39.2976,
    "longitude": -94.7139,
    "timezone": "America/Chicago",
    "found": true
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.