Skill Tracer
Skills › Scientific Agent Skills › database-lookup › usgs.md

usgs.md

268 lines · skills/database-lookup/references/usgs.md at 5f2bc03

Open on GitHub
1# USGS API Reference (Earthquake Hazards + Water Services)
2

USGS API Reference (Earthquake Hazards + Water Services)

Raw lines 1 to 2
3## Part A: Earthquake Hazards Program
4

Part A: Earthquake Hazards Program

Raw lines 3 to 4
5### Water Services migration
6
7USGS announces that WaterServices will be decommissioned in early 2027. The NWIS
8examples below target the legacy service. For new water-data applications, use
9https://api.waterdata.usgs.gov and its documented collections; do not translate
10NWIS query parameters mechanically. Earthquake APIs have a separate lifecycle.
11Source: https://waterservices.usgs.gov/

Water Services migration

USGS announces that WaterServices will be decommissioned in early 2027. The NWIS examples below target the legacy service. For new water-data applications, use https://api.waterdata.usgs.gov and its documented collections; do not translate NWIS query parameters mechanically. Earthquake APIs have a separate lifecycle. Source: https://waterservices.usgs.gov/

Raw lines 5 to 12
13## Base URL
14```
15https://earthquake.usgs.gov/fdsnws/event/1
16```

Base URL

https://earthquake.usgs.gov/fdsnws/event/1
Raw lines 13 to 17
18### Authentication
19**None required.** Fully public, no API key needed.

Authentication

None required. Fully public, no API key needed.

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

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.
Raw lines 21 to 24
25### Key Endpoints
27#### 1. Query Earthquakes
28```
29GET /query
30```
31Returns earthquake events matching search criteria. This is the primary endpoint.
33**Parameters:**
34| Parameter | Type | Required | Default | Description |
35|--------------|--------|----------|------------|-------------|
36| `format` | string | No | `quakeml` | `geojson`, `csv`, `quakeml`, `text`, `kml`. Use `geojson` for JSON. |
37| `starttime` | string | No | (now - 30d)| ISO8601 date, e.g. `2024-01-01`. |
38| `endtime` | string | No | (now) | ISO8601 date. |
39| `minmagnitude`| float | No | - | Minimum magnitude (e.g. `4.5`). |
40| `maxmagnitude`| float | No | - | Maximum magnitude. |
41| `mindepth` | float | No | - | Minimum depth in km. |
42| `maxdepth` | float | No | - | Maximum depth in km. |
43| `latitude` | float | No | - | Center latitude for circle search (-90 to 90). |
44| `longitude` | float | No | - | Center longitude for circle search (-180 to 180). |
45| `maxradiuskm`| float | No | - | Max radius in km (with lat/lon). |
46| `minlatitude`| float | No | - | Bounding box south edge. |
47| `maxlatitude`| float | No | - | Bounding box north edge. |
48| `minlongitude`| float | No | - | Bounding box west edge. |
49| `maxlongitude`| float | No | - | Bounding box east edge. |
50| `limit` | int | No | - | Max events returned (max 20000). |
51| `offset` | int | No | 1 | Pagination offset (1-based). |
52| `orderby` | string | No | `time` | `time`, `time-asc`, `magnitude`, `magnitude-asc`. |
53| `alertlevel` | string | No | - | PAGER alert: `green`, `yellow`, `orange`, `red`. |
54| `eventtype` | string | No | - | e.g. `earthquake`, `quarry blast`. |
56**Example -- significant earthquakes in a region:**
57```
58https://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
59```
61**GeoJSON Response:**
62```json
64 "type": "FeatureCollection",
65 "metadata": {
66 "generated": 1700000000000,
67 "url": "https://earthquake.usgs.gov/fdsnws/event/1/query?...",
68 "title": "USGS Earthquakes",
69 "status": 200,
70 "api": "1.14.1",
71 "count": 42
72 },
73 "features": [
74 {
75 "type": "Feature",
76 "properties": {
77 "mag": 6.2,
78 "place": "15 km NNE of Ridgecrest, CA",
79 "time": 1700000000000,
80 "updated": 1700100000000,
81 "tz": null,
82 "url": "https://earthquake.usgs.gov/earthquakes/eventpage/ci00000001",
83 "detail": "https://earthquake.usgs.gov/fdsnws/event/1/query?eventid=ci00000001&format=geojson",
84 "felt": 1500,
85 "cdi": 7.1,
86 "mmi": 6.5,
87 "alert": "yellow",
88 "status": "reviewed",
89 "tsunami": 0,
90 "sig": 800,
91 "net": "ci",
92 "code": "00000001",
93 "type": "earthquake",
94 "title": "M 6.2 - 15 km NNE of Ridgecrest, CA"
95 },
96 "geometry": {
97 "type": "Point",
98 "coordinates": [-117.5, 35.8, 10.5]
99 },
100 "id": "ci00000001"
101 }
102 ]
104```
105Note: `geometry.coordinates` is `[longitude, latitude, depth_km]`.
107#### 2. Event Detail
108```
109GET /query?eventid={EVENTID}&format=geojson
110```
111Returns detailed info for a single event, including moment tensor, focal mechanism, and nearby cities.
113#### 3. Event Count
114```
115GET /count
116```
117Same parameters as `/query`, returns just the count of matching events. Useful for checking result size before querying.
119**Example:**
120```
121https://earthquake.usgs.gov/fdsnws/event/1/count?starttime=2024-01-01&endtime=2024-12-31&minmagnitude=4.5
122```
124#### 4. Real-Time Feeds (no parameters)
125Pre-built GeoJSON feeds updated every minute/5 min/15 min/hour:
126```
127https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/significant_month.geojson
128https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_week.geojson
129https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_day.geojson
130https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_hour.geojson
131```
132Pattern: `{significance}_{timeperiod}.geojson` where significance is `significant`, `4.5`, `2.5`, `1.0`, `all` and timeperiod is `hour`, `day`, `week`, `month`.
134---

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:

