Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

usage-tracker-public

Package Overview
Dependencies
Maintainers
0
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

usage-tracker-public

weather and gis aggregation library with a simple API

  • 3.81.0
  • unpublished
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-80%
Maintainers
0
Weekly downloads
 
Created
Source

Weather and Earthquake SDK -- Premium Package

Overview

The Earthquake Data Library is a Node.js SDK that provides an easy-to-use interface for fetching and analyzing earthquake data from the USGS (United States Geological Survey) Earthquake API. This library allows users to retrieve recent earthquake information, query earthquakes by geographic radius, and perform basic analysis on seismic events.

Features

  • Fetch recent earthquakes with customizable parameters
  • Query earthquakes within a specified radius of a geographic point
  • Retrieve the most significant recent earthquakes
  • Calculate distances between geographic coordinates
  • Interpret earthquake magnitudes with descriptive categories

Installation

Please make sure you have a valid license prior to installing this library. To install the Earthquake Data Library, run the following command in your project directory:

npm install earthquake-data-library

Note: Make sure you have Node.js and npm installed on your system.

Usage

Here's a basic example of how to use the Earthquake Data Library:

const EarthquakeLibrary = require("earthquake-data-library");

const earthquakeLib = new EarthquakeLibrary();

async function main() {
  try {
    // Get recent earthquakes
    const recentQuakes = await earthquakeLib.getEarthquakes({
      startTime: "2023-06-01",
      minMagnitude: 4.5,
      limit: 10,
    });
    console.log("Recent significant earthquakes:", recentQuakes);

    // Get earthquakes within 1000km of Tokyo
    const tokyoQuakes = await earthquakeLib.getEarthquakesByRadius(
      35.6762,
      139.6503,
      1000,
      5
    );
    console.log("Recent earthquakes near Tokyo:", tokyoQuakes);

    // Get magnitude description
    console.log(
      "A magnitude 6.5 earthquake is considered:",
      earthquakeLib.getMagnitudeDescription(6.5)
    );
  } catch (error) {
    console.error("Error:", error.message);
  }
}

main();

API Reference

getEarthquakes(options)

Fetches earthquake data based on specified parameters.

  • options (Object):
    • startTime (String): Start date for the query (default: '2023-01-01')
    • endTime (String): End date for the query (default: current date)
    • minMagnitude (Number): Minimum magnitude (default: 0)
    • maxMagnitude (Number): Maximum magnitude (default: 10)
    • limit (Number): Maximum number of results to return (default: 100)

Returns a Promise that resolves to an array of earthquake objects.

getEarthquakesByRadius(latitude, longitude, maxRadiusKm, minMagnitude)

Fetches earthquakes within a specified radius of a geographic point.

  • latitude (Number): Latitude of the center point
  • longitude (Number): Longitude of the center point
  • maxRadiusKm (Number): Maximum radius in kilometers
  • minMagnitude (Number): Minimum magnitude (default: 0)

Returns a Promise that resolves to an array of earthquake objects.

getMostSignificantEarthquakes(limit)

Retrieves the most significant recent earthquakes.

  • limit (Number): Maximum number of results to return (default: 10)

Returns a Promise that resolves to an array of earthquake objects.

calculateDistance(lat1, lon1, lat2, lon2)

Calculates the distance between two geographic points.

  • lat1, lon1: Latitude and longitude of the first point
  • lat2, lon2: Latitude and longitude of the second point

Returns the distance in kilometers.

getMagnitudeDescription(magnitude)

Provides a descriptive category for an earthquake magnitude.

  • magnitude (Number): The earthquake magnitude

Returns a string describing the magnitude category (e.g., "Minor", "Moderate", "Major").

Error Handling

The library uses a centralized error handling mechanism. All methods that interact with the USGS API will throw an error if the request fails or if there's an issue with the data. It's recommended to use try-catch blocks when calling these methods.

Contributing

Contributions to the Earthquake Data Library are welcome! Please feel free to submit a Pull Request. Author: Incisiv3

License

This project is licensed under the MIT License! - see the LICENSE file for details.

FAQs

Package last updated on 01 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc