Documentation

Install the InfluxDB v2 JavaScript client library

Use InfluxDB 3 clients

The /api/v2/query API endpoint and associated tooling, such as InfluxDB v2 client libraries and the influx CLI, can’t query an InfluxDB Cloud Serverless cluster.

InfluxDB 3 client libraries are available that integrate with your code to write and query data stored in InfluxDB Cloud Serverless.

InfluxDB 3 supports many different tools for writing and querying data. Compare tools you can use to interact with InfluxDB Cloud Serverless.

Install the Node.js JavaScript client library to write data to InfluxDB InfluxDB Cloud Serverless.

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 Cloud Serverless, see InfluxDB URLs.

  3. In your terminal, create a directory for your Node.js project and change to it.

    mkdir influx-node-app && cd influx-node-app
  4. Enter the following command to generate an npm package for your project.

    • npm: the package manager included with Node.js
    • -y: uses defaults for the package and bypasses prompts
    npm init -y

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. Enter the following command to create a TypeScript configuration (tsconfig.json) with default values:

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

    tsc --watch

Install dependencies

Use the @influxdata/influxdb-client JavaScript client library to write data in InfluxDB Cloud Serverless.

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

npm i --save @influxdata/influxdb-client

The @influxdata/influxdb-client-apis client library package won’t work with InfluxDB Cloud Serverless. It only works with InfluxDB v2 management APIs.

Configure credentials

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.

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

export INFLUX_URL=https://cloud2.influxdata.com
export INFLUX_TOKEN=API_TOKEN
export INFLUX_ORG=ORG_ID
export INFLUX_BUCKET=BUCKET_NAME

Replace the following:

  • API_TOKEN: InfluxDB API token with write permission to the bucket.
  • ORG_ID: InfluxDB organization ID
  • BUCKET_NAME: the name of the InfluxDB Cloud Serverless bucket to write to

Next steps

Once you’ve installed the client library and configured credentials, you’re ready to write data.


Was this page helpful?

Thank you for your feedback!


New in InfluxDB 3.5

Key enhancements in InfluxDB 3.5 and the InfluxDB 3 Explorer 1.3.

See the Blog Post

InfluxDB 3.5 is now available for both Core and Enterprise, introducing custom plugin repository support, enhanced operational visibility with queryable CLI parameters and manual node management, stronger security controls, and general performance improvements.

InfluxDB 3 Explorer 1.3 brings powerful new capabilities including Dashboards (beta) for saving and organizing your favorite queries, and cache querying for instant access to Last Value and Distinct Value caches—making Explorer a more comprehensive workspace for time series monitoring and analysis.

For more information, check out:

InfluxDB Docker latest tag changing to InfluxDB 3 Core

On November 3, 2025, the latest tag for InfluxDB Docker images will point to InfluxDB 3 Core. To avoid unexpected upgrades, use specific version tags in your Docker deployments.

If using Docker to install and run InfluxDB, the latest tag will point to InfluxDB 3 Core. To avoid unexpected upgrades, use specific version tags in your Docker deployments. For example, if using Docker to run InfluxDB v2, replace the latest version tag with a specific version tag in your Docker pull command–for example:

docker pull influxdb:2

InfluxDB Cloud Serverless