If you’re new, then you’ll want to start by reading my 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 rules about the way you enter specific airport and airline names within the departure and destination fields. Commas let you enter more than one option.
After the basic language for departure/destination airports, you can use more commands for things like connections, fare class, and connection time. In the original version of ITA Matrix you would have started with your airport, then separate the routing codes with two colons (” :: “). After the colons you would enter the routing codes for things like connecting cities or specific airlines. Then, you can enter a forward slash (” / “) with extension codes after that.
Here’s a query that asks for an outbound flight from Seattle with one or more segments on United Airlines. It should include a connection in Denver or Chicago in the W or V fare class.
Departing from > SEA :: UA+ DEN,ORD /f bc=w|bc=v
However, we’re now in version 3 of ITA Matrix. If you try to do this today, ITA will automatically switch to the new view and move your text into separate fields for all this routing language. Notice that the colons and slashes have been removed.
Departing from > SEA
Outbound routing codes > UA+ DEN,ORD
Outbound extension codes > f bc=w|bc=v
To reduce confusion, I don’t see any point in telling you how to write a command that ITA is going to change anyway. (But I want you to know how to interpret what you might read elsewhere.) I am going to dispense with the colons and simply tell you what to enter in every box. You can force these extra fields to appear by clicking on “Advanced controls.”
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:
Departing from > SEA
Outbound routing codes > UA
Outbound extension codes >Destination > IAD
Return routing codes >
Return extension codes >
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, looking for a return journey from our “Destination” to our “Departing from.” But it will rely on return routing codes and return extension codes to filter results, and there are no instructions for the trip from IAD to SEA.
It could return anything. That’s one of the beauties of ITA Matrix: you not only have the power to filter your results with precise detail, but you also have the power to set different rules for each direction of travel. 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).
Departing from > SEA
Outbound routing codes > UA
Outbound extension codes >Destination > IAD
Return routing codes > UA
Return extension codes >
United Airlines offers both nonstop and connecting itineraries on this route. Complimentary upgrades are usually easier to get on connecting flights, but imagine it is 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. (I’ll explain another way of excluding options if you keep reading.)
Again, you’ll need to enter it in both fields if you want that instruction to apply to the outbound and the return journey.
Departing from > SEA
Outbound routing codes > UA IAH
Outbound extension codes >Destination > IAD
Return routing codes > UA IAH
Return extension codes >
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.
Departing from > SEA
Outbound routing codes > UA IAH UA
Outbound extension codes >Destination > IAD
Return routing codes > UA IAH UA
Return extension codes >
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.
Departing from > SEA
Outbound routing codes > IAH UA
Outbound extension codes >Destination > IAD
Return routing codes > UA IAH UA
Return extension codes >
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.
Departing from > SEA
Outbound routing codes > SFO,LAX,IAH
Outbound extension codes >Destination > IAD
Return routing codes > UA,AA,DL
Return extension codes >
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.
Departing from > SEA
Outbound routing codes > UA+
Outbound extension codes >Destination > IAD
Return routing codes > UA UA UA+
Return extension codes >
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.
Departing from > SFO,OAK
Outbound routing codes > UA,AS+
Outbound extension codes >Destination > IAD,DCA
Return routing codes > UA,AS+
Return extension codes >
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 (“~”).
Departing from > SFO,OAK
Outbound routing codes > UA,AS ~ORD UA
Outbound extension codes >Destination > IAD,DCA
Return routing codes > ~ORD UA,AS+
Return extension codes >
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.
Specify Codeshares
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.
Departing from > SFO
Outbound routing codes > O:UA
Outbound extension codes >Destination > FRA
Return routing codes > UA
Return extension codes >
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 (“/”) when you enter them as part of a single line of code. (Just like how the routing codes are always preceded by two colons, ” :: “.) However, because I’m showing you how to enter the codes separately in each box in the newest version of ITA Matrix, the slash is omitted. It will be easier to show you how the booking class code works with an example.
Departing from > SFO
Outbound routing codes > UA
Outbound extension codes > f bc=w
Destination > FRA
Return routing codes > UA
Return extension codes > f bc=w|v
It might be helpful if you imagine how you might translate this request to English. My extension code says that I want 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.
Specify Alliances
You can specify that flights be marketed by a particular alliance so you don’t have to type in all the airline codes. Like the fare class requirement, these are extension codes. (It’s a little weird because when you enter specific airlines those go in the routing code box.) Remember that we use a forward slash for extension codes when we try to type an entire command in one line, but when we use the new ITA Matrix with separate boxes the slash is omitted.
Departing from >
Outbound routing codes >
Outbound extension codes > alliance star-alliance
Alternatively, replace “star-alliance with one of the other alliances:
“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. Check out this post for more information on using ITA to find or avoid codeshares.
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:
Command | Description |
---|---|
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:
Command | Description |
---|---|
~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 other extension codes that I have not discussed in detail here. They should also go in the extension code field by themselves. These were originally detailed by SeattleFred on FlyerTalk but can also be found on the ITA Matrix website. For example, “-overnight” to avoid overnight flights or “-redeye” to avoid redeye flights. Note that these commands use minus signs, not the tildes used for negation in the routing codes above.
Command | Description |
---|---|
-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 placed in the routing code box, e.g., “minconnect 60” for a minimum connection time of 60 minutes. Note that the command for maximum duration requires three digits, not two.
Command | Description |
---|---|
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. |