RandomCoords REST API Documentation

Your API Token

2d1676b28b82ff9cd702b6240e91b3d3:03c6f78189939ed1b7916e5ca8232cf4762d2eb89d7be5dc0e0ee48852853347eff3c6e3b7448b3c11af22f98ca6d3c44520d8e79d08cf909f4dbe18e463fbc30c0a94c66998206d0ad41895e7bc2f6f
All APIs require x-api-token in header. By using the RandomCoords APIs, you agree to the Terms and Conditions.
The client libraries are available for:

APIs

Get Regions

GET https://api.randomcoords.com/v1/coordinates/regions
Response
{
  type: "regions";
  results: number;
  data: {
    id: string;
    name: string;
  }[];
}

Get Random Coordinates in a Region

GET https://api.randomcoords.com/v1/coordinates/regions/{region}?limit={number}

Query Parameters: limit (optional, max 100, default 1)

Response
{
  id: string;
  name: string;
  type: "region";
  results: number;
  data: {
    id: string;
    country: string;
    city: string;
    iso2: string;
    coordinates: [number, number];
  }[];
}

Get Countries

GET https://api.randomcoords.com/v1/coordinates/countries
Response
{
  type: "countries";
  results: number;
  data: {
    id: string;
    name: string;
    iso2: string;
  }[];
}

Get Random Coordinates in a Country

GET https://api.randomcoords.com/v1/coordinates/countries/{country}?limit={number}

Query Parameters: limit (optional, max 100, default 1)

Response
{
  id: string;
  name: string;
  type: "country";
  regions: string[];
  iso2: string;
  results: number;
  data: {
    city: string;
    state?: string;
    coordinates: [number, number];
  }[];
}

Status Codes

  • 200 - Success.
  • 401 - Unauthorized.
    • Ensure x-api-token in the header is not malformed.
  • 403 - Forbidden.
    • Confirm x-api-token exists in the header.
    • Ensure the URL is valid.
  • 404 - Not Found.
    • Verify the identifiers in the URL (e.g., region or country) are correct.
  • 429 - Too Many Requests.
    • Wait before retrying.
    • Cache results whenever possible.
401 and 404 responses return a JSON object with a message field:
Response
{
  message: string;  
}