# USGS Streamflow & Water Levels Scraper API (`pink_comic/usgs-streamflow-water-levels`) Actor

Query USGS NWIS Instantaneous Values for bounded streamflow, discharge, gage-height, and water-monitoring observations by site or geography. Returns one source-linked row per site/parameter series with qualifiers, units, methods, and optional bounded history.

- **URL**: https://apify.com/pink\_comic/usgs-streamflow-water-levels.md
- **Developed by:** [Ava Torres](https://apify.com/pink_comic) (community)
- **Categories:** Automation, Developer tools, AI
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 usgs streamflow & water levels scraper api evidence items

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## USGS Streamflow & Water Levels Scraper API

Query the official **USGS National Water Information System (NWIS) Instantaneous Values JSON service** and receive one dataset item per site/parameter time series. Use it for bounded streamflow, discharge, gage-height, watershed monitoring, research, dashboards, and source-backed data pipelines.

### Deterministic first run

```json
{
  "sites": ["01646500"],
  "parameterCd": ["00060", "00065"],
  "siteStatus": "all",
  "includeHistory": false,
  "observationsPerSeries": 24,
  "maxResults": 2
}
```

This requests the Potomac River near Washington (`01646500`) and normally returns two rows: discharge (`00060`) and gage height (`00065`). It returns at most **2 paid items**, so the maximum first-run charge is **$0.0041**: $0.0001 start + 2 × $0.002/item. Missing/sentinel readings are never converted to zero.

### Inputs

Choose exactly one geography selector:

- `sites`: up to 100 USGS site numbers
- `stateCd`: state/territory abbreviation
- `countyCd`: five-digit county FIPS
- `huc`: hydrologic unit code
- `bbox`: `west,south,east,north`

Additional controls:

- `parameterCd`: up to 20 USGS parameter codes
- `period`, or paired `startDT` + `endDT` (mutually exclusive)
- `siteStatus`: `all`, `active`, or `inactive`
- `qualifiers`: optional exact codes such as `P` or `A`
- `includeHistory` and `observationsPerSeries` (maximum 1,000 nested observations)
- `maxResults`: total series rows across the entire request (maximum 500)

The actor rejects missing or conflicting geography selectors before contacting USGS. It never issues an unbounded national request.

### Parameter guidance

- `00060`: discharge / streamflow, commonly cubic feet per second
- `00065`: gage height, commonly feet

USGS determines the available parameters, statistic, units, methods, and observations for each site. Do not assume every site offers both codes or the same unit. Other NWIS parameter codes may be supplied explicitly.

### Output

Each `FOUND` row includes site ID/name, coordinates, state/county/HUC, site type, time zones, parameter code/name/description, unit, statistic, latest value/time, source qualifier codes and descriptions, method, bounded observations, exact source request URL, retrieval time, and coverage disclosure. Explicit `NO_MATCH`, `INVALID_INPUT`, and `SOURCE_UNAVAILABLE` records prevent silent empty runs.

### Important evidence boundaries

USGS instantaneous values can be **provisional, revised, delayed, equipment-affected, missing, or unavailable**. Qualifiers such as provisional (`P`) and approved (`A`) are preserved exactly; they are not rewritten into a quality judgment. A missing value or USGS `noDataValue` is omitted, never represented as zero.

These observations are **not flood forecasts, regulatory determinations, navigational guidance, or emergency instructions**. Do not use this actor as a warning system or safety-of-life source. Follow National Weather Service warnings and official local emergency authorities. A bounded no-match does not prove a site, parameter, or observation does not exist.

### Source and reliability

Source: `https://waterservices.usgs.gov/nwis/iv/` (USGS NWIS Instantaneous Values, WaterML JSON). No API credential is required. Requests use a descriptive User-Agent, bounded timeout and response size, and retries for transport/body-read failures, malformed transient responses, HTTP 408/429/5xx, and `Retry-After`.

# Actor input Schema

## `sites` (type: `array`):

USGS site numbers (maximum 100). Mutually exclusive with state, county, HUC, and bbox.

## `stateCd` (type: `string`):

Two-letter state/territory code. Clear sites before using.

## `countyCd` (type: `string`):

Five-digit county FIPS. Clear sites before using.

## `huc` (type: `string`):

HUC code. Clear sites before using.

## `bbox` (type: `string`):

west,south,east,north. Clear sites before using. Requests remain result- and response-bounded.

## `parameterCd` (type: `array`):

USGS parameter codes. 00060 = discharge/streamflow; 00065 = gage height. Maximum 20.

## `period` (type: `string`):

ISO-8601 duration such as P1D or PT6H. Mutually exclusive with startDT/endDT.

## `startDT` (type: `string`):

ISO date/time; must be paired with endDT and cannot be combined with period.

## `endDT` (type: `string`):

ISO date/time paired with startDT.

## `siteStatus` (type: `string`):

Optional site status filter or result-control setting. See the README for source semantics and examples.

## `qualifiers` (type: `array`):

Optional exact qualifier codes such as P (provisional) or A (approved). Qualifiers are preserved in output.

## `includeHistory` (type: `boolean`):

When false, each paid series row contains only its latest valid observation. When true, includes a bounded tail.

## `observationsPerSeries` (type: `integer`):

Maximum observations nested in each paid time-series row when history is enabled.

## `maxResults` (type: `integer`):

Total paid rows across all sites/parameters. Default 2 costs at most $0.0041 including the $0.0001 start fee.

## Actor input object example

```json
{
  "sites": [
    "01646500"
  ],
  "stateCd": "",
  "countyCd": "",
  "huc": "",
  "bbox": "",
  "parameterCd": [
    "00060",
    "00065"
  ],
  "period": "",
  "startDT": "",
  "endDT": "",
  "siteStatus": "all",
  "qualifiers": [],
  "includeHistory": false,
  "observationsPerSeries": 24,
  "maxResults": 2
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "sites": [
        "01646500"
    ],
    "parameterCd": [
        "00060",
        "00065"
    ],
    "maxResults": 2
};

// Run the Actor and wait for it to finish
const run = await client.actor("pink_comic/usgs-streamflow-water-levels").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "sites": ["01646500"],
    "parameterCd": [
        "00060",
        "00065",
    ],
    "maxResults": 2,
}

# Run the Actor and wait for it to finish
run = client.actor("pink_comic/usgs-streamflow-water-levels").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "sites": [
    "01646500"
  ],
  "parameterCd": [
    "00060",
    "00065"
  ],
  "maxResults": 2
}' |
apify call pink_comic/usgs-streamflow-water-levels --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=pink_comic/usgs-streamflow-water-levels",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/9Dh6NWBEBpdP1ASL9/builds/NbHL48lTsPV8LSWYQ/openapi.json
