|
Sign In |
|
The search API is an HTTP interface that lets you, the programmer, integrate kayak.com searches and results into your web site, desktop application, or mobile phone application. If you can make an HTTP connection, you should be able to use this API.
Why might one want to do this? We're not entirely sure, but it sure seems like it might result in some interesting mashups.
You are free to use the Kayak search API, free of charge, providing you meet certain conditions.
Get a developer key. If you are just fooling around on your own, use the key from your own kayak.com account. If you are are going to put it on a web site, or expose it in anyway to the public, you should create a separate kayak.com account, with a different email address.
Then choose one of the following:
Read the API spec and use your favorite technology/language to use it. If you want, package up the essential implementation, and we'll put it here for others to use.
Download the Ruby sample and modify it.
These may be a bit out of date, but are a good starting point: Perl and Java.
The Kayak search API is implemented as XML over HTTP. It doesn't use WSDL or XMLRPC or anything fancy. You just do an HTTP GET or POST with regular form arguments, and you get responses as simple XML documents.
To invoke a search there are 3 steps: get a session, launch the search, and then poll for results. You can launch multiple searches from a single session, but you should only process one at a time. So the sequence is: get session, launch search, poll for results, done, launch search. Sessions time out after about 30 minutes of idle time. How often you poll is up to you, and mostly depends on what you want your application to look like. If you are doing a batchy application, you probably should launch the search, wait 60 seconds, and then poll one time only; that will guarantee that you only need to make one poll request to get all the results. If you want a more interactive thing, we recommend you poll every 5-10 seconds, so you user can see stuff happening.
One thing to keep in mind is that every time you poll you get only the first 10 search results according to whatever sort method you are using. You might want to adjust this up or down, depending on what you want your app to do. If you are polling for display purposes, you'll want to set the count limit and sort order so you showing the first n results or so. Then when you make your "final" call, make sure you fetch all. Or you can just keep fetching in small chunks, and not store the results in your app at all.
Generally, you will be better off requesting the minimal number results you need because it will take kayak less time to assemble and transmit the result, and it will take your application less time and bandwidth to receive and parse the result.
If your application does all of it's manipulation of results internally, you are better off getting ALL the results in one single call. If you would rather have kayak do the sorting and filtering, hence making a lot of calls as the user works, you should limit the result count to something like 10-50 on each call.