# Airport Search



Three discovery modes help users find an airport before you fetch full records from [Airports](/docs/v31/airports): typeahead by name or code, nearest airports to a map pin or GPS fix, and nearest airports inferred from a visitor IP. All three return the same core airport item schema; location and IP modes add `distance_km`.

| Endpoint                        | When to use                                               |
| ------------------------------- | --------------------------------------------------------- |
| `GET /airports/search/text`     | Autocomplete — user types a name, city, or partial code   |
| `GET /airports/search/location` | Map pin or GPS coordinates — airports within a radius     |
| `GET /airports/search/ip`       | "Airports near me" without browser geolocation permission |

<DocJumpNav>
  <DocJumpLink href="#search-by-text" icon="solar:magnifer-bold-duotone">
    Text
  </DocJumpLink>

  <DocJumpLink href="#search-by-location" icon="solar:gps-bold-duotone">
    Location
  </DocJumpLink>

  <DocJumpLink href="#search-by-ip" icon="solar:server-bold-duotone">
    IP
  </DocJumpLink>
</DocJumpNav>

<a id="search-by-text" />

## Search by text [#search-by-text]

Free-text search across ICAO codes, IATA codes, airport names, and cities. Results are ranked by `relevance_score` — exact code matches score highest.

### Request [#request]

<DocRequirements>
  <DocRequirementAuth />
</DocRequirements>

<DocApiPath method="GET" path="/airports/search/text" />

| Parameter | Type    | Required | Default | Description                              |
| --------- | ------- | -------- | ------- | ---------------------------------------- |
| `q`       | string  | Yes      | -       | Search string — minimum **2** characters |
| `limit`   | integer | No       | `10`    | Maximum results to return                |

### Response [#response]

```json
{
  "query": "jfk",
  "airports": [
    {
      "id": 3622,
      "ident": "KJFK",
      "type": "large_airport",
      "name": "John F. Kennedy International Airport",
      "latitude_deg": 40.639447,
      "longitude_deg": -73.779317,
      "municipality": "New York",
      "iso_country": "US",
      "iata_code": "JFK",
      "relevance_score": 100
    }
  ],
  "airports_found": 1
}
```

| Field            | Type    | Required | Description                   |
| ---------------- | ------- | -------- | ----------------------------- |
| `query`          | string  | **Yes**  | Echo of the search string     |
| `airports`       | array   | **Yes**  | Ranked matches (may be empty) |
| `airports_found` | integer | **Yes**  | Count of items in `airports`  |

#### Airport item (`airports[]`) [#airport-item-airports]

