Skip to main content

Random GPS Coordinates API

MOCK DATA

Random geographic coordinates: uniform across the globe (no pole clustering), inside a bounding box, or within a radius of a point — with haversine distances.

Generated test data for fixtures and development

Base URL
/api/coordinates
Capabilities
1 route Seedable
Last updated
July 30, 2026

GET /api/coordinates

Live requestRuns against the public API
No key required
GET/api/coordinates?seed=42

Request parameters

Center point as 'lat,lng' (latitude -90..90, longitude -180..180). Points are sampled uniformly within 'radiusKm' of it and distanceKm is filled in. Mutually exclusive with 'bbox'.

Disk radius in km around 'near' (0.1–20000). Defaults to 50 when 'near' is set; using it without 'near' is a 400.

Bounding box as 'minLat,minLng,maxLat,maxLng' (min ≤ max, latitudes -90..90, longitudes -180..180). Points are sampled area-uniformly inside it. Mutually exclusive with 'near'.

Advanced response options7 options

How many records to generate (1–100).

Deterministic output: the same seed always returns the same records. Omit for random (the used seed is echoed in meta.seed).

Return only these fields (comma-separated). Mutually exclusive with 'exclude'.

Return all fields except these (comma-separated).

Response format: json envelope, ndjson (one record per line) or csv.

Pretty-print the JSON response.

Drop the envelope: return the raw array/object without data/meta wrapper.

Response

Example parameters are ready. Send the request to inspect the live response.

Route reference

Code samples Ready-to-copy requests in 4 languages
Choose a code sample language
curl "https://randomapi.dev/api/coordinates?seed=42"
const res = await fetch("https://randomapi.dev/api/coordinates?seed=42");
const { data, meta } = await res.json();
import requests

data = requests.get("https://randomapi.dev/api/coordinates?seed=42").json()["data"]
$json = json_decode(file_get_contents(
  "https://randomapi.dev/api/coordinates?seed=42"
), true);
$data = $json["data"];
Parameters Route-specific request inputs 3
near string

Center point as 'lat,lng' (latitude -90..90, longitude -180..180). Points are sampled uniformly within 'radiusKm' of it and distanceKm is filled in. Mutually exclusive with 'bbox'.

example: near=40.7128,-74.006
radiusKm float

Disk radius in km around 'near' (0.1–20000). Defaults to 50 when 'near' is set; using it without 'near' is a 400.

allowed: 0.1 – 20000
example: radiusKm=25
bbox string

Bounding box as 'minLat,minLng,maxLat,maxLng' (min ≤ max, latitudes -90..90, longitudes -180..180). Points are sampled area-uniformly inside it. Mutually exclusive with 'near'.

example: bbox=24.5,-125,49.5,-66.9
Universal parameters Shared response and formatting options 7
count int

How many records to generate (1–100).

default: 10
allowed: 1 – 100
example: count=3
seed int

Deterministic output: the same seed always returns the same records. Omit for random (the used seed is echoed in meta.seed).

example: seed=42
fields list

Return only these fields (comma-separated). Mutually exclusive with 'exclude'.

example: fields=latitude,longitude
exclude list

Return all fields except these (comma-separated).

example: exclude=distanceKm
format enum

Response format: json envelope, ndjson (one record per line) or csv.

default: json
allowed: json | ndjson | csv
example: format=csv
pretty boolean

Pretty-print the JSON response.

default: false
example: pretty=true
unwrap boolean

Drop the envelope: return the raw array/object without data/meta wrapper.

default: false
example: unwrap=true
Response schema Fields returned in each record 3
latitude float

Latitude in decimal degrees (-90..90), rounded to 6 decimals (~0.11 m).

example: 40.782912

longitude float

Longitude in decimal degrees (-180..180), rounded to 6 decimals.

example: -73.965355

distanceKm float nullable

Great-circle (haversine, R = 6371 km) distance to the 'near' point in km, rounded to 2 decimals — null unless 'near' is used.

example: 7.42

Documented examples

