cwmsjs
v2.0.0
Published
CWMS Data API Library for JavaScript/TypeScript created with OpenAPI generator in TypeScript for use with browser webapps
Downloads
309
Readme
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 .getCwmsDataTimeseries({ 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:
- New Users : Examples
- Advanced users : Type Documentation / Developer Docs
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