Endpoint
Method: GETPath:
/v1/earthquakes/locationAuthentication: Not required
Parameters
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”
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”
Search radius in kilometers.Default: 50 kmValidation:
- Minimum: 0.1 km
- If not provided or invalid, defaults to 50 km
Page number for pagination. Must be a positive integer greater than 0.Validation:
- Must be > 0
- Returns 400 error if invalid
Number of results per page. Must be a positive integer greater than 0.Validation:
- Must be > 0
- Returns 400 error if invalid
Sort order for results. Prefix with
- for descending order.Allowed values:timeor-time(default: descending)magnitudeor-magnitudedepthor-depth
Comma-separated list of fields to include in response.Allowed values:
timemagnitudedepthplacecoordinates
Request Example
Response
Indicates if the request was successful
HTTP status code (200 for success)
HTTP status message (“OK” for success)
Human-readable message. Format: “Earthquakes events near [, ] within km from to today”
Array of GeoJSON Feature objects containing earthquake data
Request metadata containing method, path, and timestamp
Total count of earthquakes within the specified radius
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-distancepackage 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
- Calculate approximate degree radius:
radius_km / 111 - Create bounding box:
lat ± degreeRadius,lon ± degreeRadius - Fetch earthquakes within bounding box from INGV
- Filter results using precise Haversine distance
- 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
| City | Latitude | Longitude |
|---|---|---|
| Rome, Italy | 41.9028 | 12.4964 |
| Tokyo, Japan | 35.6762 | 139.6503 |
| Los Angeles, USA | 34.0522 | -118.2437 |
| Mexico City, Mexico | 19.4326 | -99.1332 |
| Istanbul, Turkey | 41.0082 | 28.9784 |
Related Endpoints
- By Region - Italian administrative regions
- Recent Earthquakes - Year-to-date events
- By Date Range - Custom date range