Writing My Own Travel Agent in C#
Yesterday, Garrick was describing the difference between a "search result" and "find". His short answer was:
Search Results Listings say, 'The answer might be here'. Find says, 'Here you are, get on with your day.'â€
That distinction is something that has always struck me as irritating about using every travel site I've ever seen (later discussion revealed that, ironically, this distinction is talked about obsessively at Orbitz). That irritation is because every search I've made started out as something that doesn't fit in their search boxes: "Find me a cheap coach flight and a hotel near the conference center in Austin, TX for SXSW", "I'd like to go to San Francisco for a long weekend some time this fall; is there a way to do that for under $500?" or "Which one of these cities and which weekend will be cheapest in October for a 5 day weekend?".
Those aren't questions which naturally get answered by a search results page. You don't get to pose those questions to travel sites. What you are asked on every one of them is to choose specific dates and, in many cases, both airports. The sites don't even so much as hold on to the fact that 99% of my travel is based out of Minneapolis/St. Paul International Airport.
Rather, I get a constant flow of emails from the travel engines telling me about great deals to Miami/Las Vegas/New York for $89. Of course, if you are flying out of Minneapolis, that deal suddenly becomes $327 instead.
There is a place you could and can ask those questions and get your "find" satisfied. Travel agents pick up the phone, listen to just such a question and call you back later in the day with the results of your find. Unfortunately, they also are professionals who need to make a living. That means they're not entirely thrilled to, for instance, check daily for weeks at a time for a very specific set of criteria for a vacation I may take if the deal is good enough.
That does, however, smell of the kind of thing that I like sling a bit of code to solve. And, it's something I've wanted to solve for a very long time. Every couple of months, I go looking for a way to write code that searches for flights and hotels and have always come up empty.
Then, this weekend, I did it again and ran across the Kayak API, which looks like what I've been looking for all along. The API allows 1000 searches per day, per developer key. While that wouldn't let me create much of a public service or commercial application, it's a really roomy number if you're looking to do lots of permutations for your own travel needs.
Personally, I'd like to do things like have a list of cities I've never been to and have software grind away on it, finding a good deal for a "fall long weekend" or a "week-long summer vacation", etc. for one of those locations. Similarly, I'd like to be able to say, "I've got $300. Is there somewhere I can go and get a hotel for a 3 day weekend that's on my list?".
Software can easily handle digging through the tedious crap like seeing whether leaving on Thursday and coming back on Sunday is cheaper or more expensive than leaving on Friday and coming back on Monday. As a person, trying those combinations on the existing search results-oriented sites is tedious. Tedious is what software does best.
Before I start dreaming too big for what might be possible, I threw together a quick POC app to see how easy it might be to search and grab results. I created a really basic class library for doing the actual searches and a tiny console app to try out a single search.
I have to say, I like what I see and think that there are some real possibilities for coding up my own travel agent with Kayak.
The sample, half-finished POC code is available in PDF form if you want to look at it. It's got gaping holes all over (hard-coded, read-only properties, unused properties, concatenated strings, etc), but shows the basic idea for how to hit the service. This doesn't do anything to take advantage of any of the polling cycle that the API documentation describes, so the results are incomplete.
However, it proved what I wanted from the POC. I'm now pretty sure that I'll be able to get what I want out of that API. If you're interested in travel and writing software, it might be worth a look for you as well.



