Skip to main content

CWMSpy

CWMS REST API for Data Retrieval

Requirements.

Python 3.9+

Installation & Usage

pip install

pip install cwms-python

Then import the package:

import cwms

Authentication

cwms.init_session() supports both CDA API keys and Keycloak access tokens. Use api_key= for the headless CDA API key flow, or token= for an OIDC access token such as one saved by cwms-cli login.

import cwms

cwms.init_session(
    api_root="https://cwms-data.usace.army.mil/cwms-data/",
    token="ACCESS_TOKEN",
)

If both token and api_key are provided, cwms-python will use the token and log a warning.

Getting Started

import cwms
from datetime import datetime, timedelta

end = datetime.now()
begin = end - timedelta(days = 10)
data = cwms.get_timeseries(ts_id='Some.Fully.Qualified.Ts.Id',office_id='OFFICE1' , begin = begin, end = end)

#a cwms data object will be provided this object containes both the JSON as well
#as the values converted into a dataframe

#display the dataframe

df = data.df
print(df)
     date-time 	value 	quality-code
0 	2024-04-23 08:15:00 	86.57 	3
1 	2024-04-23 08:30:00 	86.57 	3
2 	2024-04-23 08:45:00 	86.58 	3
3 	2024-04-23 09:00:00 	86.58 	3
4 	2024-04-23 09:15:00 	86.58 	3
5 	2024-04-23 09:30:00 	86.58 	3
6 	2024-04-23 09:45:00 	86.59 	3
7 	2024-04-23 10:00:00 	86.58 	3
#display JSON
json = data.JSON
print(json)
{'name': 'Some.Fully.Qualified.Ts.Id',
 'office-id': 'MVP',
 'units': 'ft',
 'values': [['2024-04-23T08:15:00', 86.57, 3],
  ['2024-04-23T08:30:00', 86.57, 3],
  ['2024-04-23T08:45:00', 86.57999999999997, 3],
  ['2024-04-23T09:00:00', 86.57999999999997, 3],
  ['2024-04-23T09:15:00', 86.57999999999997, 3],
  ['2024-04-23T09:30:00', 86.57999999999997, 3],
  ['2024-04-23T09:45:00', 86.59, 3],
  ['2024-04-23T10:00:00', 86.57999999999997, 3]],
 'version-date': None}

TimeSeries Profile API Compatibility Warning

Currently, the TimeSeries Profile API may not be fully supported until a new version of cwms-data-access is released with the updated endpoint implementation.

Contributing

Please view the contribution documentation here: [CONTRIBUTING.md]

Contributing and releases

See CONTRIBUTING.md for development checks, PR title conventions, and the Release Please publishing workflow.

Release files for cwms-python 1.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cwms-python 1.0.9
File Size Uploaded
cwms_python-1.0.9.tar.gz 46.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cwms-python 1.0.9
File Interpreter ABI Platform
cwms_python-1.0.9-py3-none-any.whl Python 3 none any Details

Total release size: 118.8 kB

Release files / cwms_python-1.0.9.tar.gz

Download URL cwms_python-1.0.9.tar.gz
Size 46.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1d6983e19a5df57bc4139869145794d5ce9ed2045e5752fe959b6e49afafaaf1
BLAKE2b-256 checksum
How to use checksums
3da1121123e74d908a3eb159eaa65bfb97c0116e0bf25128bf2dd90e6f157453
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 10, 2026.

Transparency log

Release files / cwms_python-1.0.9-py3-none-any.whl

Download URL cwms_python-1.0.9-py3-none-any.whl
Size 72.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
822a08862461f0356126eac78496088197a2b4a3a57b7b63e40c2b0b8263317f
BLAKE2b-256 checksum
How to use checksums
de6e173fb1267c0484ad0cb45ca86b2ff6fd35ac2562e32e4272e9c13e2cf9c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 10, 2026.

Transparency log

Release history Release notifications | RSS feed

1.1.0

2 release files

1.0.10

2 release files

This release

1.0.9 This release

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.3

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.4

2 release files

0.3.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page