How to Search for Airports Using Autocomplete
The autocomplete endpoint is the first step in the Flights API booking flow. Use it to resolve airport names or IATA codes into structured airport data. The response headers include an x-correlation-id that you must capture and pass to all subsequent API calls.
Endpoint
GET /flights/api/v2/autocomplete?key={search_term}
Headers
| Header | Required | Description |
|---|---|---|
x-api-key | Yes | Your API key. |
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
key | string | Yes | Airport name, city name, or IATA code to search for. Minimum 2 characters recommended. |
Example Request
GET /flights/api/v2/autocomplete?key=SFO
Example Response
JSON
{
"status": "success",
"data": [
{
"airport_code": "SFO",
"airport_name": "San Francisco International Airport",
"city_code": "SFO",
"city_name": "San Francisco",
"country_code": "US",
"country_name": "United States"
}
],
"message": "Airports retrieved successfully"
}Response Fields
| Field | Type | Description |
|---|---|---|
status | string | Request status (success or error). |
data | array | List of matching airport objects. |
data[].airportcode | string | IATA airport code (e.g., SFO). |
data[].airportname | string | Full airport name. |
data[].citycode | string | IATA city code. |
data[].cityname | string | City name. |
data[].countrycode | string | ISO country code. |
data[].countryname | string | Full country name. |
message | string | Human-readable status message. |
Capturing the Correlation ID
The autocomplete response includes an x-correlation-id in the response headers. You must capture this value and include it as a header in all subsequent requests (search, availability, fare rules, and booking).
Response Headers:
x-correlation-id: abc123-def456-ghi789
Store this value and pass it as:
x-correlation-id: abc123-def456-ghi789
in the headers of your next API call.
Error Responses
| HTTP Status | Description |
|---|---|
| 400 | Invalid or missing key parameter. |
| 500 | Internal server error. Retry the request or contact support. |
Tips
- Search by IATA code (e.g.,
SFO,LAX,BLR) for the most precise results. - Search by city name (e.g.,
San Francisco,London) to return all airports in that city. - The
x-correlation-idis essential. Without it, the search endpoint will reject your request.
Next Steps
- How to Search for Flights — Use the airport codes and correlation ID to search for flights.