|
| 1 | +TimeSeries API Discussion Table (with Examples & Issues) |
| 2 | +========================================================= |
| 3 | + |
| 4 | +.. list-table:: |
| 5 | + :header-rows: 1 |
| 6 | + :widths: 20 25 25 30 |
| 7 | + |
| 8 | + * - Endpoint (Swagger Link) |
| 9 | + - Highlights from Discussion |
| 10 | + - Tests / Recommendations & Issues |
| 11 | + - Example Calls |
| 12 | + * - `GET /timeseries <https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html#/TimeSeries/getTimeseries>`__ |
| 13 | + - - Core endpoint, most used in CDA. |
| 14 | + - **Office is required** even though docs once showed optional. |
| 15 | + - Defaults: 24h window, 500 records per page. |
| 16 | + - Supports ``unit-system`` (EN/SI), ``datum``, ``version-date``. |
| 17 | + - Supports ``include-entry-date``. |
| 18 | + - ``trim=true`` removes leading/trailing nulls. |
| 19 | + - ``regular`` vs ``pseudo-irregular`` series behavior explained. |
| 20 | + - - Always specify ``office``. |
| 21 | + - Use ``America/Chicago`` instead of ``US/Central``. |
| 22 | + - **Time Zone Issue**: Defaults to UTC if not specified. |
| 23 | + - **Trim + Page-size Edge Case**: Some values disappeared unless page-size adjusted. |
| 24 | + - Raise ``page-size`` or parallelize by date slices for large pulls. |
| 25 | + - For CSV downloads in browsers: prefer ``format=csv`` query (**Format vs Accept Header Conflict**). |
| 26 | + - **curl**:: |
| 27 | + |
| 28 | + curl "https://cwms-data.usace.army.mil/cwms-data/timeseries?name=KEYS.ELEV.Inst.1Hour.0.CCP-RAW&office=SWT&begin=2025-08-01T00:00:00Z&end=2025-08-07T00:00:00Z&unit-system=EN&timezone=America/Chicago&page-size=2000&format=csv" -o data.csv |
| 29 | + |
| 30 | + **Python (requests)**:: |
| 31 | + |
| 32 | + import requests |
| 33 | + r = requests.get("https://cwms-data.usace.army.mil/cwms-data/timeseries", |
| 34 | + params={ |
| 35 | + "name": "KEYS.ELEV.Inst.1Hour.0.CCP-RAW", |
| 36 | + "office": "SWT", |
| 37 | + "begin": "2025-08-01T00:00:00Z", |
| 38 | + "end": "2025-08-07T00:00:00Z", |
| 39 | + "unit-system": "EN", |
| 40 | + "timezone": "America/Chicago", |
| 41 | + "page-size": 2000 |
| 42 | + }, |
| 43 | + headers={"Accept": "application/json"}) |
| 44 | + print(r.json()) |
| 45 | + * - `GET /timeseries/recent <https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html#/TimeSeries/getRecentTimeseries>`__ |
| 46 | + - - Used for dashboards, gets most recent values. |
| 47 | + - Accepts ``ts-ids`` (comma separated), ``group-id``, or ``category-id``. |
| 48 | + - Performance fixes (latest ~300ms). |
| 49 | + - - Use comma-separated ``ts-ids``. |
| 50 | + - **Group/Category Issue**: returned empty in tests → likely bug. |
| 51 | + - Watch URI length (~2000 chars); chunk large sets. |
| 52 | + - **curl**:: |
| 53 | + |
| 54 | + curl "https://cwms-data.usace.army.mil/cwms-data/timeseries/recent?office=SWT&ts-ids=KEYS.ELEV.Inst.1Hour.0.CCP-RAW,KEYS.FLOW.Inst.1Hour.0.CCP-RAW" |
| 55 | + |
| 56 | + **Python**:: |
| 57 | + |
| 58 | + r = requests.get("https://cwms-data.usace.army.mil/cwms-data/timeseries/recent", |
| 59 | + params={ |
| 60 | + "office": "SWT", |
| 61 | + "ts-ids": "KEYS.ELEV.Inst.1Hour.0.CCP-RAW,KEYS.FLOW.Inst.1Hour.0.CCP-RAW" |
| 62 | + }) |
| 63 | + print(r.json()) |
| 64 | + * - `GET /timeseries/filtered <https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html#/TimeSeries/getFilteredTimeseries>`__ |
| 65 | + - - SQL-like queries (``greater than``, ``less than``, etc.). |
| 66 | + - Session noted powerful but time-consuming. |
| 67 | + - - Use only when filtering by values is essential. |
| 68 | + - Test carefully on large ranges; may impact performance. |
| 69 | + - **curl**:: |
| 70 | + |
| 71 | + curl "https://cwms-data.usace.army.mil/cwms-data/timeseries/filtered?office=SWT&name=KEYS.ELEV.Inst.1Hour.0.CCP-RAW&where=value>500" |
| 72 | + |
| 73 | + **Python**:: |
| 74 | + |
| 75 | + r = requests.get("https://cwms-data.usace.army.mil/cwms-data/timeseries/filtered", |
| 76 | + params={ |
| 77 | + "office": "SWT", |
| 78 | + "name": "KEYS.ELEV.Inst.1Hour.0.CCP-RAW", |
| 79 | + "where": "value>500" |
| 80 | + }) |
| 81 | + print(r.json()) |
| 82 | + * - `GET /timeseries/profiles <https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html#/TimeSeries/getTimeseriesProfiles>`__ |
| 83 | + - - 2D profiles (e.g., values by depth). |
| 84 | + - Session confirmed little/no data on national instance. |
| 85 | + - - Verify your district has data before building UI. |
| 86 | + - May be optional feature. |
| 87 | + - **curl**:: |
| 88 | + |
| 89 | + curl "https://cwms-data.usace.army.mil/cwms-data/timeseries/profiles?office=SWT&name=PROFILE.DEPTH.1Day.0.WQ" |
| 90 | + |
| 91 | + **Python**:: |
| 92 | + |
| 93 | + r = requests.get("https://cwms-data.usace.army.mil/cwms-data/timeseries/profiles", |
| 94 | + params={ |
| 95 | + "office": "SWT", |
| 96 | + "name": "PROFILE.DEPTH.1Day.0.WQ" |
| 97 | + }) |
| 98 | + print(r.json()) |
| 99 | + * - `GET /catalog/timeseries <https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html#/Catalog/getTimeseriesCatalog>`__ |
| 100 | + - - Lists available time series, units, intervals, time zones. |
| 101 | + - Essential for validation. |
| 102 | + - - Query before building dashboards to ensure valid IDs. |
| 103 | + - Use to distinguish ``regular`` vs ``pseudo-irregular`` (tilde in ID). |
| 104 | + - **curl**:: |
| 105 | + |
| 106 | + curl "https://cwms-data.usace.army.mil/cwms-data/catalog/timeseries?office=SWT" |
| 107 | + |
| 108 | + **Python**:: |
| 109 | + |
| 110 | + r = requests.get("https://cwms-data.usace.army.mil/cwms-data/catalog/timeseries", |
| 111 | + params={"office": "SWT"}) |
| 112 | + print(r.json()) |
0 commit comments