erddap4js - ERDDAP JavaScript interface for the browser & Node
Simple ERDDAP library for JS, written in TypeScript. Works in Node or the browser. Supports tabledap and griddap queries. Browser version is dependency free.
Quickstart
Browser example
See a demo in demo/browser/index.html
Copy the file dist/browser/ERDDAP.js to the same folder with your HTML file.
Node example
The import is different, the rest is the same as the browser example above.
npm install erddap4js
const ERDDAP = default;
See a demo in demo/node/query.js
Documentation
ERDDAP()
const erddapServer = "https://coastwatch.pfeg.noaa.gov/erddap";
To use debug mode add a second argument of true
, this will console log URLs of all queries.
tabledap()
- Everything is case sensitive
- Constraints are ANDed together
- Operators are
!=
,=~
,<=
,>=
,=
,<
,>
- Order types are:
orderBy
,orderByClosest
,orderByCount
,orderByLimit
,orderByMax
,orderByMin
,orderByMinMax
,orderByMean
await erddapServer;
Sample response:
id: "Anacapa (Landing Cove)" common_name: "Red sea urchin" ... ;
griddap()
- Constraints are set differently for griddap.
- make sure to match number of dimensions with that of the dataset
- dimension properties must be ordered as they appear in the dataset (time, altitude, latitude, longitude)
- to add a
stride
argument (to get every nth value), add another element to the range array, eg["2010-12-16T12:00:00Z", "2010-12-16T12:00:00Z",3]
await erddapServer;
Sample response:
time: '2010-12-16T12:00:00Z' latitude: 505 longitude: -150 tos: 6109735 tosNobs: 3175 tosStderr: 06101171 ...
info()
Get variable and global attribute information for this dataset
await erddapServer;
Sample response:
"Row Type": "attribute" "Variable Name": "NC_GLOBAL" "Attribute Name": "acknowledgement" "Data Type": "String" "Value": "NOAA NESDIS COASTWATCH, NOAA SWFSC ERD, Channel Islands National Park, National Park Service" ... "Row Type": "variable" "Variable Name": "longitude" "Attribute Name": "" "Data Type": "double" "Value": "" ...
allDatasets()
Get metadata for all datasets- griddap, tabledap and others
await erddapServer;
Sample response:
datasetID: 'jplAmsreSstMon' accessible: 'public' institution: 'Remote Sensing Systems' dataStructure: 'grid' cdm_data_type: 'Grid' class: 'EDDGridSideBySide' title: 'AMSRE Model Output, obs4MIPs NASA-JPL, Global, 1 Degree, 2002-2010, Monthly' ... many more fields ... ...
CORS
Lots of ERDDAP servers won't support CORS, so you may run into this issue while trying to use ERDDAP in your browser. Read more about CORS and ERDDAP
Development
npm run build
- build the 'dist' directorynpm test
to run testsnpm run coverage
- to build a folder 'coverage' to see coverage reports in your browseract
- test Github Actions with act