Skip to main content
Fetches earthquake events within a specified radius of given coordinates using the Haversine formula for precise distance calculation. This endpoint is ideal for finding earthquakes near cities, landmarks, or specific points of interest.

Endpoint

Method: GET
Path: /v1/earthquakes/location
Authentication: Not required

Parameters

number
required
Latitude in decimal degrees.Validation:
  • Must be a valid number
  • Valid range: -90 to 90
  • Returns 400 error if missing or invalid: “Please provide valid latitude and longitude”
number
required
Longitude in decimal degrees.Validation:
  • Must be a valid number
  • Valid range: -180 to 180
  • Returns 400 error if missing or invalid: “Please provide valid latitude and longitude”
number
default:"50"
Search radius in kilometers.Default: 50 kmValidation:
  • Minimum: 0.1 km
  • If not provided or invalid, defaults to 50 km
integer
default:"1"
Page number for pagination. Must be a positive integer greater than 0.Validation:
  • Must be > 0
  • Returns 400 error if invalid
integer
default:"50"
Number of results per page. Must be a positive integer greater than 0.Validation:
  • Must be > 0
  • Returns 400 error if invalid
string
default:"-time"
Sort order for results. Prefix with - for descending order.Allowed values:
  • time or -time (default: descending)
  • magnitude or -magnitude
  • depth or -depth
string
Comma-separated list of fields to include in response.Allowed values:
  • time
  • magnitude
  • depth
  • place
  • coordinates

Request Example

Response

boolean
Indicates if the request was successful
integer
HTTP status code (200 for success)
string
HTTP status message (“OK” for success)
string
Human-readable message. Format: “Earthquakes events near [, ] within km from to today”
array
Array of GeoJSON Feature objects containing earthquake data
object
Request metadata containing method, path, and timestamp
integer
Total count of earthquakes within the specified radius
object
Pagination details with page, totalPages, limit, and hasMore

Response Example

Error Responses

Missing or Invalid Coordinates

Invalid Limit Parameter

Invalid Page Parameter

Implementation Details

  • Distance Calculation: Uses Haversine formula via haversine-distance package for precise great-circle distance
  • Bounding Box Optimization: Initial query uses approximate bounding box (degreeRadius = radius / 111 km) to reduce data fetching
  • Precise Filtering: Results are filtered using exact Haversine distance calculation
  • Date Range: From start of current year to today
  • Coordinate Format: GeoJSON format [longitude, latitude, depth]
  • Sorting: Default sort is by time (most recent first: -time)
  • Data Source: INGV API with minlatitude, maxlatitude, minlongitude, maxlongitude parameters

Distance Calculation Process

  1. Calculate approximate degree radius: radius_km / 111
  2. Create bounding box: lat ± degreeRadius, lon ± degreeRadius
  3. Fetch earthquakes within bounding box from INGV
  4. Filter results using precise Haversine distance
  5. Return only earthquakes within exact radius

Use Cases

  • Find earthquakes near cities or populated areas
  • Analyze seismic activity around specific landmarks
  • Risk assessment for infrastructure projects
  • Real estate seismic risk analysis
  • Emergency response planning

Coordinate Examples