Airport Distance API - Ruby Gem
Airport Distance is a simple tool for getting the distance between two airports. It returns the distance between the two airports.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_airportdistance'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_airportdistance
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_airportdistance'
# Initialize the client
client = APIVerve::Airportdistance::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({
iata1: "JFK",
iata2: "LAX"
})
# Print the response
puts response
Error Handling
begin
response = client.execute({ iata1: "JFK", iata2: "LAX" })
puts response["data"]
rescue APIVerve::Airportdistance::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Airportdistance::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Airportdistance::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"distanceMiles": 2470.23,
"distanceKm": 3974.2,
"distanceNauticalMiles": 2145.12,
"estimatedFlightTime": "5h 24m",
"timezoneDiffHours": -3,
"bearing": 265,
"direction": "West",
"isInternational": false,
"carbonEstimateKg": 543,
"airport1": {
"name": "John F Kennedy International Airport",
"iata": "JFK",
"icao": "KJFK",
"city": "New York",
"state": "New-York",
"country": "US",
"elevation": 13,
"latitude": 40.63980103,
"longitude": -73.77890015,
"timezone": "America/New_York"
},
"airport2": {
"name": "Los Angeles International Airport",
"iata": "LAX",
"icao": "KLAX",
"city": "Los Angeles",
"state": "California",
"country": "US",
"elevation": 125,
"latitude": 33.94250107,
"longitude": -118.4079971,
"timezone": "America/Los_Angeles"
}
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://airportdistance.apiverve.com?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.