Previously I provided an introduction to ITA Matrix, what I consider one of the best free tools to search for air travel. It doesn’t let you book tickets but does provide very detailed information and a lot of control on the parameters of your search. These parameters are important because most search engines time out and provide only partial results. If you want to make sure you’ve really exhausted your search for the best flight, you need to know that you also excluded everything irrelevant.
The key to defining your search query is with advanced routing language. ITA Matrix was eventually purchased by Google and forms the basis of the popular Google Flights tool. Several features have also been copied by Hipmunk. While advanced routing language is still most powerful when used with ITA Matrix, a good understanding will help you improve your flight search on these other websites.
Recap on Using ITA Matrix
Last time I introduced how to use ITA Matrix for a basic round trip flight. Among other things I showed you how to use time bars to display flight options and how to view the fare breakdown of the final itinerary. In my next post I’ll talk about a lot of special features and filters that maximize the value of using ITA Matrix to perform your search.
Today I’m going to focus on routing language, which is the core feature of ITA Matrix. This can be used to limit your search results to force certain airlines, certain flight numbers, and certain connections. ITA Matrix shares some of this information on its website (and the number of commands listed is much more thorough in version 3.0), but it does not always show how to combine these commands into more powerful queries.
Where to Enter Advanced Routing Language
So, how do we activate this magical feature? Some of the routing language is simply the way you enter specific airport and airline names within the departure and destination fields. Additional commands for things like fare class and connection time and be listed after these, separated by two colons (“::”). Alternatively, you can enter these commands in a separate field underneath the airport names, by clicking on the link for “advanced controls.”
Since version 3.0, advanced controls have been separated into “routing codes,” which provide information on where you should fly and with which carriers, and “extension codes,” which provide additional instruction to the search engine on what types of itineraries are permissible.
Personally, I find it easier just to type everything in the airport fields. Routing codes tend to get mixed up with the original query anyway, and it’s not always obvious how they should be separated. By typing everything into one line (assuming you do it right), ITA Matrix will automatically move the codes to the right place.
Search Specific Airlines and Connecting Airports
The simplest commands are to specify your airline and connecting airport. We’ll use the example of a flight from Seattle (SEA) to Washington-Dulles (IAD) in all examples unless otherwise stated.
Imagine you want to fly on United Airlines. Instead of searching for a flight from SEA to IAD, you should enter the following:
Departure airport: SEA :: UA
Destination airport: IAD
This instructs ITA Matrix to look for a (single) flight from Seattle on United Airlines. In the results below you can see these are the only options provided by ITA Matrix.
Clearly, you will need to become familiar with three-letter airport codes and two-letter airline codes to become proficient at creating such queries. It’s easy enough to look them up with Google (e.g., search for “united airlines code”).
However, we’ve only provided instruction on the outbound journey. ITA Matrix will switch the fields around automatically to find our return flight, and there are no instructions for the trip from IAD to SEA. It could return anything. If you want to fly United Airlines on the return journey, you’ll need to specify that again (you can also pick a different airline, as there’s no need for it to be the same one).
Departure airport: SEA :: UA
Destination airport: IAD :: UA
United Airlines offers both nonstop and connecting itineraries on this route. Complimentary upgrades are usually easier to get on connecting flights, but imagine it’s winter and we don’t want to go through Chicago or Denver. You can force a connection in Houston by entering that airport’s code after the airline code. Again, you’ll need to enter it in both fields if you want that instruction to apply to the outbound and the return journey.
Departure airport: SEA :: UA IAH
Destination airport: IAD :: UA IAH
And you can see that in the search results, all of the options have a United Airlines flight with a stop in Houston.
Technically, we have only told ITA Matrix that we want one flight from Seattle to Houston on United Airlines followed by any possible flight to Washington-Dulles. The instructions end at “IAH” so ITA Matrix is not constrained in how it gets you to the final destination. Usually you’ll still be on the same airline. But if you want to be really specific you should still enter the airline’s code again.
Departure airport: SEA :: UA IAH UA
Destination airport: IAD :: UA IAH UA
By now you should be getting the picture. An alternating pattern of airport, airline, airport, airline of instructions is required. Skipping entries in this pattern is fine, but when instructions are not provided, ITA Matrix can do what it likes. You could just as easily let it pick from any airline to reach Houston, but still require United Airlines between Houston and Washington-Dulles.
Departure airport: SEA :: IAH UA
Destination airport: IAD :: UA IAH UA
Search Multiple Airlines and Airports at Once
Having addressed the basic mechanics of routing codes, it’s now easy to combine them or make them more complex. For example, you can leave out the airlines altogether if you only want to specify the connecting airports. Or you can leave out the connecting airports and only specify the airlines. If you want to give ITA Matrix a choice, separate those entries by commas.
Departure airport: SEA :: SFO,LAX,IAH
Destination airport: IAD :: UA,AA,DL
In the above example, it is implied that we will have two flights on the outbound journey because we must make a connection at one of three airports. It’s also implied that there will be a single flight on the return journey because we have specified one flight on any of three different airlines.
Typically I do not care about connection points but do care about how many flights I take. Use the plus (“+”) symbol to indicate one or more flights by an airline, or enter the airline’s code multiple times to indicate a specific number of flights.
Departure airport: SEA :: UA+
Destination airport: IAD :: UA UA UA+
The above example permits any number of flights (one or more) on United Airlines from Seattle to Washington-Dulles. The return journey requires three or more flights on United Airlines, because there must be one flight, then another, then one or more. The plus symbol is extremely important because usually you don’t care about the number of segments, just which airline you fly.
Here’s the real power of ITA Matrix: You can even enter multiple airports for your departure and destination. Perhaps you live in the San Francisco Bay Area and are willing to fly from San Francisco or Oakland, but not San Jose. You want to fly into Washington-Dulles or Washington-Reagan, but not Baltimore. And you want to fly United Airlines or Alaska Airlines, but not any other. You are indifferent to connections.
Departure airport: SFO,OAK :: UA,AS+
Destination airport: IAD,DCA :: UA,AS+
This is a lot of detail, but it’s easy to do and will greatly focus your search so that ITA Matrix can focus on providing just the results you want and exhaust all possible options. It will not be distracted by searching for flights on American Airlines or Delta Air Lines, for example.
But let’s go back to our earlier example. It’s winter and you really don’t want to connect in Chicago. You can exclude airlines and airports by using a tilde (“~”).
Departure airport: SFO,OAK :: UA,AS ~ORD UA
Destination airport: IAD,DCA :: UA ~ORD UA,AS+
I want to highlight some important differences here and how to think carefully about how this routing codes work. For the outbound journey, I requested a single flight (no plus symbol) on United Airlines or Alaska Airlines, I wanted to stop somewhere other than Chicago, and then I wanted to complete the trip on United Airlines.
For the return journey, I provided the same commands with the addition of a plus symbol. (The commands are in reverse order because I’m traveling in the reverse direction.) But now, after avoiding a connection in Chicago I want to take one or more flights on United Airlines or Alaska Airlines to reach Seattle. At this point, ITA Matrix can pick whatever connecting city it wants. It’s entirely possible I could get an itinerary like IAD-PHL-ORD-SEA.
The lesson is to pay close attention. If you really don’t want multiple flights, then don’t let ITA Matrix pick them for you.
Avoid Overly Broad Search Queries
My favorite application of ITA Matrix is creating flexible queries with multiple airport options. Imagine you just want a cheap flight to Europe and don’t care where; you’re going to take the train anyway. ITA Matrix will accept a query with a dozen airports in the destination field separated by commas. The problem is your query will time out after a minute. I’ll reiterate this point in my next post on using the “nearby airports” feature of ITA Matrix.
An overly broad search will still return results, but not all of them, and you might not get the lowest fares available to some of those destinations. If you often find that your queries take a long time, consider breaking them up into smaller pieces and running them separately. Alternatively, adding restrictions like a particular airline will counteract the effect of being too permissive with the number of airports.
It’s important to be clear about the nature of your request when you enter an airline’s code in your query. If you enter “UA” for United Airlines, this will return flights that are marketed by United Airlines, meaning they have a UA flight number. The majority will probably also be operated by United Airlines, with their own aircraft, but it’s also possible you’ll get a codeshare. For example, a Lufthansa codeshare could have an LH flight number but be operated by United Airlines. You’ll be able to see codeshares in the search results because an asterisk appears next to the airline code.
Rules for different loyalty programs sometimes mean you’ll earn a different number of miles based on who markets the flight or who operates the flight. You’ll need to look at the rules of the loyalty program to learn more. Sometimes the cost of the flight will also be different. And very often a codeshare prevents you from getting an upgrade. There are a lot of reasons why you will want to force or avoid a codeshare.
There are a few options here. You can do nothing and let ITA Matrix return flights that are marketed by the airline. You can also add the prefix “O:” to request flights that are operated by the airline. In this example, only the outbound flight to Frankfurt has this restriction, and the return journey requests a flight marketed by United Airlines.
Departure airport: SFO :: O:UA
Destination airport: FRA :: UA
This still doesn’t solve our problem because you can get the reverse issue: Lufthansa-marketed flights operated by United Airlines. You can see that the outbound journey provides the same flight but with different flight numbers.
The return journey provides different flights operated by different carriers, but both with United Airlines flight numbers.
Depending on the route you will want to go one way or the other. If it’s a domestic U.S. flight, for example, Lufthansa-operated flights will be rare and “O:UA” will probably work well.
Specify Booking Classes
All those reasons I gave for paying attention to codeshares? They apply to booking classes, too. (These are also called fare classes.) You may earn a different number of miles, see a different price, and change your eligibility for an upgrade. A common example is trying to use a Global Premier Upgrade (systemwide upgrade) on United Airlines. With some exceptions, you must be flying on a United-operated and United-marketed flight with a fare class of W or higher.
Your average search returns the lowest fare for the cabin specified: the lowest fare in coach, the lowest fare in business, or the lowest fare in first class. If you want a very specific fare that is somewhere in between, you can almost never search for this on other websites. ITA Matrix makes it easy.
This will be our first example of an extension code because it doesn’t affect the route but does adjust the results. Remember that fare extension codes always come last and begin with a forward slash (“/”). It will also be easier to show you how the booking class code works with an example.
Departure airport: SFO :: UA /f bc=w
Destination airport: FRA :: UA /f bc=w|v
It might be helpful if you imagine how you might translate this request to English. I have indicated that I am adding an extension code (“/”) to specify part of my fare (“f”). I want a specific booking class (“bc”) that is W on the outbound journey and either W or V on the return journey. You can enter as many booking classes as you like by separating them with a pipe (“|”), which is a common way of saying “or” in logical operations.
In the example below, you can see that the United-operated flight to Frankfurt that we found earlier is actually a little more expensive, at $1,588 instead of $1,513. This is the extra cost of buying an upgrade-eligible W fare. We can confirm it is a W fare by hovering over the flight here or by selecting it and viewing all the itinerary details on the last page.
Be aware that the airline might not be selling any tickets with the booking class you request, so entering more than one can improve your chances of success. You’ll still get only results for the cheapest booking class within the limitations of a particular query, so if you look for both W and V and both are available, only the cheaper W fare will be returned.
You can specify that flights be marketed by a particular alliance so you don’t have to type in all the airline codes. These commands don’t require the two colons after the airport, but they won’t hurt, either. However, you must use a forward slash and include them at the end of any routing codes.
“/alliance star-alliance” to search Star Alliance members like United Airlines
“/alliance oneworld” to search oneworld Alliance members like American Airlines
“/alliance skyteam” to search SkyTeam members like Delta Air Lines
Be careful when using these commands. Many carriers have non-alliance partners. For example, searching for oneworld Alliance members will not include Alaska Airlines, which is a partner of many alliance members such as British Airways, American Airlines, and Cathay Pacific. Alaska Airlines itself is not a member of any alliance.
If you only care about being able to earn miles with a specific program, using alliance commands are not a perfect solution. A better application might be if you want certain alliance benefits during your trip like priority boarding and lounge access. Or, if you know the local partners in the area where you are traveling, just enter the airline codes manually.
List of Advance Routing Language Commands
My examples are based on ITA’s own instructions, which you can bring up by clicking on the question mark next to each of the advanced routing entry fields. I’ve expanded on them a bit where I felt ITA was unclear. And with that said, I give you the list:
|AA||Direct flight on a specific carrier. In this example, it will be marketed by AA (i.e., AA flight number), but it could be operated by another carrier.|
|AA+||One or more flights on a specific carrier.|
|AA,UA,DL||Direct flight on one of the carriers separated by a comma.|
|O:AA||Direct flight on a specific operating carrier. In this example it could be marketed by another carrier (e.g., a BA flight number), but it will be operated by AA.|
|O:AA,O:UA,O:DL||Direct flight operated by one of the carriers separated by commas.|
|N||Any single nonstop flight. This contrasts with a direct flight, which may have a connection or plane change but still uses the same flight number. (This command is rarely used in practice.)|
|N:AA||Any single nonstop flight on AA.|
|DFW||A single connection point at a specified airport. You can also use city codes (e.g., WAS).|
|DFW, STL, LAX||A single connection point at one of the airports separated by commas.|
|X||Any single connection point. Use multiple separated by space to define multiple connections. (This command is rarely used in practice.)|
|X?||Zero or one flights. Use this to permit a connection but leave open the possibility of a nonstop flight.|
|DFW||Direct flight or one connection point at the specified airport.|
|AA151||A specific flight number, in this case American Airlines flight 151.|
|AA1000-2000||A single flight on AA within the range of 1000-2000.|
|~||Negation. Use this to rule out an airline, airport, or flight. For example, use SEA :: ~DEN to allow a flight from Seattle that connects anywhere but Denver.|
Various combinations of these commands are possible. For example:
|~AA,UA,DL+||Any number of flights, but not on AA, UA, or DL.|
|AA+ DL+||One or more flights on AA followed by one or more flights on DL.|
|AA DL,AF||Any direct flight on AA followed by any direct flight on either DL or AF.|
|AA UA?||Any direct flight on AA, optionally followed by another flight on UA.|
|AA N?||Any direct flight on AA, optionally followed by another flight on any airline.|
|AA25 UA814||Two specific flights: AA25 followed by UA814.|
|AA25 UA+||Flight AA25 followed by any number of flights on UA.|
|DL CHI DL||Two direct flights on DL, separated by a connection in Chicago (either airport, since the city code was used).|
|EWR CVG SLC||Three connections in EWR, CVG, and SLC (in that order).|
There are also many special commands, what ITA Matrix now calls extension codes, that were previously detailed by SeattleFred on FlyerTalk. List them after a forward slash and separated by commas (e.g., “BOS :: / -overnight,-redeye”). Note that these commands use minus signs, not the tildes used for negation in the routing codes above.
|-overnight||No overnight stops.|
|-change||No airport changes.|
|-redeye||No redeye flights.|
|-prop||No propeller planes.|
|-train||No trains (e.g., these are sometimes included on United flights to PHL).|
|-helicopter||No helicopters (I've never seen one).|
SeattleFred also tells us how to set connection times and itinerary duration. These commands must also be preceded by a forward slash (e.g., “/ minconnect 60”). Note that the last command for maximum duration requires three digits, not two.
|minconnect XX||Minimum connection of XX minutes.|
|maxonnect XX||Maximum connection of XX minutes.|
|padconnect XX||Require XX minutes in addition to the airline's minimum recommendation.|
|maxdur XXX||Maximum total trip duration of XXX minutes.|