Error Handling

HTTP error codes and troubleshooting with Travelyzer Places API.

Error Handling

Travelyzer Places API uses standard HTTP codes and returns structured error messages in JSON. This guide helps you understand and resolve common errors.

Error Format

All errors follow this JSON format:

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "Detailed error description"
}
FieldTypeDescription
statusCodenumberHTTP error code
errorstringError type (standard HTTP name)
messagestringHuman-readable error description
retryAfternumber(Optional) Seconds to wait before retrying

Client Errors (4xx)

These errors indicate a problem with your request. They are generally not recoverable without correction.

400 Bad Request

The request is malformed or required parameters are missing.

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

Common causes:

CauseExampleSolution
Missing parameter/v1/geocoding/forward without queryAdd ?query=Paris
Empty parameter?query=Provide a non-empty value
Invalid coordinates?lat=999&lon=999Use lat between -90/90, lon between -180/180

Corrected request example:

# Correct
curl "https://places.gotravelyzer.com/v1/geocoding/forward?query=Paris" \
  -H "Authorization: Bearer YOUR_TOKEN"
 
# Incorrect (missing parameter)
curl "https://places.gotravelyzer.com/v1/geocoding/forward" \
  -H "Authorization: Bearer YOUR_TOKEN"

401 Unauthorized

Authentication failed.

{
  "statusCode": 401,
  "error": "Unauthorized",
  "message": "Invalid token"
}

Common causes and solutions:

MessageCauseSolution
Missing Authorization headerHeader absentAdd Authorization: Bearer <token>
Invalid tokenMalformed tokenCheck the token format
Token expiredToken expiredRequest a new token
Invalid API keyWrong key during exchangeCheck the API Key
Invalid API secretWrong secret during exchangeCheck the API Secret

Header verification:

# Correct
curl "https://places.gotravelyzer.com/v1/geocoding/forward?query=Paris" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
 
# Incorrect (missing Bearer)
curl "https://places.gotravelyzer.com/v1/geocoding/forward?query=Paris" \
  -H "Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
 
# Incorrect (wrong header)
curl "https://places.gotravelyzer.com/v1/geocoding/forward?query=Paris" \
  -H "X-API-Key: my_token"

Get a new token:

curl -X POST "https://api2.gotravelyzer.com/api-clients/token" \
  -H "Content-Type: application/json" \
  -d '{
    "apiKey": "gck_your_api_key",
    "apiSecret": "gcs_your_api_secret"
  }'

403 Forbidden

Access is denied despite valid authentication.

{
  "statusCode": 403,
  "error": "Forbidden",
  "message": "API key disabled"
}

Common causes:

MessageCauseSolution
API key disabledKey disabledReactivate in Dashboard
Quota exceededMonthly quota exceededWait for reset or upgrade
Domain not allowedDomain restrictionCheck restrictions
IP not allowedIP restrictionCheck restrictions

Actions:

  1. Log in to the Dashboard
  2. Check your API key status
  3. Check configured restrictions
  4. Contact support if necessary

404 Not Found

The requested endpoint does not exist.

{
  "statusCode": 404,
  "error": "Not Found",
  "message": "Cannot GET /unknown"
}

Available endpoints:

EndpointMethodDescription
/v1/geocoding/forwardGETForward geocoding
/v1/geocoding/reverseGETReverse geocoding
/v1/geocoding/autocompleteGETAutocomplete
/v1/geocoding/batchPOSTBatch geocoding
/healthGETService status
/sla-metricsGETSLA metrics
/sla-historyGETSLA history
/coverageGETCoverage by country

429 Too Many Requests

Request limit exceeded.

{
  "statusCode": 429,
  "error": "Too Many Requests",
  "message": "Rate limit exceeded",
  "retryAfter": 45
}

Handling 429:

# If you receive a 429, wait the time indicated in retryAfter
# then retry the request
 
