Skip to main content

Overview

This guide covers best practices for using the TerraQuake API efficiently and reliably. Follow these recommendations to build robust applications that provide the best user experience.

API Usage Patterns

Pagination Strategy

Always use pagination to manage large datasets and reduce response times.
Default limit is 50. Use limit=100 for fewer requests, or limit=25 for faster initial responses.

Request Only What You Need

Use field selection and sorting to optimize responses.

Use Appropriate Endpoints

Choose the most specific endpoint for your use case.
Python

Caching Strategies

Implement caching to reduce API calls and improve performance.

Time-Based Caching

1

Identify cacheable data

Historical data (past months/years) doesn’t change and can be cached indefinitely:
Python
2

Implement caching

Python

Using Redis for Caching

Python

Rate Limit Management

While the TerraQuake API doesn’t currently enforce strict rate limits, implement rate limiting to be a good API citizen and prepare for future restrictions.

Implement Request Throttling

Python

Exponential Backoff for Retries

Python

Error Handling

Comprehensive Error Handling

Python

Graceful Degradation

Python

Data Freshness and Polling

Smart Polling Strategy

Python

Performance Optimization

Parallel Requests

Python

Connection Pooling

Python

Monitoring and Logging

Python

Summary Checklist

✅ Do

  • Use pagination for large datasets
  • Implement caching with appropriate TTLs
  • Handle errors gracefully
  • Use specific endpoints
  • Request only needed fields
  • Implement retry logic
  • Monitor API usage
  • Use connection pooling

❌ Don't

  • Fetch all data without pagination
  • Poll too frequently (< 1 minute)
  • Ignore error responses
  • Make unnecessary requests
  • Hardcode API responses
  • Ignore timeouts
  • Skip logging
  • Create new connections per request

Next Steps

API Reference

Complete endpoint documentation

Filtering Guide

Learn about filter options