npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@streamster/usgs

v0.0.1-alpha.3

Published

> :warning: Streamster is still very much a work in progress. Features and implementations are likely to change.

Downloads

7

Readme

@streamster/usgs

:warning: Streamster is still very much a work in progress. Features and implementations are likely to change.

Firstly, a big thanks to the folks over at USGS for all of their hardwork in developing their Water Services. Much much appreciated!

@streamster/usgs is a JavaScript library designed to make working with the USGS Water Services significantly easier. Currently, the package provides a way to easily query the Daily and Instantaneous services. The data can be returned from the service as is or re-structured to a more friendly time-series format that is easy to display in a table or chart.

Getting Started

To install the package

# yarn
yarn add @streamster/usgs

# npm
npm install @streamster/usgs

Usage

@streamster/usgs currently supports the USGS Daily Values and USGS Instantaneous Values service. Like the name implies, the daily service allows you to retrieve aggregated daily values for a variety of parameters for any USGS stream gage. The instantaneous service allows you to retrieve data collected at 15 minute intervals for a variety of parameters for any USGS stream gage. If this sounds like a whole lot of mumbo jumbo to you, I recommend taking a gander at the USGS Water Services home page.

Using the Daily Service

You can use the daily service to return aggregated data for any USGS stream gage. The getDailyData() accepts every valid query argument that the USGS service supports. The argument names are identical to those in the USGS service so if they use the key stateCd to represent the state to filter on, stateCd will be the filter key in streamster as well. For a full list of supported arguments, please reference the USGS Documentation.

You can choose to return the data in its raw format or as a tidy time series suitable for plotting in a chart or tabular format. To return the raw data, pass raw as the argument to the format property. To return the data in a time series format, pass time-series as the argument to the format property.

You can also use the USGS Instantaneous Value Service Test Tool to explore different queries. This can be found at https://waterservices.usgs.gov/rest/DV-Test-Tool.html.

import usgs from '@streamster/usgs`;

// initialize an instance of the daily service
const daily = usgs.daily()

// request the last five days of daily data for all usgs sites in Colorado
// returns data in a tidy time series format
const data = daily
  .getDailyData({
    format: 'time-series',
    queryParameters: {
      stateCd: 'co', // usgs site code
      siteStatus: 'active',
      parameterCd: '00060', // usgs flow parameter code
      startDT: '2020-10-01',
      endDT: '2020-10-05',
    },
  })
  .then(data => {
    // do something with the data!
  })
  .catch(err => {
    console.error(err);
  });

Using the Instantaneous Service

You can use the instantaneous service to return 15 minute data for any USGS stream gage. The getInstantaneousData() accepts every valid query argument that the USGS service supports. The argument names are identical to those in the USGS service so if they use the key stateCd to represent the state to filter on, stateCd will be the filter key in streamster as well. For a full list of supported arguments, please reference the USGS Documentation.

You can choose to return the data in its raw format or as a tidy time series suitable for plotting in a chart or tabular format. To return the raw data, pass raw as the argument to the format property. To return the data in a time series format, pass time-series as the argument to the format property.

You can also use the USGS Instantaneous Value Service Test Tool to explore different queries. This can be found at https://waterservices.usgs.gov/rest/IV-Test-Tool.html.

import usgs from '@streamster/usgs`;

// initialize an instance of the daily service
const daily = usgs.daily()

// request the 15 minute data for the last two days of daily data for all usgs sites in Colorado
// returns data in a tidy time series format
const data = daily
  .getInstantaneousData({
    format: 'time-series',
    queryParameters: {
      stateCd: 'co', // usgs site code
      siteStatus: 'active',
      parameterCd: '00060', // usgs flow parameter code
      startDT: '2020-10-01',
      endDT: '2020-10-02',
    },
  })
  .then(data => {
    // do something with the data!
  })
  .catch(err => {
    console.error(err);
  });