USGS Earthquake Hazards Program

USGS Earthquake Hazards Program

Science

Earthquakes data real-time. This is an implementation of the FDSN Event Web Service Specification, and allows custom searches for earthquake information using a variety of parameters.

Visit API

📚 Documentation & Examples

Everything you need to integrate with USGS Earthquake Hazards Program

🚀 Quick Start Examples

USGS Earthquake Hazards Program Javascript Examplejavascript
// USGS Earthquake Hazards Program API Example
const response = await fetch('https://earthquake.usgs.gov/fdsnws/event/1/', {
    method: 'GET',
    headers: {
        'Content-Type': 'application/json'
    }
});

const data = await response.json();
console.log(data);

Explore Earthquake Data with the USGS API

The United States Geological Survey (USGS) provides a public API to access information on earthquakes worldwide. This API allows developers to query earthquake data in real time using various parameters such as location, time, and magnitude.

Getting Started

To start exploring the earthquake data, we need to first make a request to the API endpoint. The endpoint for the USGS earthquake API is https://earthquake.usgs.gov/fdsnws/event/1/query.

Query Parameters

The following query parameters are available for filtering the results:

  • starttime - start time of the earthquake (YYYY-MM-DD)
  • endtime - end time of the earthquake (YYYY-MM-DD)
  • minmagnitude - minimum magnitude of the earthquake
  • maxmagnitude - maximum magnitude of the earthquake
  • latitude - latitude of the location
  • longitude - longitude of the location
  • maxradiuskm - maximum radius around the location
  • orderby - order of the results (time, magnitude, distance)

API Example Code in JavaScript

Below is an example on how to retrieve earthquake data with JavaScript.

const endpoint = "https://earthquake.usgs.gov/fdsnws/event/1/query";

// Set query parameters
const params = {
  starttime: "2021-01-01",
  endtime: "2021-02-01",
  minmagnitude: 6.0,
  latitude: 34.0522,
  longitude: -118.2437,
  maxradiuskm: 1000,
  orderby: "time"
};

// Construct query string
const queryString = Object.keys(params)
  .map(key => key + "=" + encodeURIComponent(params[key]))
  .join("&");

// Make API request with fetch
fetch(endpoint + "?" + queryString)
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

This code retrieves all earthquakes with a magnitude of 6.0 or higher that occurred within a 1000 km radius of Los Angeles between January 1, 2021 and February 1, 2021. The resulting data is logged to the console.

Conclusion

With the USGS earthquake API, we can easily access and analyze earthquake data in real time using just a few lines of code. By applying different query parameters, we can hone in on specific information and gain a better understanding of seismology. The possibilities for exploration with this API is endless.

📊 30-Day Uptime History

Daily uptime tracking showing online vs offline minutes

Jun 6Jun 8Jun 10Jun 12Jun 14Jun 16Jun 18Jun 20Jun 22Jun 24Jun 26Jun 28Jun 30Jul 2Jul 504008001440Minutes
Online
Offline

Related APIs in Science