Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8760077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:57:26+00:00 2026-06-13T14:57:26+00:00

I’m developing an app that needs to look up country codes (ISO-3166 alpha2) based

  • 0

I’m developing an app that needs to look up country codes (ISO-3166 alpha2) based on IATA-codes (http://en.wikipedia.org/wiki/IATA_airport_code).

Is there an (preferably free) API for that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:57:27+00:00Added an answer on June 13, 2026 at 2:57 pm

    I’m submitting here a incomplete solution, both as way to address the IATA-to-Contry-Code question at hand, and to bring attention to what may be a underused resource for structured content: I’m talking about Freebase !

    This is incomplete in the sense that not all IATA codes are included (though I’m guessing a relatively high coverage) or not all have a country code assigned to them (alas a more common occurrence).

    The API I wish to suggest is the Freebase MQL Read Service.
    This free service works by sending an HTTPS request with a parameter that expresses a query in MQL (Metaweb Query Language), and receiving a JSON object with the desired results.

    Specifically the request looks like

    https://www.googleapis.com/freebase/v1/mqlread?indent=2&query=[{"type":"/aviation/airport","id":null,"limit": 25,"name":null,"sort":"name","iata": "SFO", "/location/location/containedby": [{"limit":6,"name":null,"optional": true,"sort":"name","/location/country/iso3166_1_alpha2": [{ "limit":6, "optional": false, "sort":"value", "value":null}]}],"airport_type": [{"limit":3,"name":null,"optional": true,"sort":"name","type":"/aviation/airport_type"}]}]
                                                                                                                                                        ^---  here place the IATA code
    

    for readability I’m showing the corresponding MQL with indentation on multiple lines; same thing as above only better layout.

    [{
      "type":  "/aviation/airport",
      "id":    null,
      "limit": 25,
      "name":  null,
      "sort":  "name",
    
      "iata": "SFO",     -- <<< that's where you place the desired IATA code
    
      "/location/location/containedby": [{
        "limit":    6,
        "name":     null,
        "optional": true,
        "sort":     "name",
        "/location/country/iso3166_1_alpha2": [{
          "limit":    6,
          "optional": false,
          "sort":     "value",
          "value":    null
        }]
      }],
      "airport_type": [{
        "limit":    3,
        "name":     null,
        "optional": true,
        "sort":     "name",
        "type":     "/aviation/airport_type"
      }]
    }]​
    

    And the response looks like the following:

    {
      "result": [
        {
          "name": "San Francisco International Airport", 
          "iata": "SFO", 
          "/location/location/containedby": [
            {
              "name": "United States of America", 
              "/location/country/iso3166_1_alpha2": [
                {
                  "value": "US"
                }
              ]
            }
          ], 
          "airport_type": [
            {
              "type": "/aviation/airport_type", 
              "name": "Public"
            }
          ], 
          "type": "/aviation/airport", 
          "id": "/en/san_francisco_international_airport"
        }
      ]
    }
    

    This solution was “whipped-up” in approximately 30 minutes by drilling into the Freebase /aviation/airport type and using various tools I describe briefly below.

    Note that this is a generic approach, applicable to various queries: rather than matching IATA airport codes to ISO country codes, we could, for example, get the list of the bridges build before 1950 with a span exceeding 500 feet, or look up the famous musicians born in a given city etc. Furthermore, AFAIK, the Freebase API and information is freely available. Beware, however, that there are some limitations (and some advantages!) to the content found at Freebase as compared with that obtained from specialized sources.
    The information obtained from Freebase may not be as authoritative, complete or current as that obtained with APIs and Data Extracts from specialized sources. This limitation speaks to the quasi universal breadth of the information gathered at Freebase in a collaborative, wiki-like, fashion, by a mostly volunteer task force, compared with the focused, often single-purposed, information gathering performed by paid professionals at various trade organizations such as, say the IATA or the International Maritime Organization (IMO). On the other hand, Freebase, with its semantic representation of the data, provides ways of connecting bits of information in powerful ways. Whereby the authoritative sources provide mostly “tabular” data, Freebase queries can match apparently unrelated pieces of information. For example, whereby the IMO probably produces lists of seaports with their annual tonnage, their number of terminals and such, Freebase can also find, say, the films that were shot in these ports or the famous writers who were born there.

    But enough with disclosures, let’s see how one can produce these queries

    • First peruse the kind of desired items on Freebase, to get familiar with what the site has to offer in this area, and get an informal “feel” for the breadth and depth of the information available for this kind of items.
      For example, one may peek into various airport instances found for the Airport Type on Freebase
    • Once the type(s) of items desired is identified, one can look into their schema(s) (many ways to get there, for example link at bottom of page)
      Here’s the schema for our Airport Type example.
    • The schema shows what fields of information are collected for a given type. Beware however that while the schema can be relatively complete and elaborate, the individual instances of the corresponding type may not all have these fields properly filled-in: verify informally with ad hoc reviews of instances or with lists of instances as explained below.
    • Return to the list of instances view and modify this view by adding and removing columns. This is done, respectively, with the orange “+” button on the top left of the list and with the small “x” button next to each column header.
      See how the tree shown in the “Add new column” section (shown after pressing the “+”) allows drilling down the schema of the type that we start with or of types connected to it.
      In the case of Airports, I quickly removed the “image”, “article” and “airline”-related fields, to make room, and added the IATA code, and drilled in the “Location” to find the Country and from there the ISO code. This connection to “Country” was a bit tricky, I had to look into the “Contained by” which itself is another “Location” and, using the “More” brought up the “Country” type.
    • Once you have a tabular listing, with the desired fields, and maybe with a few extra fields used for review purposes, you can export the corresponding MQL code by picking the “MQL” link in the “Use Data from this Collection”, at the bottom of the page. This pops-up a window where you can copy the MQL snippet, although it is probably better to proceed to the Query Editor. (You may still need to copy the MQL code and paste it back into the editor, due to a bug with the application which doesn’t bring that MQL when pressing the “View in Query Editor” button)
    • The query editor provides a convenient way of tweaking this initial/default query and testing it. You may need to get familiar with MQL language, it is generally rather intuitive.
    • When the query produces precisely what we need, it is time to to make it a “One-liner” (formatting convenience button at bottom of editor screen) which can then be used inside a URL to the Freebase MQL Read service (see example at the top of this answer).
    • A bit more testing and tweaking (e.g. fighting the JSON syntax errors occasionally introduced by typos while copying/editing the string to the URL) et… Voila !
    • There is actually a lot more that can be done with Freebase, for example using the Google Client Library to facilitate the integration with the MQL service.

    I’d like to finish with the following suggestion: Rather than integrating this online API to your application, it is sometimes possible to download the complete list and to create a local database with it. In this fashion it may be possible to complement the data by adding rows and/or filling empty columns. This approach is particularly applicable to the IATA/Airport example -after all the list of airports and their underlying codes is relatively small and does not vary all that frequently-. This approach of course may require the local DB to be refreshed and otherwise maintained occasionally, but it removes the requirement of the online, real-time, connection to Freebase.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.