Documentation

Install the InfluxDB JavaScript client library

This page documents an earlier version of InfluxDB. InfluxDB v2.6 is the latest stable version. View this page in the v2.6 documentation.

Install Node.js

  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 TypeScript

Many of the client library examples use TypeScript. Follow these steps to initialize the TypeScript project.

  1. Install TypeScript and type definitions for Node.js.

    npm i -g typescript && npm i --save-dev @types/node
    
  2. Create a TypeScript configuration with default values.

    tsc --init
    
  3. Run the TypeScript compiler. To recompile your code automatically as you make changes, pass the watch flag to the compiler.

    tsc -w -p
    

Install dependencies

The JavaScript client library contains two packages: @influxdata/influxdb-client and @influxdata/influxdb-client-apis. Add both as dependencies of your project.

  1. Open a new terminal window and install @influxdata/influxdb-client for querying and writing data:

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

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

Next steps

Once you’ve installed the Javascript client library, you’re ready to write data to InfluxDB or get started with other examples from the client library.

Get started with examples

The client examples include an env module for accessing your InfluxDB properties from environment variables or from env.js. The examples use these properties to interact with the InfluxDB API.

  1. Set environment variables or update env.js with your InfluxDB bucket, organization, token, and url.

    export INFLUX_URL=http://localhost:8086
    export INFLUX_TOKEN=YOUR_API_TOKEN
    export INFLUX_ORG=YOUR_ORG
    export INFLUX_BUCKET=YOUR_BUCKET
    

    Replace the following:

    • YOUR_API_TOKEN: InfluxDB API token
    • YOUR_ORG: InfluxDB organization ID
    • YOUR_BUCKET: InfluxDB bucket name
  2. Run an example script.

    query.ts
    

For more examples and information, see the JavaScript client on GitHub.


Was this page helpful?

Thank you for your feedback!


Set your InfluxDB URL

Linux Package Signing Key Rotation

All signed InfluxData Linux packages have been resigned with an updated key. If using Linux, you may need to update your package configuration to continue to download and verify InfluxData software packages.

For more information, see the Linux Package Signing Key Rotation blog post.

InfluxDB Cloud backed by InfluxDB IOx

All InfluxDB Cloud organizations created on or after January 31, 2023 are backed by the new InfluxDB IOx storage engine. Check the right column of your InfluxDB Cloud organization homepage to see which InfluxDB storage engine you’re using.

If powered by IOx, this is the correct documentation.

If powered by TSM, see the TSM-based InfluxDB Cloud documentation.

InfluxDB Cloud backed by InfluxDB TSM

All InfluxDB Cloud organizations created on or after January 31, 2023 are backed by the new InfluxDB IOx storage engine which enables nearly unlimited series cardinality and SQL query support. Check the right column of your InfluxDB Cloud organization homepage to see which InfluxDB storage engine you’re using.

If powered by TSM, this is the correct documentation.

If powered by IOx, see the IOx-based InfluxDB Cloud documentation.

State of the InfluxDB Cloud (IOx) documentation

The new documentation for InfluxDB Cloud backed by InfluxDB IOx is a work in progress. We are adding new information and content almost daily. Thank you for your patience!

If there is specific information you’re looking for, please submit a documentation issue.