1.1.0 • Published 5 months ago

@influxdata/influxdb3-client v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

InfluxDB 3 JavaScript Client

The JavaScript Client that provides a simple and convenient way to interact with InfluxDB 3. This package supports both writing data to InfluxDB and querying data using the FlightSQL client, which allows you to execute SQL queries against InfluxDB IOx.

Installation

To write or query InfluxDB 3, add @influxdata/influxdb3-client as a dependency to your project using your favorite package manager.

npm install --save @influxdata/influxdb3-client
yarn add @influxdata/influxdb3-client
pnpm add @influxdata/influxdb3-client

If you target Node.js, use @influxdata/influxdb3-client. It provides main (CJS), module (ESM), and browser (UMD) exports.

⚠️ The browser target is not currently supported.

Usage

set environment variables:

  • INFLUXDB_URL region of your influxdb cloud e.g. https://us-east-1-1.aws.cloud2.influxdata.com/
  • INFLUXDB_TOKEN read/write token generated in cloud
  • INFLUXDB_DATABASE name of database e.g .my-database
export INFLUXDB_URL="<url>"
export INFLUXDB_DATABASE="<database>"
export INFLUXDB_TOKEN="<token>"

powershell

set INFLUXDB_URL=<url>
set INFLUXDB_DATABASE=<database>
set INFLUXDB_TOKEN=<token>

cmd

$env:INFLUXDB_URL "<url>"
$env:INFLUXDB_DATABASE "<database>"
$env:INFLUXDB_TOKEN "<token>"

To get started with influxdb client import @influxdata/influxdb3-client package.

import {InfluxDBClient, Point} from '@influxdata/influxdb3-client'

Prepare environmnet variables and instanciate InfluxDBClient in asynchronous function. Make sure to close client after.

const url = process.env.INFLUXDB_URL
const token = process.env.INFLUXDB_TOKEN
const database = process.env.INFLUXDB_DATABASE

async function main() {
    const client = new InfluxDBClient({url, token})

    // following code goes here

    client.close()
}

main()

The client can be now used to insert data using line-protocol:

const line = `stat,unit=temperature avg=20.5,max=45.0`
await client.write(line, database)

Fetch data using SQL query and print result.

// Execute query
const query = `
    SELECT *
    FROM "stat"
    WHERE
    time >= now() - interval '5 minute'
    AND
    "unit" IN ('temperature')
`
const queryResult = await client.query(query, database)

for await (const row of queryResult) {
    console.log(`avg is ${row.avg}`)
    console.log(`max is ${row.max}`)
}

Example

For more complex examples see examples folder.

Feedback

If you need help, please use our Community Slack or Community Page.

New features and bugs can be reported on GitHub: https://github.com/InfluxCommunity/influxdb3-js

Contribution

If you would like to contribute code you can do through GitHub by forking the repository and sending a pull request into the main branch.

Development

Update the Flight Client

As of now, we're responsible for generating the Flight Client by ourself. However, its Protobuf interfaces may undergo changes over time. To re-generate the Flight Client, we have provided a script that can be executed using yarn flight. This script will clone the Flight Protobuf repository and generate new TypeScript files into the client.

License

The InfluxDB 3 JavaScript Client is released under the MIT License.

0.13.0-nightly.6888

12 months ago

0.13.0-nightly.6983

12 months ago

0.13.0-nightly.6982

12 months ago

0.13.0-nightly.6981

12 months ago

0.13.0-nightly.6980

12 months ago

0.13.0-nightly.6974

12 months ago

1.1.0-nightly.8064

8 months ago

1.1.0-nightly.8077

8 months ago

1.1.0-nightly.8051

8 months ago

0.13.0-nightly.6922

12 months ago

1.1.0-nightly.7730

9 months ago

1.1.0-nightly.7965

9 months ago

1.1.0-nightly.7846

9 months ago

0.13.0-nightly.6911

12 months ago

1.1.0-nightly.7743

9 months ago

0.13.0-nightly.6905

12 months ago

1.1.0-nightly.7717

9 months ago

1.1.0-nightly.7833

9 months ago

1.1.0-nightly.7922

9 months ago

1.1.0-nightly.7807

9 months ago

1.1.0-nightly.7820

9 months ago

1.1.0-nightly.7909

9 months ago

1.1.0-nightly.7698

9 months ago

0.13.0-nightly.7054

11 months ago

0.13.0-nightly.7048

11 months ago

1.1.0-nightly.7794

9 months ago

0.13.0-nightly.7032

11 months ago

0.13.0-nightly.7026

11 months ago

0.13.0-nightly.7146

11 months ago

0.13.0-nightly.7025

11 months ago

1.1.0-nightly.7685

9 months ago

0.13.0-nightly.7266

10 months ago

0.13.0-nightly.7140

11 months ago

0.13.0-nightly.7260

10 months ago

1.1.0-nightly.7896

9 months ago

1.1.0-nightly.7648

9 months ago

1.1.0-nightly.7787

9 months ago

1.2.0-nightly.8282

7 months ago

1.2.0-nightly.8284

7 months ago

0.13.0-nightly.7199

11 months ago

0.13.0-nightly.7198

11 months ago

0.13.0-nightly.7197

11 months ago

0.13.0-nightly.7076

11 months ago

0.13.0-nightly.7075

11 months ago

1.1.0-nightly.7883

9 months ago

1.2.0-nightly.8263

7 months ago

1.2.0-nightly.8262

7 months ago

0.13.0-nightly.7335

10 months ago

0.13.0-nightly.7334

10 months ago

0.13.0-nightly.7333

10 months ago

1.1.0-nightly.8026

8 months ago

1.1.0-nightly.8146

8 months ago

0.13.0-nightly.7332

10 months ago

1.1.0-nightly.8153

8 months ago

0.13.0-nightly.7201

11 months ago

1.1.0

7 months ago

1.1.0-nightly.8121

8 months ago

1.0.0

9 months ago

0.13.0-nightly.7019

11 months ago

0.13.0-nightly.7139

11 months ago

1.1.0-nightly.8102

8 months ago

0.13.0-nightly.7244

10 months ago

0.13.0-nightly.7243

10 months ago

0.13.0-nightly.7242

10 months ago

0.13.0-nightly.7112

11 months ago

1.2.0-nightly.8417

5 months ago

0.13.0-nightly.7346

10 months ago

0.12.0-nightly.6842

12 months ago

0.12.0-nightly.6841

12 months ago

0.12.0-nightly.6844

12 months ago

0.12.0-nightly.6843

12 months ago

0.13.0-nightly.6855

12 months ago

0.12.0

12 months ago

0.12.0-nightly.6835

12 months ago

0.11.0

1 year ago

0.10.0

1 year ago

0.9.0

1 year ago

0.8.0

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago