JavaScript and InfluxDB
Use This InfluxDB Integration for FreeBuild IoT, analytics, and cloud applications using the JavaScript client library with InfluxDB.
Why use the InfluxDB JavaScript Client Library?
InfluxDB is an API-first time series database for your JavaScript applications. Use the InfluxDB open-source JavaScript API client to write and query data in Node.js, browser, and Deno environments and even manage your InfluxDB instance from within your application.
Key features
- Provides API access to all InfluxDB Write and Read functionality, settings, and advanced features
- Write data in InfluxDB line protocol or point data structure
- Automatically retry requests on failure
- Batch data to InfluxDB to gain greater efficiency
- Return InfluxDB data as a Flux Table Structure, string, csv, stream, or dataframe
- Delete data from a particular bucket
- Invoke a Flux script
- Create and manage your environment (buckets, tasks, authorization, source)
Get started
Read
Write
const {InfluxDB, flux} = require('@influxdata/influxdb-client')
// const url = "https://us-west-2-1.aws.cloud2.influxdata.com";
const url = "https://127.0.0.1:9999";
const token = 'my-token'
const org = 'my-org'
const bucket = 'my-bucket'
const client = new InfluxDB({url: url, token: token})
const queryApi = client.getQueryApi(org)
const query = flux`from(bucket: "${bucket}")
|> range(start: -1d)
|> filter(fn: (r) => r._measurement == "weatherstation")`
queryApi.queryRows(query, {
next(row, tableMeta) {
const o = tableMeta.toObject(row)
console.log(`${o._time} ${o._measurement}: ${o._field}=${o._value}`)
},
error(error) {
console.error(error)
console.log('Finished ERROR')
},
complete() {
console.log('Finished SUCCESS')
},
})
For more information, please check out the documentation.
Project URL Documentation for web browsers Documentation for Node.js JavaScript client library