TravelyzerTravelyzerDocs

Autocomplete

Real-time search suggestions for user interfaces.

GET /v1/geocoding/autocomplete

Provides real-time search suggestions during user input. This endpoint is optimized for speed and returns lightweight results, ideal for search fields.

Designed for speed: Autocomplete is optimized for LLMs and AI applications that need to quickly identify a place (country, city, monument) without superfluous details. It does not return hotels or restaurants.

Endpoint

GET https://places.gotravelyzer.com/v1/geocoding/autocomplete

Authentication

This endpoint requires authentication via a JWT Bearer token.

Authorization: Bearer YOUR_JWT_TOKEN

Parameters

Query Parameters

ParameterTypeRequiredDescriptionDefault
qstringYesPartial search term-
limitintegerNoNumber of suggestions (1-10)5

The parameter is called q (not query) for this route, to keep URLs concise.


Requests

Basic Request

curl "https://places.gotravelyzer.com/v1/geocoding/autocomplete?q=Par" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

With Custom Limit

curl "https://places.gotravelyzer.com/v1/geocoding/autocomplete?q=Par&limit=10" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Search for a Monument

curl "https://places.gotravelyzer.com/v1/geocoding/autocomplete?q=Eiffel%20Tow" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Search for an Airport

curl "https://places.gotravelyzer.com/v1/geocoding/autocomplete?q=CDG" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Response

Success Example (200 OK)

[
  {
    "display_name": "Paris, Île-de-France, France",
    "lat": 48.8588897,
    "lon": 2.3200410,
    "country": "France",
    "city": "Paris",
    "type": "city"
  },
  {
    "display_name": "Paris, Texas, United States",
    "lat": 33.6617962,
    "lon": -95.5555199,
    "country": "United States",
    "city": "Paris",
    "type": "city"
  },
  {
    "display_name": "Parc des Princes, Paris, France",
    "lat": 48.8414356,
    "lon": 2.2530177,
    "country": "France",
    "city": "Paris",
    "type": "stadium"
  }
]

Autocomplete responses are lightweight to optimize speed. For complete information about a place, use the Forward Geocoding endpoint.

Response Fields

FieldTypeDescription
display_namestringFull name of the place to display
latnumberLatitude in decimal degrees
lonnumberLongitude in decimal degrees
countrystringCountry name
citystringCity name (if applicable)
typestringPlace type (city, town, village, stadium, airport, etc.)

HTTP Codes

CodeStatusDescription
200OKSuccessful request (may return an empty array)
400Bad RequestMissing or invalid q parameter
401UnauthorizedMissing or invalid JWT token
429Too Many RequestsRequest limit exceeded
502Bad GatewayService error
503Service UnavailableService temporarily unavailable

Error Examples

400 Bad Request - Missing Parameter

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "q parameter is required"
}

Best Practices

Implement Debounce

Important: Don't make a request on every keystroke. Use a debounce of 250-300ms to avoid overloading the API.

# Simulating debounce with a script
# Only send the request 300ms after the last input
 
sleep 0.3  # Wait for debounce
curl "https://places.gotravelyzer.com/v1/geocoding/autocomplete?q=Paris" \
  -H "Authorization: Bearer $TOKEN"

Minimum Length

Don't send requests for strings that are too short:

LengthRecommended Action
1 characterDon't request
2 charactersStart requesting
3+ charactersRequest normally
# Check length before calling the API
QUERY="Pa"
if [ ${#QUERY} -ge 2 ]; then
  curl "https://places.gotravelyzer.com/v1/geocoding/autocomplete?q=$QUERY" \
    -H "Authorization: Bearer $TOKEN"
fi

Client-Side Cache

Cache recent results to improve performance and reduce API calls:

RequestAction
"Par"API request → Cache
"Pari"API request → Cache
"Par" (again)Use cache

Performance

The autocomplete endpoint is optimized for fast responses:

MetricTarget
Target response time< 100ms
Average response size< 2 KB

Tips for Optimizing Latency

  1. Use debounce: Avoid unnecessary requests
  2. Cache results: Reduce repeated calls
  3. Limit results: limit=5 is sufficient for most cases
  4. Cancel in-flight requests: If the user continues typing

Differences from Forward Geocoding

AspectAutocompleteForward Geocoding
Parameterqquery
OptimizationSpeedCompleteness
Returned fieldsLimitedComplete
Max limit1050
Use caseSearch fieldsFull geocoding

Limits

LimitValue
Maximum suggestions10 per request
Minimum q length1 character
Maximum q length500 characters
Counting1 request against quota

Technical Notes

  • Results are sorted by relevance
  • An empty array [] is returned if no suggestions match
  • Responses are optimized to be lightweight (fewer fields)
  • Target response time is under 100ms

Next Steps