{
  "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.


Raw lines 25 to 135
136## Part B: Water Services

Part B: Water Services

Raw lines 136 to 137
138### Base URL
139```
140https://waterservices.usgs.gov/nwis
141```

Base URL

https://waterservices.usgs.gov/nwis
Raw lines 138 to 142
143### Authentication
144**None required.** Fully public, no API key needed.

Authentication

None required. Fully public, no API key needed.

Raw lines 143 to 145
146### Rate Limits
147- No strict per-user limit, but USGS recommends limiting automated requests. Large queries may time out.

Rate Limits

  • No strict per-user limit, but USGS recommends limiting automated requests. Large queries may time out.
Raw lines 146 to 148
149### Key Endpoints
151#### 1. Instantaneous Values (Real-Time Data)
152```
153GET /iv/
154```
155Returns the most recent sensor readings (typically 15-minute intervals).
157**Parameters:**
158| Parameter | Type | Required | Default | Description |
159|----------------|--------|----------|---------|-------------|
160| `format` | string | No | `wml` | `json`, `xml`, `wml,1.1`, `wml,2.0`, `rdb`. Use `json` for JSON. |
161| `sites` | string | Cond. | - | Comma-separated USGS site numbers (e.g. `01646500`). |
162| `stateCd` | string | Cond. | - | 2-letter state code (e.g. `NY`). |
163| `huc` | string | Cond. | - | Hydrologic Unit Code(s). |
164| `bBox` | string | Cond. | - | Bounding box: `west,south,east,north` (decimal degrees). |
165| `countyCd` | string | Cond. | - | 5-digit FIPS county code(s). |
166| `parameterCd` | string | No | `00060` | Parameter code(s). `00060`=streamflow, `00065`=gage height, `00010`=water temp. |
167| `period` | string | No | - | ISO8601 duration, e.g. `P7D` (past 7 days). |
168| `startDT` | string | No | - | Start datetime (ISO8601). |
169| `endDT` | string | No | - | End datetime (ISO8601). |
170| `siteType` | string | No | - | e.g. `ST` (stream), `GW` (groundwater), `LK` (lake). |
171| `siteStatus` | string | No | `all` | `active`, `inactive`, `all`. |
173At least one location parameter (`sites`, `stateCd`, `huc`, `bBox`, or `countyCd`) is required.
175**Example -- real-time streamflow for a site:**
176```
177https://waterservices.usgs.gov/nwis/iv/?format=json&sites=01646500&parameterCd=00060&period=P1D
178```
180**JSON Response (abbreviated):**
181```json
183 "name": "ns1:timeSeriesResponseType",
184 "declaredType": "org.cuahsi.waterml.TimeSeriesResponseType",
185 "value": {
186 "timeSeries": [
187 {
188 "sourceInfo": {
189 "siteName": "Potomac River near Wash, DC Little Falls Pump Sta",
190 "siteCode": [{"value": "01646500", "agencyCode": "USGS"}],
191 "geoLocation": {
192 "geogLocation": {"latitude": 38.94977778, "longitude": -77.12763889}
193 }
194 },
195 "variable": {
196 "variableCode": [{"value": "00060"}],
197 "variableName": "Streamflow, ft³/s",
198 "unit": {"unitCode": "ft3/s"}
199 },
200 "values": [
201 {
202 "value": [
203 {"value": "5280", "dateTime": "2024-01-15T00:00:00.000-05:00"},
204 {"value": "5310", "dateTime": "2024-01-15T00:15:00.000-05:00"}
205 ]
206 }
207 ]
208 }
209 ]
210 }
212```
214#### 2. Daily Values (Historical Aggregates)
215```
216GET /dv/
217```
218Returns daily statistical values (mean, max, min). Same location parameters as `/iv/`.
220**Additional Parameters:**
221| Parameter | Type | Description |
222|-----------|--------|-------------|
223| `statCd` | string | Statistic code: `00001`=max, `00002`=min, `00003`=mean, `00006`=sum. Default `00003`. |
225**Example -- daily mean streamflow, 1 year:**
226```
227https://waterservices.usgs.gov/nwis/dv/?format=json&sites=01646500&parameterCd=00060&statCd=00003&startDT=2023-01-01&endDT=2023-12-31
228```
230#### 3. Site Information
231```
232GET /site/
233```
234Returns metadata about monitoring sites. Same location parameters apply.
236**Example -- active stream sites in Virginia:**
237```
238https://waterservices.usgs.gov/nwis/site/?format=rdb&stateCd=VA&siteType=ST&siteStatus=active&hasDataTypeCd=iv
239```
241#### 4. Statistics (Pre-computed)
242```
243GET /stat/
244```
245Returns pre-computed statistics (percentiles, mean, median) for daily values, useful for comparing current conditions to historical norms.
247**Example:**
248```
249https://waterservices.usgs.gov/nwis/stat/?format=rdb&sites=01646500&parameterCd=00060&statReportType=daily&statTypeCd=mean,p05,p25,p50,p75,p95
250```

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):

{
  "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
Raw lines 149 to 251
252### Common Parameter Codes
253| Code | Description |
254|---------|-------------|
255| `00060` | Discharge/streamflow (ft3/s) |
256| `00065` | Gage height (ft) |
257| `00010` | Water temperature (C) |
258| `00045` | Precipitation (in) |
259| `00400` | pH |
260| `00300` | Dissolved oxygen (mg/L) |
261| `00095` | Specific conductance (uS/cm) |
262| `72019` | Groundwater level depth below land surface (ft) |

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)
Raw lines 252 to 263
264## Notes
265- Earthquake API returns coordinates as `[lon, lat, depth]` (note: longitude first).
266- Water Services JSON wraps data in a verbose WaterML-like structure. The `rdb` (tab-delimited) format is simpler for tabular data.
267- USGS site numbers are typically 8 digits for surface water, 15 for groundwater.
268- Both APIs are free, public, and require no authentication.

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.
Raw lines 264 to 268