Back to Claude Scientific Skills

USGS API Reference (Earthquake Hazards + Water Services)

scientific-skills/database-lookup/references/usgs.md

2.38.09.5 KB
Original Source

USGS API Reference (Earthquake Hazards + Water Services)

Part A: Earthquake Hazards Program

Base URL

https://earthquake.usgs.gov/fdsnws/event/1

Authentication

None required. Fully public, no API key needed.

Rate Limits

  • No documented per-user rate limit, but USGS asks users to limit automated queries to avoid overloading the service.
  • Requests returning very large result sets (>20,000 events) will be rejected. Use pagination or narrow your query.

Key Endpoints

1. Query Earthquakes

GET /query

Returns earthquake events matching search criteria. This is the primary endpoint.

Parameters:

ParameterTypeRequiredDefaultDescription
formatstringNoquakemlgeojson, csv, quakeml, text, kml. Use geojson for JSON.
starttimestringNo(now - 30d)ISO8601 date, e.g. 2024-01-01.
endtimestringNo(now)ISO8601 date.
minmagnitudefloatNo-Minimum magnitude (e.g. 4.5).
maxmagnitudefloatNo-Maximum magnitude.
mindepthfloatNo-Minimum depth in km.
maxdepthfloatNo-Maximum depth in km.
latitudefloatNo-Center latitude for circle search (-90 to 90).
longitudefloatNo-Center longitude for circle search (-180 to 180).
maxradiuskmfloatNo-Max radius in km (with lat/lon).
minlatitudefloatNo-Bounding box south edge.
maxlatitudefloatNo-Bounding box north edge.
minlongitudefloatNo-Bounding box west edge.
maxlongitudefloatNo-Bounding box east edge.
limitintNo-Max events returned (max 20000).
offsetintNo1Pagination offset (1-based).
orderbystringNotimetime, time-asc, magnitude, magnitude-asc.
alertlevelstringNo-PAGER alert: green, yellow, orange, red.
eventtypestringNo-e.g. earthquake, quarry blast.

Example -- significant earthquakes in a region:

https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&starttime=2024-01-01&endtime=2024-12-31&minmagnitude=5.0&minlatitude=30&maxlatitude=45&minlongitude=-125&maxlongitude=-110&orderby=magnitude

GeoJSON Response:

json
{
  "type": "FeatureCollection",
  "metadata": {
    "generated": 1700000000000,
    "url": "https://earthquake.usgs.gov/fdsnws/event/1/query?...",
    "title": "USGS Earthquakes",
    "status": 200,
    "api": "1.14.1",
    "count": 42
  },
  "features": [
    {
      "type": "Feature",
      "properties": {
        "mag": 6.2,
        "place": "15 km NNE of Ridgecrest, CA",
        "time": 1700000000000,
        "updated": 1700100000000,
        "tz": null,
        "url": "https://earthquake.usgs.gov/earthquakes/eventpage/ci00000001",
        "detail": "https://earthquake.usgs.gov/fdsnws/event/1/query?eventid=ci00000001&format=geojson",
        "felt": 1500,
        "cdi": 7.1,
        "mmi": 6.5,
        "alert": "yellow",
        "status": "reviewed",
        "tsunami": 0,
        "sig": 800,
        "net": "ci",
        "code": "00000001",
        "type": "earthquake",
        "title": "M 6.2 - 15 km NNE of Ridgecrest, CA"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [-117.5, 35.8, 10.5]
      },
      "id": "ci00000001"
    }
  ]
}

Note: geometry.coordinates is [longitude, latitude, depth_km].

2. Event Detail

GET /query?eventid={EVENTID}&format=geojson

Returns detailed info for a single event, including moment tensor, focal mechanism, and nearby cities.

3. Event Count

GET /count

Same parameters as /query, returns just the count of matching events. Useful for checking result size before querying.

Example:

https://earthquake.usgs.gov/fdsnws/event/1/count?starttime=2024-01-01&endtime=2024-12-31&minmagnitude=4.5

4. Real-Time Feeds (no parameters)

Pre-built GeoJSON feeds updated every minute/5 min/15 min/hour:

https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/significant_month.geojson
https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_week.geojson
https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_day.geojson
https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_hour.geojson

Pattern: {significance}_{timeperiod}.geojson where significance is significant, 4.5, 2.5, 1.0, all and timeperiod is hour, day, week, month.


Part B: Water Services

Base URL

