Skip to main content

Overview

The TerraQuake API uses standard HTTP status codes and returns consistent error response formats to help you identify and handle issues effectively. All errors include descriptive messages and metadata to assist with debugging.

Error Response Format

All error responses follow this standardized structure:

Error Response Fields

boolean
Always false for error responses
integer
HTTP status code (400, 404, 429, 500, 503, etc.)
string
Human-readable error description explaining what went wrong and how to fix it
object
Additional metadata about the error

HTTP Status Codes

The API uses standard HTTP status codes to indicate the success or failure of requests:

Success Codes

success
Request succeeded. The response body contains the requested data.

Client Error Codes (4xx)

error
Invalid request parameters or malformed request.Common causes:
  • Invalid pagination parameters (page < 1, limit < 1)
  • Invalid date formats
  • Missing required parameters
  • Invalid parameter types
error
The requested resource does not exist.Common causes:
  • Invalid endpoint URL
  • Non-existent earthquake ID
  • Unavailable region
error
Rate limit exceeded.Solution: Wait for the duration specified in the Retry-After header before retrying.See Rate Limiting for more details.

Server Error Codes (5xx)

error
An unexpected error occurred on the server.What to do:
  • Retry the request after a brief delay
  • If the error persists, contact support
error
The upstream data source (INGV API) is temporarily unavailable.What to do:
  • Retry the request after a few seconds
  • Implement exponential backoff for retries

Common Error Scenarios

Invalid Pagination Parameters

Request:
Response:

Rate Limit Exceeded

Request:
Response:
Response Headers:

Upstream Service Error

Request:
Response:

Invalid Date Format

Request:
Response:

Not Found Error

Request:
Response:

Error Handling Implementation

The API uses a centralized error handler utility for consistent error responses:
Source: /home/daytona/workspace/source/backend/src/utils/handleHttpError.js:5-19

Handling Errors in Your Code

JavaScript/TypeScript

Python

Go

Best Practices

1

Always Check Response Status

Don’t assume requests succeed. Always check the HTTP status code or the success field in the response.
2

Implement Retry Logic

For server errors (5xx) and rate limits (429), implement retry logic with exponential backoff.
3

Log Errors for Debugging

Always log error details including the timestamp, status code, and message for debugging.
4

Handle Rate Limits Gracefully

Use the Retry-After header to determine when to retry after hitting rate limits.See Rate Limiting for detailed examples.
5

Validate Input Before Sending

Validate parameters client-side before making requests to catch errors early.
6

Set Appropriate Timeouts

Set reasonable request timeouts to avoid hanging requests.

Error Monitoring

For production applications, implement error monitoring:

Common Questions

  • 500 (Internal Server Error): An unexpected error in the TerraQuake API itself
  • 503 (Service Unavailable): The upstream INGV data source is temporarily unavailable
Both should be retried with exponential backoff.
No. 4xx errors indicate client-side problems (invalid parameters, rate limits, etc.). Fix the request instead of retrying, except for 429 (rate limit) where you should wait and retry.
  • 429 errors: Use the Retry-After header value
  • 5xx errors: Use exponential backoff (1s, 2s, 4s, etc.)
  • Network errors: Start with 1s and increase exponentially
Error messages are designed to be descriptive. If you encounter an unclear error, check:
  1. The HTTP status code
  2. The timestamp in meta.timestamp
  3. Your request parameters
If the issue persists, contact support with the error details.