Skip to content
Reference client to the Travel IQ API at
Find file
New pull request
Pull request Compare This branch is even with traveliq:master.
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


tapi - Client for the Travel IQ API

This is the reference client implementation in Ruby for the Travel IQ API.

The API is a RESTful webservice which enables you to build meta travel search services or programs.

For the full documentation, visit

To access the API, you need an API key - you can get that by signing up for the Travel IQ affiliate program at .


The TAPI client provides both easy HTTP request handling (with built-in, transparent HTTP etag handling), and a Parser that returns response data as dynamic documents that allow you to access the data and do subsequent requests with ease.

This is best illustrated with an example. Here's how you autocomplete a location, start a hotel search, and query the results, using the tapi.

Load up tapi in an irb session:

$ irb
=> require 'rubygems'
=> gem 'tapi'
=> require 'tapi'

Get the first city matching the name “Berlin”:

=> city = TAPI::V3::Client.new_from_get("").first.cities.first

The client outputs what it's doing:

>> TAPI GET 0.221213 {}  "504f7ed4c2170bac4a8537eea29aa7b8"
>> Unknown ETag.

And this is the result:

>> #<TAPI::V3::Client:0x1589a48
     :display_name=>"Berlin - Deutschland"}>

Since all results are again instances of TAPI::V3::Client, you can both get the data with accessor methods:

=> "Berlin"
>> city.latitude
=> 52.5166667

And query further parts of the API, which are always linked by the “resources” key in the API responses, by prepending “fetch_” to the resource name:

>> city.fetch_country
=> #<TAPI::V3::Client:0x2137048

To start a search, you first need to configure the Search class, and set up the parameters in an instance:

>> TAPI::V3::Hotels::Search.config = {:key => "traveliq", :host => "", :port => "80", :path => ''}
>> search ={:arrival_date => + 1, :departure_date => + 2, :city_id =>, :room_configuration => "[A]"})

You can validate the parameters like in ActiveRecord with #valid? When everything's set up, start the search:

>> search.start!

The search will take a little while to finish. You can query its status like this (note the reload, which does a new request to the API):

>> search.reload.status_detailed.state
=> "running"


>> search.reload.status_detailed.state
=> "finished"

You can look at the results of a search at any time. Keep in mind, though, that results will expire after a while - display results while the search is running or when finished, don't cache them in your application.

=> 24.0


(sudo) gem install tapi

Or, install latest version from Github with bundler by adding this to your Gemfile:

gem 'tapi', :git => 'git://'

Dependencies and Rubies

You'll need the ActiveSupport, curl, and json gems, but that should be handled automatically. The client is tested under Ruby 1.8.7 (REE). It may not work well under 1.9 - feel free to contribute !


Dr. Florian Odronitz ( Matthias Georgi ( Github release by Martin Tepper (


For questions, contact the authors or

Contributing to tapi

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet

  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.


Copyright © 2011 Travel IQ. See LICENSE.txt for further details.

Something went wrong with that request. Please try again.