{
  "openapi": "3.1.0",
  "info": {
    "title": "CloseFlight Airport Data API",
    "version": "1.0.0",
    "description": "Airport lookups. Send your key in the X-API-Key header. Without a key, add demo=1 (30 calls a day, 5 results a call). API only: up to 20 results a call, no bulk export, usage limits apply."
  },
  "servers": [
    {
      "url": "https://closeflight.com/data-api/v1"
    }
  ],
  "security": [
    {
      "ApiKey": []
    }
  ],
  "paths": {
    "/airports/": {
      "get": {
        "operationId": "findAirports",
        "summary": "Find airports by code, search text or country",
        "parameters": [
          {
            "name": "code",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "3-letter IATA or 4-letter ICAO code",
            "example": "LHR"
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 80
            },
            "description": "City, airport name or code",
            "example": "heathrow"
          },
          {
            "name": "country",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "ISO 3166-1 alpha-2 country code",
            "example": "GB"
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/demo"
          }
        ],
        "responses": {
          "200": {
            "description": "Airports",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AirportList"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/airports/near/": {
      "get": {
        "operationId": "findNearbyAirports",
        "summary": "Find airports near a location",
        "parameters": [
          {
            "name": "lat",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "lon",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "radius_km",
            "in": "query",
            "schema": {
              "type": "number",
              "default": 150,
              "maximum": 500
            }
          },
          {
            "name": "scheduled",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            },
            "description": "Only airports with scheduled service"
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/demo"
          }
        ],
        "responses": {
          "200": {
            "description": "Airports with distance_km",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AirportList"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    },
    "parameters": {
      "limit": {
        "name": "limit",
        "in": "query",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 20
        }
      },
      "demo": {
        "name": "demo",
        "in": "query",
        "schema": {
          "type": "string",
          "enum": [
            "1"
          ]
        },
        "description": "Try without a key"
      }
    },
    "responses": {
      "Error": {
        "description": "Error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Meta": {
        "type": "object",
        "properties": {
          "count": {
            "type": "integer"
          },
          "demo": {
            "type": "boolean"
          }
        }
      },
      "Airport": {
        "type": "object",
        "properties": {
          "iata": {
            "type": "string"
          },
          "icao": {
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "country": {
            "type": "string"
          },
          "country_code": {
            "type": "string"
          },
          "latitude": {
            "type": "number"
          },
          "longitude": {
            "type": "number"
          },
          "timezone": {
            "type": [
              "string",
              "null"
            ]
          },
          "utc_offset_now": {
            "type": [
              "number",
              "null"
            ]
          },
          "size": {
            "type": "string",
            "enum": [
              "large",
              "medium",
              "small"
            ]
          },
          "scheduled_service": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "data_status": {
            "type": "string",
            "enum": [
              "no_open_issue",
              "under_review",
              "unknown"
            ]
          },
          "uncertain_fields": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "dataset_updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the whole table was last updated, not a per-airport review date"
          },
          "elevation_ft": {
            "type": [
              "integer",
              "null"
            ]
          },
          "passenger_status": {
            "type": "string",
            "enum": [
              "closed",
              "not_for_passenger_flights",
              "flight_offers_seen",
              "unknown"
            ]
          },
          "use_instead": {
            "type": [
              "string",
              "null"
            ],
            "description": "IATA code travellers use instead, when not open"
          },
          "seen_in_our_searches": {
            "type": "object",
            "description": "Flight offers returned by providers for searches on CloseFlight (offered, not proof a flight took off), updated weekly; empty means not seen yet",
            "properties": {
              "tracking": {
                "type": "string",
                "enum": [
                  "active",
                  "not_started",
                  "unavailable"
                ]
              },
              "last_flight_offer_seen": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date"
              },
              "since": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date"
              },
              "airlines_departing_or_arriving": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "maxItems": 150
              },
              "destinations_from_here": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "maxItems": 300
              }
            }
          },
          "matched_on": {
            "type": "string"
          },
          "distance_km": {
            "type": "number"
          }
        }
      },
      "AirportList": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Airport"
            }
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          },
          "request_id": {
            "type": "string"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "how_to_fix": {
                "type": "string"
              }
            }
          },
          "request_id": {
            "type": "string"
          }
        }
      }
    }
  }
}
