@skycatch-api/skylink-node
v0.1.5
Published
Nodejs library for accessing Skycatch's REST API
Downloads
4
Readme
skylink-node
Nodejs lib for accessing Skycatch API
Setup
var config = {
API_URL: process.env.SKYLINK_API_URL || null,
API_TOKEN: process.env.SKYLINK_API_TOKEN || null,
ORGANIZATION_ID: process.env.SKYLINK_API_ORGANIZATION_ID || null,
SITE_ID: null
}
var SkyLink = require("skylink-node")
var SkyLinkObj = SkyLink({ API_TOKEN: config.API_TOKEN })
SkyLinkObj.getOrganization({ ORGANIZATION_ID: config.ORGANIZATION_ID })
.then(showOrganization)
.catch(showError)
function showOrganization(res){
console.log("\n\tOrganization name: ", res.data.organization.name, '\n')
SkyLinkObj.getSites(
{ ORGANIZATION_ID: config.ORGANIZATION_ID })
.then(showSites)
.catch(showError)
}
function showSites(res){
console.log("\n\tSites:\n")
for(var key in res.data.items) {
console.log('\t', res.data.items[key].id, ' ', res.data.items[key].name)
}
config.SITE_ID = res.data.items[9].id
config.SITE_NAME = res.data.items[9].name
SkyLinkObj.getDatasets(
{ ORGANIZATION_ID: config.ORGANIZATION_ID,
SITE_ID: config.SITE_ID })
.then(showDatasets)
.catch(showError)
}