/opensensemap-client

The library allows and improves type-bassed working with the openSenseMap API

Primary LanguageTypeScriptMIT LicenseMIT

openSenseMap Client

Based on API version: v11.0.0

NPM

Install

yarn add opensensemap-client

Usage

Usage in TypeScript (with ES Modules):

import * as client from 'opensensemap-client';

async function start() {
	// Get information about a senseBox
	const r = await client.getBox('57000b8745fd40c8196ad04c').catch((e) => console.error(e));

	console.log(JSON.stringify(r));

	// Post new sensor data
	const data: client.PostNewMeasurementsData = [];
	const authToken = 'Your senseBox token';

	data.push({
		sensor: 'Your sensorId',
		value: 'Your data'
	});

	client.postNewMeasurements('Your senseBoxId', data, authToken).catch(console.error);
}

start();

Usage in JavaScript (with CommonJS):

const client = require('opensensemap-client');

async function start() {
	// Get information about a senseBox
	const r = await client.getBox('57000b8745fd40c8196ad04c').catch((e) => console.error(e));

	console.log(JSON.stringify(r));

	// Post new sensor data
	const data = [];
	const authToken = 'Your senseBox token';

	data.push({
		sensor: 'Your sensorId',
		value: 'Your data'
	});

	client.postNewMeasurements('Your senseBoxId', data, authToken).catch(console.error);
}

start();

Listed functions according to API documentation of openSenseMap

You can find more information in the full documentation.


Author

👤 KillerJulian info@killerjulian.de

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can also take a look at the contributing guide.