# USGS Streamflow Latest — Discharge by Site, State or Area (`zinin/usgs-streamflow-latest`) Actor

Get the latest discharge value, time, unit, qualifiers and location metadata from the official USGS Water Data API. Select monitoring sites, a state, or a bounding box. No key required for the prefill.

- **URL**: https://apify.com/zinin/usgs-streamflow-latest.md
- **Developed by:** [Tim Zinin](https://apify.com/zinin) (community)
- **Categories:** Other
- **Features:** Limited permissions
- **Stats:** 4 total users, 3 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## USGS Streamflow Latest

Get the latest discharge measurement for USGS monitoring locations from the official **USGS Water Data OGC API**. Select exact sites, a U.S. state, or a longitude/latitude bounding box and receive analysis-ready rows with observation time, discharge, unit, qualifiers, approval status, coordinates, attribution, and provenance.

No API key is needed for the small default run. This Actor uses the JSON API only—no HTML scraping and no proxies.

### Use cases

- **Water utilities:** track nearby river discharge for intake and operational context.
- **Hydrology analysts:** assemble a current cross-site snapshot without writing OGC pagination and validation code.
- **Insurance and catastrophe teams:** enrich flood-exposure workflows with recent gauge observations.
- **Data teams:** schedule state or portfolio-site snapshots into datasets, webhooks, or downstream ETL.

### Input

Choose one selector. `siteIds` takes priority, then `stateCode`, then `bbox`. With no valid selector, the Actor uses California (`06`) so a keyless run still returns useful data.

```json
{
  "siteIds": ["01646500", "USGS-09421500"],
  "maxItems": 20
}
```

State example:

```json
{
  "siteIds": [],
  "stateCode": "06",
  "maxItems": 10
}
```

Bounding-box example (remove `stateCode`, or set it to an empty string, so the box is selected):

```json
{
  "siteIds": [],
  "stateCode": "",
  "bbox": [-123.0, 37.0, -121.0, 39.0],
  "maxItems": 50
}
```

| Field | Description | Limit |
|---|---|---:|
| `siteIds` | USGS site numbers or IDs | 50 |
| `stateCode` | Two-digit ANSI/FIPS state code | one |
| `bbox` | `[west, south, east, north]` | exactly 4 numbers |
| `maxItems` | Maximum successful observation rows | 500 |
| `apiKey` | Optional USGS Water Data API key | one secret |

### Output

```json
{
  "found": true,
  "monitoringLocationId": "USGS-11525530",
  "siteNumber": "11525530",
  "siteName": "KLAMATH R BL IRON GATE DAM CA",
  "stateCode": "06",
  "stateName": "California",
  "time": "2026-11-10T19:30:00+00:00",
  "value": 1040,
  "valueText": "1040",
  "unit": "ft^3/s",
  "qualifiers": [],
  "approvalStatus": "Provisional",
  "latitude": 41.9301,
  "longitude": -122.4347,
  "parameterCode": "00060",
  "statisticId": "00011",
  "lastModified": "2026-11-10T19:42:20+00:00",
  "source": "U.S. Geological Survey (USGS) Water Data",
  "sourceUrl": "https://api.waterdata.usgs.gov/ogcapi/v0/collections/latest-continuous/items?...",
  "retrievedAt": "2026-11-10T19:50:00.000Z"
}
```

`value` is numeric for analysis and `valueText` preserves the API's precision-bearing string. Every successful row is one latest parameter `00060` (discharge) observation per monitoring location. Rows with `found: false` explain source errors, empty selections, or a budget stop and are free.

### Pricing

**$0.01 per latest streamflow reading (`result-found`) on the Free plan, with automatic discounts on paid Apify plans: Bronze −5%, Silver −10%, Gold −15%, Platinum −18%, Diamond −20%. A small Actor start event ($0.002) applies per run**

Successful observation rows use the `result-found` pay-per-event event. Delivery and billing happen atomically. Error and empty-result rows do not use that event and are free.

### Limitations

- Values can be **provisional** and subject to revision; inspect `approvalStatus` and `qualifiers` before operational decisions.
- “Latest” is what the USGS collection currently reports. Observation age varies by site, equipment, telemetry, and processing.
- A site can be missing, offline, not measure discharge, or return no current observation.
- The Actor returns at most one observation per monitoring location and 500 rows per run.
- Requests are sequential with timeouts and bounded retries. HTTP 429 and service failures may produce a free explanatory row rather than results.
- This is not a flood forecast, warning service, or substitute for professional hydrologic judgment. For official warnings, consult the responsible public authority.

### Source, terms, and attribution

Data comes from the [USGS Water Data OGC API](https://api.waterdata.usgs.gov/ogcapi/v0/). Credit: **U.S. Geological Survey**. USGS-authored data and information are generally in the U.S. public domain, while some third-party materials can have separate rights. Review the [USGS copyright and credits policy](https://www.usgs.gov/information-policies-and-instructions/copyrights-and-credits), [crediting guidance](https://www.usgs.gov/information-policies-and-instructions/acknowledging-or-crediting-usgs), API documentation, provisional-data statement, and current usage/rate-limit requirements before reuse.

This Actor is an independent tool and is not endorsed by USGS. It does not use the trademarked USGS identifier as an icon.

### Related Actors

- [usgs-groundwater-daily](https://apify.com/zinin/usgs-groundwater-daily)
- [us-nws-alert-feed](https://apify.com/zinin/us-nws-alert-feed)
- [us-nws-point-forecast](https://apify.com/zinin/us-nws-point-forecast)

# Actor input Schema

## `siteIds` (type: `array`):

Up to 50 USGS site numbers (for example 01646500) or monitoring-location IDs (USGS-01646500). If supplied, these take priority over state and bounding box.

## `stateCode` (type: `string`):

Two-digit state ANSI/FIPS code, such as 06 for California or 48 for Texas. Used when site IDs are empty.

## `bbox` (type: `array`):

Optional \[west, south, east, north] longitude/latitude box. Used only when site IDs and state code are empty.

## `maxItems` (type: `integer`):

Maximum number of paid observation rows returned across the entire run.

## `apiKey` (type: `string`):

Optional key from api.waterdata.usgs.gov for your USGS quota. The small prefill works without one.

## Actor input object example

```json
{
  "siteIds": [],
  "stateCode": "06",
  "maxItems": 10
}
```

# Actor output Schema

## `results` (type: `string`):

API URL for the default dataset items produced by this run.

# 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 = {
    "siteIds": [],
    "stateCode": "06",
    "maxItems": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("zinin/usgs-streamflow-latest").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 = {
    "siteIds": [],
    "stateCode": "06",
    "maxItems": 10,
}

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

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

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

```

## CLI example

```bash
echo '{
  "siteIds": [],
  "stateCode": "06",
  "maxItems": 10
}' |
apify call zinin/usgs-streamflow-latest --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,zinin/usgs-streamflow-latest"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/CFWdDAqxiS44JDndB/builds/e5xX3LTlX4LxvmBT5/openapi.json
