This module handles the complete backend data flow for the Earthquake Globe project. It connects to the live USGS Earthquake API, fetches real-time earthquake data, processes the GeoJSON response, and provides clean formatted data for the 3D Globe and Dashboard modules.
- Fetch live earthquake data from USGS API
- Process and clean raw GeoJSON data
- Create reusable API utility functions
- Handle API errors and loading states
- Implement live auto-refresh system
- Provide structured data for visualization
https://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php
https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojsonβ
Real-time earthquake data fetching
β
GeoJSON data processing
β
Auto-refresh every 60 seconds
β
Error handling system
β
Reusable React hooks
β
Clean formatted earthquake objects
src/
β
βββ services/
β βββ usgsApi.js
β
βββ hooks/
β βββ useEarthquakeData.js
β
βββ utils/
β βββ filterData.js
β
βββ mock/
βββ mockEarthquakeData.json- JavaScript (ES6+)
- React
- Vite
- Fetch API
- USGS GeoJSON API
Clone repository:
git clone <repository-url>Install dependencies:
npm installRun development server:
npm run devconst API_URL =
"https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson";
export async function fetchEarthquakeData() {
try {
const response = await fetch(API_URL);
const data = await response.json();
οΏ½OB return data.features.map((quake) => ({
magnitude: quake.properties.mag,
place: quake.properties.place,
time: quake.properties.time,
lat: quake.geometry.coordinates[1],
lng: quake.geometry.coordinates[0],
depth: quake.geometry.coordinates[2],
}));
} catch (error) {
οΏ½OB console.error("Error fetching earthquake data:", error);
}
}οΏ½OB---
setInterval(fetchEarthquakeData, 60000);{
"magnitude": 5.4,
οΏ½OB "place": "Indonesia",
"time": 1715660000000,
"lat": -2.45,
"lng": 118.22,
οΏ½OB "depth": 35
}οΏ½OB | Field | Description | οΏ½OB|------|-------------| | magnitude | Earthquake magnitude | οΏ½OB| place | Earthquake location | οΏ½OB| time | Timestamp | | lat | Latitude | οΏ½OB| lng | Longitude | | depth | Depth in KM |
οΏ½OB
feature/api-systemfeature/usgs-fetch
feature/data-processing
feature/live-syncThis module supplies processed earthquake data to:
- π Globe Visualization Module
- π Dashboard & Analytics Module
Role: Backend/API & Data Processing
Project: Live Earthquake Globe
Technology: React + USGS API + JavaScript