Skip to main content

Country Lookup

Determine which country a GPS coordinate falls in.

Endpoint

GET /geo/country/fromGps/{latitude},{longitude}

Parameters

ParameterTypeLocationDescription
latitudenumberpathLatitude coordinate (-90 to 90)
longitudenumberpathLongitude coordinate (-180 to 180)

Response

Returns an ISO 3166-1 alpha-3 country code as a plain string.

Examples

# New York, USA
curl "https://api.boxesnlines.com/geo/country/fromGps/40.7128,-74.0060" \
-H "X-API-Key: YOUR_API_KEY"
# Response: "USA"

# London, UK
curl "https://api.boxesnlines.com/geo/country/fromGps/51.5074,-0.1278" \
-H "X-API-Key: YOUR_API_KEY"
# Response: "GBR"

# Tokyo, Japan
curl "https://api.boxesnlines.com/geo/country/fromGps/35.6762,139.6503" \
-H "X-API-Key: YOUR_API_KEY"
# Response: "JPN"
const response = await fetch(
"https://api.boxesnlines.com/geo/country/fromGps/40.7128,-74.0060",
{ headers: { "X-API-Key": "YOUR_API_KEY" } }
);

const countryCode = await response.text();
console.log(countryCode); // "USA"

Error Responses

StatusDescription
400Invalid coordinates (latitude outside -90 to 90, longitude outside -180 to 180)
404No country found at the given coordinates (e.g., ocean, Antarctica)
429Rate limit exceeded

For detailed error handling patterns, see Error Handling.

Use Cases

  • User localization: Detect a user's country for language or currency defaults
  • Content filtering: Show region-specific content based on location
  • Analytics: Aggregate user activity by country
  • Compliance: Verify user location for regulatory requirements

Try It

Use the interactive API reference to test this endpoint with your own API key.