This directory contains javascript and typescript examples for node.js, browser, and deno.
- Node.js examples
- Prerequisites
- node installed, at least version 18 is recommended
- Run
npm install
in this directory - Change variables in ./env.mjs to configure connection to your InfluxDB instance. The file can be used as-is against a new docker InfluxDB v2.3 OSS GA installation
- Examples are executable. If it does not work for you, run
npm run esr EXAMPLE.ts
. - write.mjs Write data points to InfluxDB.
- query.ts Query InfluxDB with Flux.
- queryWithParams.mjs Supply parameters to a Flux query.
- ping.mjs Check status of InfluxDB server.
- createBucket.mjs Creates an example bucket.
- onboarding.mjs Performs onboarding of a new influxDB database. It creates a new organization, bucket and user that is then used in all examples.
- influxdb-1.8.ts How to use forward compatibility APIs from InfluxDB 1.8.
- rxjs-query.ts Use RxJS to query InfluxDB with Flux.
- writeAdvanced.mjs Shows how to control the way of how data points are written to InfluxDB.
- follow-redirects.mjs Shows how to configure the client to follow HTTP redirects.
- delete.ts Shows how to delete data from a bucket.
- httpErrorHandled.mjs Shows handling HTTP Error response.
- Prerequisites
- Browser examples
- Change
token, org, bucket, username, password
variables in ./env_browser.mjs to match your InfluxDB instance - Run
npm run browser
It starts a local HTTP server and opens index.html that contains client examples. The local HTTP server serves all files from this git repository and also proxies requests to a configured influxDB database, see scripts/server.mjs for details.
- Change
- Deno examples
- query.deno.ts shows how to query InfluxDB with Flux. It is almost the same as node's query.ts example, the difference is the import statement that works in deno and built-in typescript support.