/cwms-data-api-client-javascript

A JavaScript wrapper for the CWMS Data API (CDA), a RESTful web service for managing water data. Documentation: https://hydrologicengineeringcenter.github.io/cwms-data-api-client-javascript/ Package Repo: https://www.npmjs.com/package/cwmsjs

Primary LanguageJavaScriptMIT LicenseMIT

CWMSjs

CWMS Data API (CDA) client library created with OpenAPI generator in TypeScript for use with web browsers.

Getting Started

  • Install CWMSjs to your react project with:
    npm install cwmsjs --save
    (This will grab the latest)

  • Import the API endpoint you wish to use:

    • Avaiable endpoints are here (Classes ending in API): Endpoints
    • At the top of your js/jsx/file type:
      import { TimeseriesAPI } from "cwmsjs";
    • Then initialize the TimeseriesAPI with:
      const tsa = new TimeseriesAPI();
    • Fetch timeseries data with:
      await ts_api
        .getTimeseries({
          office: "SWT",
          name: "KEYS.Elev.Inst.1Hour.0.Ccp-Rev",
        })
        .then((data) => {
          console.log(data);
        })
        .catch((e) => {
          console.log("My Error", e);
        });

Documentation is available for both developers and new users:

Building CWMSjs from source

  • Install openapi-generator-cli with:
    npm install -g @openapitools/openapi-generator-cli
    (This will grab the latest)

Run the following commands to build the project:

  • Run the generator with: npm run openapi
  • Transpile the typescript npm run build