# Check limit headers
curl -v "https://places.gotravelyzer.com/v1/geocoding/forward?query=Paris" \
  -H "Authorization: Bearer YOUR_TOKEN" 2>&1 | grep -i "x-ratelimit"

Response headers:

HeaderDescription
X-RateLimit-LimitLimit per minute
X-RateLimit-RemainingRemaining requests
Retry-AfterSeconds until reset

See Rate Limits for more details.


Server Errors (5xx)

These errors indicate a server-side problem. They are generally temporary and recoverable with a retry.

500 Internal Server Error

Unexpected server error.

{
  "statusCode": 500,
  "error": "Internal Server Error",
  "message": "An unexpected error occurred"
}

Action:

  • Retry the request after a few seconds
  • If the error persists after 3 attempts, contact support

502 Bad Gateway

Communication error with internal services.

{
  "statusCode": 502,
  "error": "Bad Gateway",
  "message": "Upstream service error"
}

Action:

  • Temporary error, usually resolved automatically
  • Retry after 2-5 seconds

503 Service Unavailable

The service is temporarily unavailable (maintenance).

{
  "statusCode": 503,
  "error": "Service Unavailable",
  "message": "Service temporarily unavailable"
}

Action:

  • Check the status page
  • Retry with exponential backoff
  • Service should be restored quickly

Retry Strategy

Exponential Backoff

For recoverable errors (429, 500, 502, 503), use exponential backoff:

Attempt 1: wait 1 second
Attempt 2: wait 2 seconds
Attempt 3: wait 4 seconds
Attempt 4: wait 8 seconds
...

Bash example:

#!/bin/bash
 
TOKEN="your_token"
QUERY="Paris"
MAX_RETRIES=3
 
for i in $(seq 1 $MAX_RETRIES); do
  RESPONSE=$(curl -s -w "\n%{http_code}" \
    "https://places.gotravelyzer.com/v1/geocoding/forward?query=$QUERY" \
    -H "Authorization: Bearer $TOKEN")
 
  HTTP_CODE=$(echo "$RESPONSE" | tail -1)
  BODY=$(echo "$RESPONSE" | head -n -1)
 
  if [ "$HTTP_CODE" -eq 200 ]; then
    echo "Success:"
    echo "$BODY"
    exit 0
  elif [ "$HTTP_CODE" -eq 429 ] || [ "$HTTP_CODE" -ge 500 ]; then
    WAIT=$((2 ** ($i - 1)))
    echo "Attempt $i failed (HTTP $HTTP_CODE). Retrying in ${WAIT}s..."
    sleep $WAIT
  else
    echo "Non-recoverable error (HTTP $HTTP_CODE):"
    echo "$BODY"
    exit 1
  fi
done
 
echo "Failed after $MAX_RETRIES attempts"
exit 1

Summary Table

CodeErrorRecoverableRecommended Action
400Bad RequestNoFix parameters
401UnauthorizedNoCheck/renew token
403ForbiddenNoCheck permissions in Dashboard
404Not FoundNoCheck endpoint URL
429Too Many RequestsYesWait retryAfter seconds
500Internal Server ErrorYesRetry with backoff
502Bad GatewayYesRetry with backoff
503Service UnavailableYesRetry with backoff

Quick Diagnosis

# 1. Check that the API is accessible
curl "https://places.gotravelyzer.com/health"
# Expected: {"ok": true}
 
# 2. Check that your token is valid
curl "https://places.gotravelyzer.com/v1/geocoding/forward?query=test" \
  -H "Authorization: Bearer YOUR_TOKEN"
# If 401: invalid or expired token
 
# 3. Check your quotas
curl -v "https://places.gotravelyzer.com/v1/geocoding/forward?query=test" \
  -H "Authorization: Bearer YOUR_TOKEN" 2>&1 | grep -E "X-RateLimit|X-Quota"
# Shows limit headers

Support

If you encounter persistent errors:

  1. Check the API status page
  2. Review your logs in the Dashboard
  3. Contact support: contact@gotravelyzer.com