Documentation

Install the JavaScript client library

Install

  1. Install Node.js.

  2. Ensure that InfluxDB is running and you can connect to it. For information about what URL to use to connect to InfluxDB OSS or InfluxDB Cloud, see InfluxDB URLs.

  3. Start a new Node.js project. The npm package manager is included with Node.js.

    npm init -y influx-node-app
    

Install dependencies

This library supports browser and server-side (Node.js) Javascript environments. Use the @influxdata/influxdb-client module when targeting Node.js. The module supports both CommonJS and ES Module syntax.

To use InfluxDB management APIs in your project, also add @influxdata/influxdb-client-apis as a dependency to your project.

If you target the browser or deno, use @influxdata/influxdb-client-browser. It is UMD-compatible for use with module loaders. See Javascript (browser) for more information.

The JavaScript client contains two packages. Add both as dependencies of your project.

  1. Change to your project directory:

    cd influx-node-app
    
  2. Install @influxdata/influxdb-client for querying and writing data:

    npm install --save @influxdata/influxdb-client
    
  3. Install @influxdata/influxdb-client-apis for access to the InfluxDB management APIs:

    npm install --save @influxdata/influxdb-client-apis
    

Configure your environment

Set environment variables for bucket, organization, token, and url. Your application will use these to interact with the InfluxDB API.

export INFLUX_URL=http://localhost:8086
export INFLUX_TOKEN=influxdbauthtoken
export INFLUX_ORG=emailaddress@yourorg.org
export INFLUX_BUCKET=your_data_bucket

The client examples include an env module for conveniently accessing environment variables.


Set your InfluxDB URL

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.