https://waterservices.usgs.gov/nwis

Authentication

None required. Fully public, no API key needed.

Rate Limits

  • No strict per-user limit, but USGS recommends limiting automated requests. Large queries may time out.

Key Endpoints

1. Instantaneous Values (Real-Time Data)

GET /iv/

Returns the most recent sensor readings (typically 15-minute intervals).

Parameters:

ParameterTypeRequiredDefaultDescription
formatstringNowmljson, xml, wml,1.1, wml,2.0, rdb. Use json for JSON.
sitesstringCond.-Comma-separated USGS site numbers (e.g. 01646500).
stateCdstringCond.-2-letter state code (e.g. NY).
hucstringCond.-Hydrologic Unit Code(s).
bBoxstringCond.-Bounding box: west,south,east,north (decimal degrees).
countyCdstringCond.-5-digit FIPS county code(s).
parameterCdstringNo00060Parameter code(s). 00060=streamflow, 00065=gage height, 00010=water temp.
periodstringNo-ISO8601 duration, e.g. P7D (past 7 days).
startDTstringNo-Start datetime (ISO8601).
endDTstringNo-End datetime (ISO8601).
siteTypestringNo-e.g. ST (stream), GW (groundwater), LK (lake).
siteStatusstringNoallactive, inactive, all.

At least one location parameter (sites, stateCd, huc, bBox, or countyCd) is required.

Example -- real-time streamflow for a site:

https://waterservices.usgs.gov/nwis/iv/?format=json&sites=01646500&parameterCd=00060&period=P1D

JSON Response (abbreviated):

json
{
  "name": "ns1:timeSeriesResponseType",
  "declaredType": "org.cuahsi.waterml.TimeSeriesResponseType",
  "value": {
    "timeSeries": [
      {
        "sourceInfo": {
          "siteName": "Potomac River near Wash, DC Little Falls Pump Sta",
          "siteCode": [{"value": "01646500", "agencyCode": "USGS"}],
          "geoLocation": {
            "geogLocation": {"latitude": 38.94977778, "longitude": -77.12763889}
          }
        },
        "variable": {
          "variableCode": [{"value": "00060"}],
          "variableName": "Streamflow, ft³/s",
          "unit": {"unitCode": "ft3/s"}
        },
        "values": [
          {
            "value": [
              {"value": "5280", "dateTime": "2024-01-15T00:00:00.000-05:00"},
              {"value": "5310", "dateTime": "2024-01-15T00:15:00.000-05:00"}
            ]
          }
        ]
      }
    ]
  }
}

2. Daily Values (Historical Aggregates)

GET /dv/

Returns daily statistical values (mean, max, min). Same location parameters as /iv/.

Additional Parameters:

ParameterTypeDescription
statCdstringStatistic code: 00001=max, 00002=min, 00003=mean, 00006=sum. Default 00003.

Example -- daily mean streamflow, 1 year:

https://waterservices.usgs.gov/nwis/dv/?format=json&sites=01646500&parameterCd=00060&statCd=00003&startDT=2023-01-01&endDT=2023-12-31

3. Site Information

GET /site/

Returns metadata about monitoring sites. Same location parameters apply.

Example -- active stream sites in Virginia:

https://waterservices.usgs.gov/nwis/site/?format=rdb&stateCd=VA&siteType=ST&siteStatus=active&hasDataTypeCd=iv

4. Statistics (Pre-computed)

GET /stat/

Returns pre-computed statistics (percentiles, mean, median) for daily values, useful for comparing current conditions to historical norms.

Example:

https://waterservices.usgs.gov/nwis/stat/?format=rdb&sites=01646500&parameterCd=00060&statReportType=daily&statTypeCd=mean,p05,p25,p50,p75,p95

Common Parameter Codes

CodeDescription
00060Discharge/streamflow (ft3/s)
00065Gage height (ft)
00010Water temperature (C)
00045Precipitation (in)
00400pH
00300Dissolved oxygen (mg/L)
00095Specific conductance (uS/cm)
72019Groundwater level depth below land surface (ft)

Notes

  • Earthquake API returns coordinates as [lon, lat, depth] (note: longitude first).
  • Water Services JSON wraps data in a verbose WaterML-like structure. The rdb (tab-delimited) format is simpler for tabular data.
  • USGS site numbers are typically 8 digits for surface water, 15 for groundwater.
  • Both APIs are free, public, and require no authentication.