🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@pondlog/source-usgs

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pondlog/source-usgs

USGS Water Services (NWIS) API client: typed, Zod-validated, polite-rate-limited. Real-time and daily streamflow, gage height, and site metadata. Returns Result<T> instead of throwing.

latest
Source
npmnpm
Version
0.1.3
Version published
Weekly downloads
11
-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

@pondlog/source-usgs

USGS Water Services (NWIS) API client. Typed, Zod-validated, politely rate-limited. Returns Result<T> instead of throwing.

Base URL: https://waterservices.usgs.gov/nwis/. No API key required.

Part of pondlog.

Install

npm install @pondlog/source-usgs

Functions

FunctionDescription
getInstantaneousValues({ sites, parameterCodes?, period? })Real-time gauge readings (typically 15-min cadence). Defaults to discharge + gage height for the last 2 hours.
getDailyValues({ sites, parameterCodes?, period?, startDt?, endDt?, statisticCodes? })Daily statistics. Use period for relative-to-now or startDt/endDt for historic. Defaults to discharge mean for the last 7 days.
getSiteInfo({ siteNumber })Site metadata (name, coordinates, HUC, state, altitude).
searchSites({ bbox?, stateCode?, hucCode?, siteType?, hasDataTypeCode? })Find sites by bounding box, US state, or hydrologic unit. Default siteType: "ST" (streams) and hasDataTypeCode: "iv" (live data).

All functions return Result<T> from @pondlog/core.

Helpers

  • bboxAround(coords, radiusKm): square bbox tuple around a point, ready for searchSites({ bbox }).
  • PARAMETER_CODES: common USGS parameter constants (DISCHARGE, GAGE_HEIGHT, WATER_TEMP_C).

Parameter codes (the ones you almost always want)

CodeMeaningUnit
00060Discharge / streamflowft³/s
00065Gage heightft
00010Water temperature°C

Notes

  • /iv/ (instantaneous) does not accept historic startDT/endDT. It returns HTTP 301. Use period (relative-to-now) for /iv/, or getDailyValues for historic data.
  • Unknown sites return HTTP 200 with timeSeries: [] rather than an error. The client surfaces this as ok: true with an empty array.
  • USGS encodes "no value" as -999999.0. The client translates this to undefined so consumers never see the sentinel.
  • /site/ only returns RDB (tab-delimited); JSON is unsupported. The client parses RDB internally and returns normalized objects.
  • Rate limiter: 1 req/sec sustained, bursts up to 5. USGS doesn't publish a documented limit; we're polite by default.

License

MIT.

Keywords

pondlog

FAQs

Package last updated on 12 May 2026

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