Airports
Airport lookup and sun/night-time calculations. The search and view endpoints are public: they work without a session (the marketing site’s signup form uses search). night_time needs a session or API key; every user group can call it.
Airport ids are ICAO codes. When an airport’s ICAO code was reassigned, the airport exists under both codes: the old row has superseded_by set to the new code, and the new row has former_id set to the old one.
Sun times
Section titled “Sun times”Every airport object carries SunInfo, the sun times at the airport for one day (unix seconds, UTC): sunrise, sunset, transit (solar noon), and the civil_, nautical_ and astronomical_twilight_begin / _end pairs. On days with no sunrise or no sunset (polar day or night) a value is true or false instead of a time.
Search Airports
Section titled “Search Airports”GET /airports/search.json?q={query}
Search airports, up to 10 results. First matches the start of the ICAO code or the IATA code (LEB, BCN); when nothing matches, the start of the airport name or city. Closed airports are listed after open ones, then results are ordered by ICAO code.
Query Parameters
Section titled “Query Parameters”| Parameter | Type | Description |
|---|---|---|
| q | string | Search query (ICAO or IATA code, airport name, or city name) |
Response
Section titled “Response”{ "airports": [ { "Airport": { "id": "LEBL", "icao": "LEBL", "iata": "BCN", "name": "Josep Tarradellas Barcelona-El Prat Airport", "lat": "41.29710", "lon": "2.07846", "SunInfo": { "sunrise": 1796194738, "sunset": 1796228591, "transit": 1796211664, "civil_twilight_begin": 1796192899, "civil_twilight_end": 1796230429, "nautical_twilight_begin": 1796190839, "nautical_twilight_end": 1796232490, "astronomical_twilight_begin": 1796188841, "astronomical_twilight_end": 1796234488 } }, "Country": { "id": "199", "name": "Spain" }, "Timezone": { "id": "153", "name": "Europe/Madrid" } } ]}SunInfo is for today. With an empty or missing q the response is { "airports": { "Airports": [] } }.
View Airport
Section titled “View Airport”GET /airports/view/{airport}.json
GET /airports/view/{airport}/{date}.json
Retrieve full airport details including country and timezone, with the sun times of one day. The response is the bare airport object.
Path Parameters
Section titled “Path Parameters”| Parameter | Type | Description |
|---|---|---|
| airport | string | ICAO airport code. 404 Airport not found in database when unknown |
| date | string | number | Optional. Day for SunInfo (unix timestamp or date string). Defaults to now |
Response
Section titled “Response”{ "Airport": { "id": "LEBL", "icao": "LEBL", "former_id": null, "superseded_by": null, "type": "large_airport", "name": "Josep Tarradellas Barcelona-El Prat Airport", "timezone_id": "153", "lat": "41.29710", "lon": "2.07846", "elevation": "12", "continent": "EU", "country": "ES", "country_id": "199", "region": "ES-CT", "city": "Barcelona", "iata": "BCN", "wiki": "https://en.wikipedia.org/wiki/Barcelona%E2%80%93El_Prat_Airport", "SunInfo": { "sunrise": 1782015519, "sunset": 1782070102, "transit": 1782042810, "civil_twilight_begin": 1782013490, "civil_twilight_end": 1782072131, "nautical_twilight_begin": 1782010883, "nautical_twilight_end": 1782074738, "astronomical_twilight_begin": 1782007769, "astronomical_twilight_end": 1782077851 } }, "Country": { "id": "199", "iso2": "ES", "name2": "SPAIN", "name": "Spain", "iso3": "ESP", "continent": "EU", "vat_liable": true, "enabled": true, "numcode": "724", "phonecode": "34" }, "Timezone": { "id": "153", "name": "Europe/Madrid", "description": " Madrid", "offset_hours": "+01:00", "offset": "-3600", "country_iso": "ES" }}| Field | Description |
|---|---|
| type | large_airport, medium_airport, small_airport, heliport, seaplane_base, balloonport or closed |
| elevation | Feet |
| former_id / superseded_by | Previous / new ICAO code when the code was reassigned, otherwise null |
| Timezone.name | IANA timezone of the airport |
Calculate Night Time
Section titled “Calculate Night Time”GET /airports/night_time/{departure}/{arrival}/{dTime}/{aTime}.json
Calculate the night flying time for a given flight leg based on official sunrise/sunset at departure and arrival airports.
Times can be Unix timestamps or date-time strings. The calculation accounts for all scenarios: day flights, night flights, flights crossing sunrise/sunset, and multi-day flights. Night is counted from sunset to sunrise (not civil twilight). The departure airport’s sun times are taken for the departure day, the arrival airport’s for the arrival day. The response is the bare result object.
Missing or unreadable times return 400 Incorrect times provided. Both airport codes must exist.
Path Parameters
Section titled “Path Parameters”| Parameter | Type | Description |
|---|---|---|
| departure | string | ICAO code of departure airport |
| arrival | string | ICAO code of arrival airport |
| dTime | string | number | Departure time (Unix timestamp or date string) |
| aTime | string | number | Arrival time (Unix timestamp or date string) |
Response
Section titled “Response”{ "seconds": 3600, "departure": { "sunrise": 1736490000, "sunset": 1736530000, "transit": 1736510000, "civil_twilight_begin": 1736488200, "civil_twilight_end": 1736531800, "nautical_twilight_begin": 1736486100, "nautical_twilight_end": 1736533900, "astronomical_twilight_begin": 1736484100, "astronomical_twilight_end": 1736535900 }, "arrival": { "sunrise": 1736490600, "sunset": 1736530600, "transit": 1736510600, "civil_twilight_begin": 1736488800, "civil_twilight_end": 1736532200, "nautical_twilight_begin": 1736486700, "nautical_twilight_end": 1736534500, "astronomical_twilight_begin": 1736484700, "astronomical_twilight_end": 1736536500 }}
secondsis the total night flying time in whole seconds. Returns0if the entire flight is in daylight.departureandarrivalare the two airports’ sun times.