Build-generated requests and complete responses
3
Ten uniform points across the globe
GET /api/coordinates?seed=42
{
  "data": [
    {
      "latitude": -2.546864,
      "longitude": 63.812869,
      "distanceKm": null
    },
    {
      "latitude": -67.058909,
      "longitude": -177.913729,
      "distanceKm": null
    },
    {
      "latitude": 45.558687,
      "longitude": -137.158407,
      "distanceKm": null
    },
    {
      "latitude": -43.732874,
      "longitude": 30.496248,
      "distanceKm": null
    },
    {
      "latitude": 41.866741,
      "longitude": 77.437747,
      "distanceKm": null
    },
    {
      "latitude": -75.181374,
      "longitude": -32.031534,
      "distanceKm": null
    },
    {
      "latitude": -56.48045,
      "longitude": -40.249277,
      "distanceKm": null
    },
    {
      "latitude": 41.858417,
      "longitude": 12.748485,
    …
    "generatedAt": "2026-07-30T15:14:08.000Z"
  }
}
Points within 25 km of New York City
GET /api/coordinates?near=40.7128,-74.006&radiusKm=25&count=5
{
  "data": [
    {
      "latitude": 40.644073,
      "longitude": -74.189791,
      "distanceKm": 17.28
    },
    {
      "latitude": 40.757481,
      "longitude": -74.003851,
      "distanceKm": 4.97
    },
    {
      "latitude": 40.86526,
      "longitude": -73.818859,
      "distanceKm": 23.14
    },
    {
      "latitude": 40.636674,
      "longitude": -74.065071,
      "distanceKm": 9.82
    },
    {
      "latitude": 40.667849,
      "longitude": -74.270169,
      "distanceKm": 22.83
    }
  ],
  "meta": {
    "endpoint": "coordinates",
    "count": 5,
    "seed": 42,
    "params": {
      "near": "40.7128,-74.006",
      "radiusKm": 25
    },
    "generatedAt": "2026-07-30T15:14:08.000Z"
  }
}
Points inside the contiguous US bounding box
GET /api/coordinates?bbox=24.5,-125,49.5,-66.9&count=5&seed=7
{
  "data": [
    {
      "latitude": 40.470945,
      "longitude": -75.403725,
      "distanceKm": null
    },
    {
      "latitude": 37.925666,
      "longitude": -90.324692,
      "distanceKm": null
    },
    {
      "latitude": 34.855404,
      "longitude": -80.55059,
      "distanceKm": null
    },
    {
      "latitude": 43.331618,
      "longitude": -107.279475,
      "distanceKm": null
    },
    {
      "latitude": 46.287619,
      "longitude": -108.368841,
      "distanceKm": null
    }
  ],
  "meta": {
    "endpoint": "coordinates",
    "count": 5,
    "seed": 7,
    "params": {
      "bbox": "24.5,-125,49.5,-66.9"
    },
    "generatedAt": "2026-07-30T15:14:08.000Z"
  }
}

About this API

Coverage & behavior

Generates random latitude/longitude pairs with mathematically honest sampling — the kind map demos and geo tests actually need:

  • Global (no params): uniform on the sphere via lat = asin(2u − 1), not uniform in latitude — naive generators cluster points toward the poles; this one doesn't.
  • bbox=minLat,minLng,maxLat,maxLng: area-uniform inside the box (every record is guaranteed inside, bounds inclusive). Antimeridian-crossing boxes (minLng > maxLng) are rejected — split them at 180°.
  • near=lat,lng (+ radiusKm, default 50): uniform over the spherical disk around the point — radius scaled by √u so points don't pile up at the center, and offsets computed with the exact spherical formula so the disk stays a disk even at 78°N or across the antimeridian. Each record's distanceKm is the haversine distance (R = 6371 km) to the near point, computed from the returned rounded coordinates, and is always ≤ radiusKm.

near and bbox are mutually exclusive (400), radiusKm without near is a 400, and malformed or out-of-range values are rejected with the expected format spelled out. Coordinates have 6 decimals (~0.11 m); with a seed the same request returns identical points forever.

Use it for

  • Seed map UIs, heatmaps and clustering demos with realistic, pole-free point distributions
  • Generate fixtures for geofencing and 'near me' features — distanceKm comes precomputed
  • Load-test geospatial indexes and tile servers with reproducible seeded coordinates

Frequently asked questions

Are the points uniformly distributed?

Yes — global points are area-uniform on the sphere, avoiding the pole-clustering bug of naive lat/lng generators.

Can I generate points near a location?

Yes — near=lat,lng with radiusKm scatters points within that radius and reports each point's haversine distanceKm; or pass bbox for a rectangle.

Can I use near and bbox together?

No — they're mutually exclusive constraints, and the API answers 400 rather than silently picking one.