Install the InfluxDB JavaScript client library
Start a new Node.js project. The package manager is included with Node.js.
Many of the client library examples use TypeScript. Follow these steps to initialize the TypeScript project.
Install TypeScript and type definitions for Node.js.
npm i -g typescript && npm i --save-dev @types/node
Run the TypeScript compiler. To recompile your code automatically as you make changes, pass the
watch
flag to the compiler.tsc -w -p
The JavaScript client library contains two packages: @influxdata/influxdb-client
and . Add both as dependencies of your project.
Install
@influxdata/influxdb-client-apis
for access to the InfluxDB management APIs:npm install --save @influxdata/influxdb-client-apis
The client examples include an module for accessing your InfluxDB properties from environment variables or from env.js
. The examples use these properties to interact with the InfluxDB API.
Set environment variables or update with your InfluxDB bucket, , token, and .
Replace the following:
YOUR_API_TOKEN
: InfluxDB API tokenYOUR_ORG
: InfluxDB organization IDYOUR_BUCKET
: InfluxDB bucket name