Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
186 lines (134 sloc) 3.54 KB

Aviasales/TravelPayouts API gem

Gem Version

** This gem supports ruby 2.2 and above. It won't work on earlier ruby versions due to extensive use of positional parameters.

Overview

This gem supports

How to use

Include it in your Gemfile:

gem 'travelpayouts_api'

Create an initializer in config/initializers:

# config/initializers/travelpayouts_api.rb
TravelPayouts.configure do |config|
  config.token = '<token>'
  config.marker = '<marker>'
  config.host = 'localhost'
  config.currency = 'rub'
  config.locale = 'en'
end

where

  • token - your api token
  • marker - your client id in travelpayouts system
  • currency - currency 3-digit code
  • host - should be set to your site host
  • locale - language of results

And now in your controller you can do something like this:

@api = TravelPayouts.api
prices = @api.cheap_prices(origin: 'ODS', destination: 'MOW', depart_date: '2015-04-01')

All API calls will return hash objects or raise exceptions on failure.

Data Access API

cheap_prices(origin:, destination:, depart_date: nil, return_date: nil)
direct_prices(origin:, destination:, depart_date: nil, return_date: nil)
calendar_prices(origin:, destination:, calendar_type:, depart_date: nil, trip_duration: nil, return_date: nil)
airline_directions(airline_code:, limit: 10)
countries_data()
cities_data()
airports_data()
airlines_data()
airline_alliances_data()
planes_data()
routes_data()
where_am_i(ip: nil, locale: nil)

Map API

map_of_supported_directions(origin_iata:, one_way: true, locale: nil)
map_of_prices(origin_iata:, period: :month, one_way: true, direct: false,
    price: nil, no_visa: true, schengen: nil, need_visa: true, locale: nil,
    min_trip_duration_in_days: nil, max_trip_duration_in_days: nil)

Calendar API

calendar_of_prices(origin:, destination:, depart_date:, one_way:true)

Flights API

flight_search(user_ip:,locale: nil, trip_class: 'Y', passengers: {}, segments: {}, know_english: true)
flight_search_link(search_id:, terms_url:)
flight_search_results(search_id:)
autocomplete_places(term:, locale: nil)

Hotels API

hotel_lookup(query:, lang: nil, look_for: nil, limit: 10, convert_case: true)
hotel_prices(user_ip:, check_in:,check_out:,location:nil,location_id:nil,hotel_id:nil,hotel:nil,limit:10)
hotel_countries()
hotel_locations()
hotel_amenities()
hotels_list(location_id:)
hotel_room_types()
hotel_types()
hotel_search_start(city_id:nil,hotel_id:nil,iata:nil,check_in:,check_out:,adults_count:,user_ip:,
  children_count:0,child_age1:0,child_age2:0,child_age3:0,lang:nil,currency:nil,wait_for_result:0,timeout:20)
hotel_search_result(search_id:,limit: 0,offset: 0,sort_by: :popularity, sort_asc: 1, rooms_count: 0)
You can’t perform that action at this time.