Overview
All successful TerraQuake API responses follow a consistent, standardized format. This makes it easy to parse responses and extract the data you need across all endpoints.Standard Response Structure
Every successful API response includes these core fields:Core Response Fields
Indicates whether the request was successful. Always
true for successful responses, false for errors.HTTP status code.
200 for successful requests.HTTP status text.
"OK" for successful requests.Human-readable description of the response. Examples:
"Earthquakes recent events""Earthquakes filtered by magnitude""Seismic stations retrieved successfully"
The main response data. Contains an array of earthquake features or other requested resources.
Metadata about the request and response.
Additional Fields
Depending on the endpoint, responses may include:Total number of earthquake records available (across all pages)
Pagination metadata. See Pagination for details.
Response Builder Implementation
The API uses a standardized utility to build all responses:/home/daytona/workspace/source/backend/src/utils/buildResponse.js:11-23
Earthquake Data Format (GeoJSON)
Earthquake data in thepayload follows the GeoJSON Feature format:
GeoJSON Feature Fields
Always
"Feature" for earthquake recordsUnique identifier for the earthquake event
Earthquake properties and metadata
GeoJSON geometry object
Complete Response Examples
Recent Earthquakes
Earthquakes by Magnitude
Empty Results
When no earthquakes match the query:Working with Timestamps
All timestamps in the API are provided in different formats:ISO 8601 Format (meta.timestamp)
Unix Timestamp in Milliseconds (properties.time)
Filtering and Sorting Responses
Some endpoints support additional query parameters to filter and sort results:Sorting
time, magnitude, depth
Sort order:
- Prefix with
-for descending (e.g.,-magnitude) - No prefix for ascending (e.g.,
time)
Field Selection
time, magnitude, depth, place, coordinates
Parsing Responses
JavaScript/TypeScript
Python
Best Practices
Check Success Field
Always verify
success is true before processing the payload.Use Pagination Metadata
Check
pagination.hasMore to determine if more data exists.Parse Timestamps Correctly
Convert
properties.time from milliseconds and meta.timestamp from ISO 8601.Handle Empty Payloads
Check if
payload is empty or totalEarthquakes is 0 before processing.Common Questions
Why are coordinates in [longitude, latitude] order?
Why are coordinates in [longitude, latitude] order?
This follows the GeoJSON specification, which uses
[longitude, latitude, altitude] order (x, y, z). This differs from common “lat, lon” notation.What timezone are timestamps in?
What timezone are timestamps in?
All timestamps are in UTC. Convert to your local timezone as needed.
Can I request the response in a different format (XML, CSV)?
Can I request the response in a different format (XML, CSV)?
Currently, the API only supports JSON responses following the GeoJSON standard for earthquake data.
What's the difference between 'code' and 'status'?
What's the difference between 'code' and 'status'?
code: Numeric HTTP status code (e.g.,200)status: Text representation (e.g.,"OK")