| Field             | Type           | Required | Null?   | Description                                                                       |
| ----------------- | -------------- | -------- | ------- | --------------------------------------------------------------------------------- |
| `ident`           | string         | **Yes**  | Never   | Primary identifier (usually ICAO)                                                 |
| `name`            | string         | **Yes**  | Never   | Airport name                                                                      |
| `type`            | string         | **Yes**  | Never   | Airport class (same values as [Airports](/docs/v31/airports#airport-type-values)) |
| `latitude_deg`    | number         | **Yes**  | Never   | WGS-84 latitude                                                                   |
| `longitude_deg`   | number         | **Yes**  | Never   | WGS-84 longitude                                                                  |
| `municipality`    | string \| null | No       | **Yes** | City served                                                                       |
| `iso_country`     | string \| null | No       | **Yes** | ISO country code                                                                  |
| `iata_code`       | string \| null | No       | **Yes** | IATA code when assigned                                                           |
| `relevance_score` | integer        | **Yes**  | Never   | Higher = better match (`100` = exact code hit)                                    |

<APIPage document="&#x22;https://api.skylinkapi.com/v3.1/openapi.json&#x22;" operations="[{&#x22;path&#x22;:&#x22;/airports/search/text&#x22;,&#x22;method&#x22;:&#x22;get&#x22;}]" />

<a id="search-by-location" />

## Search by location [#search-by-location]

Returns airports within a radius of a coordinate, sorted nearest-first. Each result includes `distance_km`.

### Request [#request-1]

<DocRequirements>
  <DocRequirementAuth />
</DocRequirements>

<DocApiPath method="GET" path="/airports/search/location" />

| Parameter | Type   | Required | Default   | Description                                         |
| --------- | ------ | -------- | --------- | --------------------------------------------------- |
| `lat`     | number | Yes      | -         | Latitude (`-90` to `90`, decimal degrees WGS-84)    |
| `lon`     | number | Yes      | -         | Longitude (`-180` to `180`, decimal degrees WGS-84) |
| `radius`  | number | No       | `50`      | Search radius in **kilometres** (must be > 0)       |
| `type`    | string | No       | all types | Filter by airport `type`, e.g. `large_airport`      |

Returns up to **50** airports. Heliports and closed fields may appear near dense urban areas unless you pass `type`.

### Response [#response-1]

```json
{
  "search_location": {
    "latitude": 40.64,
    "longitude": -73.78,
    "radius_km": 50.0,
    "type_filter": null
  },
  "airports": [
    {
      "ident": "KJFK",
      "name": "John F. Kennedy International Airport",
      "type": "large_airport",
      "latitude_deg": 40.639447,
      "longitude_deg": -73.779317,
      "municipality": "New York",
      "iso_country": "US",
      "iata_code": "JFK",
      "distance_km": 0.08
    }
  ],
  "airports_found": 42
}
```

| Field             | Type    | Required | Description              |
| ----------------- | ------- | -------- | ------------------------ |
| `search_location` | object  | **Yes**  | Echo of query parameters |
| `airports`        | array   | **Yes**  | Distance-sorted matches  |
| `airports_found`  | integer | **Yes**  | Count returned (≤ 50)    |

#### Airport item (`airports[]`) [#airport-item-airports-1]

Same core fields as text search, plus `distance_km` ([great-circle distance](https://en.wikipedia.org/wiki/Great-circle_distance) from the query point in kilometres).

<APIPage document="&#x22;https://api.skylinkapi.com/v3.1/openapi.json&#x22;" operations="[{&#x22;path&#x22;:&#x22;/airports/search/location&#x22;,&#x22;method&#x22;:&#x22;get&#x22;}]" />

<a id="search-by-ip" />

## Search by IP [#search-by-ip]

Geolocates an IP address and returns nearby airports using the same distance-sorted list as [location search](#search-by-location).

### Request [#request-2]

<DocRequirements>
  <DocRequirementAuth />
</DocRequirements>

<DocApiPath method="GET" path="/airports/search/ip" />

| Parameter | Type   | Required | Default   | Description                                                                                   |
| --------- | ------ | -------- | --------- | --------------------------------------------------------------------------------------------- |
| `ip`      | string | No       | caller IP | IPv4/IPv6 to geolocate. Omit to use the requester's IP (RapidAPI forwards the client address) |
| `radius`  | number | No       | `50`      | Search radius in kilometres                                                                   |

Omit `ip` for server-side "airports near me" when RapidAPI receives the end-user IP. Pass the visitor IP explicitly when your backend proxies requests.

### Response [#response-2]

```json
{
  "ip_address": "203.0.113.10",
  "location": {
    "latitude": 40.7128,
    "longitude": -74.006,
    "city": "New York",
    "region": "New York",
    "country": "United States",
    "country_code": "US"
  },
  "search_radius_km": 50.0,
  "airports": [
    {
      "ident": "KJFK",
      "name": "John F. Kennedy International Airport",
      "distance_km": 20.5
    }
  ],
  "airports_found": 38
}
```

| Field              | Type           | Required | Null?   | Description                                              |
| ------------------ | -------------- | -------- | ------- | -------------------------------------------------------- |
| `ip_address`       | string         | **Yes**  | Never   | IP that was geolocated                                   |
| `location`         | object \| null | No       | **Yes** | Resolved geolocation; `null` when lookup fails           |
| `search_radius_km` | number         | **Yes**  | Never   | Applied search radius                                    |
| `airports`         | array          | **Yes**  | Never   | Distance-sorted airports (same shape as location search) |
| `airports_found`   | integer        | **Yes**  | Never   | Count returned                                           |
| `error`            | string \| null | No       | **Yes** | Error message when geolocation fails                     |

**Accuracy note.** Residential IPs resolve to city level; VPN and data-center IPs may be inaccurate. Show the resolved city and let the user override.

<APIPage document="&#x22;https://api.skylinkapi.com/v3.1/openapi.json&#x22;" operations="[{&#x22;path&#x22;:&#x22;/airports/search/ip&#x22;,&#x22;method&#x22;:&#x22;get&#x22;}]" />

## Client types [#client-types]

<DocClientTypes id="v31/airports/text-search-types" />

## Integration [#integration]

Power an airport autocomplete field with ranked text search results.

The example below caches text-search responses for one hour and uses connect/read timeouts so typing in a search box cannot hang your UI.

<DocExample id="v31/airports/text-search-fetch" />

### Implementation notes [#implementation-notes]

**Debounce user input.** Wait \~300 ms after the last keystroke before calling the API. Require at least 2 characters to avoid 422 validation errors.

**Relevance ranking.** `relevance_score: 100` indicates an exact ICAO/IATA match — pin those to the top of autocomplete lists.

**Filter airport types.** For airline apps, filter to `large_airport` / `medium_airport` after fetch, or pass `type=large_airport` on location search.

**Chain to full lookup.** After selection, call [Airports](/docs/v31/airports) with `icao` for runways and frequencies.

**IP search privacy.** Disclose IP geolocation in your privacy policy. Prefer browser geolocation + [location search](#search-by-location) when the user grants permission.

## Error responses [#error-responses]

Shared validation and platform errors: [Error Handling](/docs/errors). Endpoint-specific:

### 422 - text query too short [#422---text-query-too-short]

```json
{
  "detail": [
    {
      "type": "string_too_short",
      "loc": ["query", "q"],
      "msg": "String should have at least 2 characters"
    }
  ]
}
```

### GeoIP lookup failed (IP search) [#geoip-lookup-failed-ip-search]

When IP geolocation fails, the API returns HTTP `200` with `location: null`, `airports: []`, and a populated `error` string. Treat this as a soft failure — prompt for manual entry or fall back to browser geolocation.

```json
{
  "ip_address": "203.0.113.10",
  "location": null,
  "search_radius_km": 50.0,
  "airports": [],
  "airports_found": 0,
  "error": "Unable to geolocate IP address"
}
```

***

Related: [Airports](/docs/v31/airports) · [METAR](/docs/v31/weather-metar) · [Countries](/docs/v31/countries)
