feat(iox): add a reference list for client libraries (#4906)

* feat(iox): add a reference list for client libraries

- Reference > Client libraries > v3, v2, v1
- For Serverless and Dedicated

* Update content/influxdb/cloud-dedicated/reference/client-libraries/_index.md

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

* Update content/influxdb/cloud-serverless/reference/client-libraries/_index.md

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

* Update content/influxdb/cloud-dedicated/reference/client-libraries/v2/_index.md

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

* Update content/influxdb/cloud-serverless/reference/client-libraries/v2/_index.md

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

* Update content/influxdb/cloud-dedicated/reference/client-libraries/v2/javascript/nodejs/write.md

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

* Update content/influxdb/cloud-serverless/reference/client-libraries/v2/_index.md

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

* Update content/influxdb/cloud-dedicated/reference/client-libraries/v2/javascript/nodejs/write.md

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

* Update content/influxdb/cloud-dedicated/reference/client-libraries/v2/python.md

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

* Update content/influxdb/cloud-dedicated/reference/client-libraries/v2/python.md

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

* Update content/influxdb/cloud-dedicated/reference/client-libraries/v2/python.md

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

* Update content/influxdb/cloud-dedicated/reference/client-libraries/v2/_index.md

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

* Update python.md

* Apply suggestions from code review

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

* Update content/influxdb/cloud-dedicated/reference/client-libraries/v2/javascript/nodejs/query.md

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

* Update content/influxdb/cloud-dedicated/reference/client-libraries/v2/go.md

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

* Update content/influxdb/cloud-dedicated/reference/client-libraries/v2/javascript/browser.md

* Update content/influxdb/cloud-dedicated/reference/client-libraries/v2/javascript/browser.md

* Update content/influxdb/cloud-dedicated/reference/client-libraries/v2/javascript/nodejs/write.md

* Update content/influxdb/cloud-dedicated/reference/client-libraries/v2/python.md

* Update content/influxdb/cloud-serverless/reference/client-libraries/v2/go.md

* Update content/influxdb/cloud-serverless/reference/client-libraries/v2/javascript/nodejs/query.md

* Update content/influxdb/cloud-serverless/reference/client-libraries/v2/javascript/browser.md

* Update content/influxdb/cloud-serverless/reference/client-libraries/v2/javascript/nodejs/install.md

* Update content/influxdb/cloud-serverless/reference/client-libraries/v2/javascript/nodejs/query.md

* fix(iox): client libraries lists for serverless and dedicated

- Removes query examples for serverless that use Flux
- Clean up and explain some placeholders
- Fix Go Flght SQL client URL (404)
- Add Flight SQL clients to client libraries list (I can imagine someone complaining that they should be there; Maybe we should separate them eventually).

* fix(iox): client library lists - extract Flight SQL clients into a separate section

* fix(v3): client libraries and flight sql clients

- cleanup
- fix tags and descriptions
- fix wrong menu names

---------

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>
pull/4907/head
Jason Stirnaman 2023-04-27 11:05:27 -05:00 committed by GitHub
parent 87944a9f9a
commit c1bc8e38b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
54 changed files with 2241 additions and 12 deletions

View File

@ -0,0 +1,21 @@
---
title: InfluxDB API client libraries
description: >
InfluxDB client libraries are language-specific tools that integrate with InfluxDB APIs.
View the list of available client libraries.
list_title: API client libraries
weight: 105
aliases:
- /influxdb/cloud-dedicated/reference/api/client-libraries/
- /influxdb/cloud-dedicated/tools/client-libraries/
- /influxdb/cloud-dedicated/api-guide/client-libraries/
menu:
influxdb_cloud_dedicated:
name: Client libraries
parent: Reference
influxdb/cloud-dedicated/tags: [client libraries, API, developer tools]
---
InfluxDB client libraries are language-specific packages that integrate with InfluxDB APIs.
{{< children depth="999" description="true" >}}

View File

@ -0,0 +1,20 @@
---
title: Flight SQL clients
description: >
Flight SQL clients are language-specific drivers that can interact with SQL databases using the Arrow in-memory format and the Flight RPC framework.
View the list of available clients.
weight: 30
menu:
influxdb_cloud_dedicated:
name: Flight SQL clients
parent: Client libraries
influxdb/cloud-dedicated/tags: [Golang, Python, client libraries, Flight SQL]
---
Flight SQL clients are language-specific drivers that can interact with SQL databases using the Arrow in-memory format and the Flight RPC framework.
Clients provide a [`FlightClient`](https://arrow.apache.org/docs/python/generated/pyarrow.flight.FlightClient.html#pyarrow.flight.FlightClient) that can query and retrieve data from InfluxDB v3 using gRPC and Flight SQL.
Some [InfluxDB v3 client libraries](/influxdb/cloud-dedicated/reference/client-libraries/v3) include Flight SQL clients.
For specifics about a client library, see the library's GitHub repository.
{{< children depth="999" description="true" >}}

View File

@ -0,0 +1,19 @@
---
title: Go Flight SQL client
description: The Go Flight SQL client integrates with golang scripts and applications to query data stored in an InfluxDB Cloud Dedicated database.
external_url: https://pkg.go.dev/github.com/apache/arrow/go/v12/arrow/flight/flightsql
menu:
influxdb_cloud_dedicated:
name: Go Flight SQL client
parent: Flight SQL clients
params:
url: https://pkg.go.dev/github.com/apache/arrow/go/v12/arrow/flight/flightsql
identifier: go-flightsql
influxdb/cloud-dedicated/tags: [Golang, gRPC, SQL, Flight SQL, client libraries]
weight: 201
---
The [Go Flight SQL client](https://pkg.go.dev/github.com/apache/arrow/go/v12/arrow/flight/flightsql) integrates with golang scripts and applications to query data stored in an InfluxDB Cloud Dedicated database.
See the [example](/influxdb/cloud-dedicated/get-started/query/?t=Go#execute-a-sql-query).
For more information, see the [Go client README on GitHub](https://github.com/influxdata/influxdb-client-go).

View File

@ -0,0 +1,18 @@
---
title: Python Flight SQL DBAPI client
description: The Python `flightsql-dbapi` library integrates with Python scripts and applications to query data stored in an InfluxDB Cloud Dedicated database.
external_url: https://github.com/influxdata/flightsql-dbapi
menu:
influxdb_cloud_dedicated:
name: Python Flight SQL client
parent: Flight SQL clients
params:
url: https://github.com/influxdata/flightsql-dbapi
influxdb/cloud-dedicated/tags: [Python, gRPC, SQL, Flight SQL, client libraries]
weight: 201
---
The [Python Flight SQL DBAPI library](https://github.com/influxdata/flightsql-dbapi) integrates with Python scripts and applications to query data stored in an InfluxDB Cloud Dedicated database.
The documentation for this client library is available on GitHub.
<a href="https://github.com/influxdata/flightsql-dbapi" target="_blank" class="btn github">Python Flight SQL DBAPI library</a>

View File

@ -0,0 +1,146 @@
---
title: InfluxDB v1 client libraries
description: >
InfluxDB v1 client libraries use the InfluxDB 1.7 API and should be fully compatible with InfluxDB 1.5+.
View the list of available client libraries.
menu:
influxdb_cloud_dedicated:
weight: 201
name: v1 client libraries
parent: Client libraries
influxdb/cloud-dedicated/tags: [client libraries, API, developer tools]
---
InfluxDB client libraries are language-specific tools that integrate with InfluxDB APIs.
Client libraries for InfluxDB v1 work with the InfluxDB 1.7 API and should be fully compatible with InfluxDB 1.5+.
{{% note %}}
We highly recommend upgrading to InfluxDB 1.8 to use new client libraries compatible with both InfluxDB 1.8 and InfluxDB 2.0. For more information, see [InfluxDB client libraries](/influxdb/v1.8/tools/api_client_libraries/).
{{% /note %}}
Functionality varies among client libraries.
These client libraries are in active development and may not be feature-complete.
For specifics about a client library, see the library's GitHub repository.
## C++
* [influxdb-cxx](https://github.com/offa/influxdb-cxx)
* Maintained by [offa](https://github.com/offa)
## Elixir
* [Instream (instream)](https://github.com/mneudert/instream)
* Maintained by [Marc Neudert (mneudert)](https://github.com/mneudert)
## Erlang
* [Erlang InfluxDB UDP Writer](https://github.com/palkan/influx_udp)
* Maintained by [Vladimir Dementyev (palkan)](https://github.com/palkan)
* [InfluxDB line encoder](https://github.com/Pouriya-Jahanbakhsh/influxdb_encoderl)
* Maintained by [Pouriya Jahanbakhsh](https://github.com/Pouriya-Jahanbakhsh)
## Go
* [InfluxDB Client](https://github.com/influxdata/influxdb1-client)
* Maintained by [InfluxData](https://github.com/influxdata)
## Haskell
* [influxdb-haskell](https://github.com/maoe/influxdb-haskell)
* Maintained by [Mitsutoshi Aoe (maoe)](https://github.com/maoe)
## Java
* [influxdb-java](https://github.com/influxdb/influxdb-java)
* Maintained by [Stefan Majer (majst01)](https://github.com/majst01)
* [Alpakka InfluxDB](https://doc.akka.io/docs/alpakka/current/influxdb.html)
* Maintained by the Alpakka community with help from [Lightbend](https://www.lightbend.com/)
* [JFlux](https://github.com/nickRm/jflux)
* Maintained by [Nick Rammos (nickRm)](https://github.com/nickRm)
## JavaScript/Node.js
* [node-influx](https://github.com/node-influx/node-influx)
* Maintained by [Ben Evans (bencevans)](https://github.com/bencevans) and [Connor Peet (connor4312)](https://github.com/connor4312)
## Lisp
* [CL-INFLUXDB](https://github.com/mmaul/cl-influxdb)
* Maintained by [Mike Maul (mmaul)](https://github.com/mmaul)
## MATLAB
* [influxdb-matlab](https://github.com/EnricSala/influxdb-matlab)
* Maintained by [Enric Sala (EnricSala)](https://github.com/EnricSala)
## .Net
* [InfluxDB.Client.Net](https://github.com/AdysTech/InfluxDB.Client.Net)
* Maintained by [Adarsha (mvadu)](https://github.com/mvadu)
* Supports .Net and .Net Core
* [InfluxData.Net](https://github.com/pootzko/InfluxData.Net)
* Maintained by [Tijhomir Kit (pootzko)](https://github.com/pootzko)
* [InfluxDB Client for .NET](https://github.com/MikaelGRA/InfluxDB.Client)
* Maintained by [Mikael Guldborg Rask Andersen (MikaelGRA)](https://github.com/MikaelGRA)
* [InfluxClient](https://github.com/danesparza/InfluxClient)
* Maintained by [Dan Esparza (danesparza)](https://github.com/danesparza)
## Perl
* [AnyEvent::InfluxDB](https://github.com/ajgb/anyevent-influxdb)
 * Maintained by [Alex Burzyński (ajgb)](https://github.com/ajgb)
* [InfluxDB-LineProtocol](http://search.cpan.org/~domm/InfluxDB-LineProtocol/)
* Maintained by [Thomas Klausner (domm)](https://domm.plix.at/)
* [InfluxDB::HTTP](https://github.com/raphaelthomas/InfluxDB-HTTP)
* Maintained by [Raphael Seebacher (raphaelthomas)](https://github.com/raphaelthomas)
## PHP
* [influxdb-php](https://github.com/influxdb/influxdb-php)
* Maintained by [TheCodeAssassin (thecodeassassin)](https://github.com/thecodeassassin) and [Gianluca Arbezzano (gianarb)](https://github.com/gianarb)
* [InfluxDB PHP SDK (influxdb-php-sdk)](https://github.com/corley/influxdb-php-sdk)
* Maintained by [Corley (corley)](https://github.com/corley)
## Python
* [InfluxDB-Python (influxdb-python)](https://github.com/influxdb/influxdb-python)
* Maintained by [Alexandre Viau (aviau)](https://github.com/aviau), [xginn8](https://github.com/xginn8), and [Sebastian Borza (sebito91)](https://github.com/sebito91)
## R
* [influxdbr](https://cran.r-project.org/web/packages/influxdbr/)
* Maintained by [Dominik Leutnant (dleutant)](https://github.com/dleutnant)
## Ruby
* [influxdb-ruby](https://github.com/influxdb/influxdb-ruby)
* Maintained by [Todd Persen (toddboom)](https://github.com/toddboom) and [Dominik Menke (dmke)](https://github.com/dmke).
* [Influxer (influxer)](https://github.com/palkan/influxer)
* Maintained by [Vladimir Dementyev (palkan)](https://github.com/palkan).
## Rust
* [Flux (flux)](https://crates.io/crates/flux)
* Maintained by [Chris Holcombe (cholcombe973)](https://crates.io/users/cholcombe973) and [Chris MacNaughton](https://crates.io/users/ChrisMacNaughton)
* [Influent (influent)](https://crates.io/crates/influent)
* Maintained by [gobwas](https://crates.io/users/gobwas) and [Eijebong](https://crates.io/users/Eijebong).
## Scala
* [scala-influxdb-client](https://github.com/paulgoldbaum/scala-influxdb-client)
* Maintained by [Paul Goldbaum (paulgoldbaum)](https://github.com/paulgoldbaum)
* [chronicler](https://github.com/fsanaulla/chronicler)
* Maintained by [Faiaz Sanaulla (fsanaulla)](https://github.com/fsanaulla)
* [Alpakka InfluxDB](https://doc.akka.io/docs/alpakka/current/influxdb.html)
* Maintained by the Alpakka community with help from [Lightbend](https://www.lightbend.com/)
## Sensu
* [sensu-influxdb-extension](https://github.com/jhrv/sensu-influxdb-extension)
* Maintained by [Johnny Horvi (jhrv)](https://github.com/jhrv)
## SNMP agent
* [SnmpCollector (snmpcollector)](https://github.com/toni-moreno/snmpcollector)
* Maintained by [Toni Moreno (toni-moreno)](https://github.com/toni-moreno).
* A full featured Generic SNMP data collector with Web Administration Interface for InfluxDB.

View File

@ -0,0 +1,24 @@
---
title: InfluxDB v2 API client libraries
description: >
InfluxDB v2 client libraries use InfluxDB `/api/v2` endpoints and work with [InfluxDB 2.0 API compatibility endpoints](/{{< latest "influxdb" "v1" >}}/tools/api/#influxdb-20-api-compatibility-endpoints).
View the list of available client libraries.
weight: 101
menu:
influxdb_cloud_dedicated:
name: v2 client libraries
parent: Client libraries
influxdb/cloud-dedicated/tags: [client libraries, API, developer tools]
---
## Client libraries for InfluxDB 2.x and 1.8+
InfluxDB client libraries are language-specific tools that integrate with InfluxDB APIs.
InfluxDB v2 client libraries use InfluxDB `/api/v2` endpoints and work with [InfluxDB 2.0 API compatibility endpoints](/{{< latest "influxdb" "v1" >}}/tools/api/#influxdb-20-api-compatibility-endpoints).
Functionality varies among client libraries.
These client libraries are in active development and may not be feature-complete.
For specifics about a client library, see the library's GitHub repository.
{{< children type="list" depth="999" >}}

View File

@ -0,0 +1,21 @@
---
title: Arduino client library
seotitle: Use the InfluxDB Arduino client library
list_title: Arduino
description: Use the InfluxDB Arduino client library to interact with InfluxDB.
external_url: https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino
list_note: _ contributed by [tobiasschuerg](https://github.com/tobiasschuerg)_
menu:
influxdb_cloud_dedicated:
name: Arduino
parent: v2 client libraries
params:
url: https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino
weight: 201
---
Arduino is an open-source hardware and software platform used for building electronics projects.
The documentation for this client library is available on GitHub.
<a href="https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino" target="_blank" class="btn github">Arduino InfluxDB client</a>

View File

@ -0,0 +1,20 @@
---
title: C# client library
list_title: C#
seotitle: Use the InfluxDB C# client library
description: Use the InfluxDB C# client library to interact with InfluxDB.
external_url: https://github.com/influxdata/influxdb-client-csharp
menu:
influxdb_cloud_dedicated:
name: C#
parent: v2 client libraries
params:
url: https://github.com/influxdata/influxdb-client-csharp
weight: 201
---
C# is a general-purpose object-oriented programming language.
The documentation for this client library is available on GitHub.
<a href="https://github.com/influxdata/influxdb-client-csharp" target="_blank" class="btn github">C# InfluxDB client</a>

View File

@ -0,0 +1,20 @@
---
title: Dart client library
list_title: Dart
seotitle: Use the InfluxDB Dart client library
description: Use the InfluxDB Dart client library to interact with InfluxDB.
external_url: https://github.com/influxdata/influxdb-client-dart
menu:
influxdb_cloud_dedicated:
name: Dart
parent: v2 client libraries
params:
url: https://github.com/influxdata/influxdb-client-dart
weight: 201
---
Dart is a programming language created for quick application development for both web and mobile apps.
The documentation for this client library is available on GitHub.
<a href="https://github.com/influxdata/influxdb-client-dart" target="_blank" class="btn github">Dart InfluxDB client</a>

View File

@ -0,0 +1,127 @@
---
title: Go client library
seotitle: Use the InfluxDB Go client library
list_title: Go
description: >
Use the InfluxDB Go client library to interact with InfluxDB.
menu:
influxdb_cloud_dedicated:
name: Go
parent: v2 client libraries
influxdb/cloud-dedicated/tags: [client libraries, Go]
weight: 201
aliases:
- /influxdb/cloud-dedicated/reference/api/client-libraries/go/
- /influxdb/cloud-dedicated/tools/client-libraries/go/
---
Use the [InfluxDB Go client library](https://github.com/influxdata/influxdb-client-go) to integrate InfluxDB into Go scripts and applications.
This guide presumes some familiarity with Go and InfluxDB.
If just getting started, see [Get started with InfluxDB](/influxdb/cloud-dedicated/get-started/).
## Before you begin
1. [Install Go 1.13 or later](https://golang.org/doc/install).
2. Add the client package your to your project dependencies.
```sh
# Add InfluxDB Go client package to your project go.mod
go get github.com/influxdata/influxdb-client-go/v2
```
3. Ensure that InfluxDB is running and you can connect to it.
For information about what URL to use to connect to your InfluxDB Cloud Dedicated cluster, contact your InfluxData account representative.
## Boilerplate for the InfluxDB Go Client Library
Use the Go library to write and query data from InfluxDB.
1. In your Go program, import the necessary packages and specify the entry point of your executable program.
```go
package main
import (
"context"
"fmt"
"time"
"github.com/influxdata/influxdb-client-go/v2"
)
```
2. Define variables for your InfluxDB [database](/influxdb/cloud-dedicated/admin/databases/) (bucket), organization (required, but ignored), and [token](/influxdb/cloud-dedicated/admin/tokens/).
```go
bucket := "example-database"
org := "example-org"
token := "example-token"
// Store the URL of your InfluxDB instance
url := "https://cluster-id.influxdb.io"
```
3. Create the the InfluxDB Go client and pass in the `url` and `token` parameters.
```go
client := influxdb2.NewClient(url, token)
```
4. Create a **write client** with the `WriteAPIBlocking` method and pass in the `org` and `bucket` parameters.
```go
writeAPI := client.WriteAPIBlocking(org, bucket)
```
5. To query data, create an InfluxDB **query client** and pass in your InfluxDB `org`.
```go
queryAPI := client.QueryAPI(org)
```
## Write data to InfluxDB with Go
Use the Go library to write data to InfluxDB.
1. Create a [point](/influxdb/cloud-dedicated/reference/glossary/#point) and write it to InfluxDB using the `WritePoint` method of the API writer struct.
2. Close the client to flush all pending writes and finish.
```go
p := influxdb2.NewPoint("stat",
map[string]string{"unit": "temperature"},
map[string]interface{}{"avg": 24.5, "max": 45},
time.Now())
writeAPI.WritePoint(context.Background(), p)
client.Close()
```
### Complete example write script
```go
func main() {
bucket := "example-database"
org := "example-org"
token := "example-token"
// Store the URL of your InfluxDB instance
url := "http://localhost:8086"
// Create new client with default option for server url authenticate by token
client := influxdb2.NewClient(url, token)
// User blocking write client for writes to desired bucket
writeAPI := client.WriteAPIBlocking(org, bucket)
// Create point using full params constructor
p := influxdb2.NewPoint("stat",
map[string]string{"unit": "temperature"},
map[string]interface{}{"avg": 24.5, "max": 45},
time.Now())
// Write point immediately
writeAPI.WritePoint(context.Background(), p)
// Ensures background processes finishes
client.Close()
}
```
## Query data from InfluxDB with Go
The InfluxDB v2 Go client cannot query InfluxDB Cloud Dedicated.
To query your dedicated instance, use the [Go Flight SQL client](https://pkg.go.dev/github.com/apache/arrow/go/v12/arrow/flight/flightsql).
For an example, see [Get started querying data](/influxdb/cloud-dedicated/get-started/query/?t=Go#execute-a-sql-query).
For more information, see the [Go client README on GitHub](https://github.com/influxdata/influxdb-client-go).

View File

@ -0,0 +1,20 @@
---
title: Java client library
seotitle: Use the InfluxDB Java client library
list_title: Java
description: Use the Java client library to interact with InfluxDB.
external_url: https://github.com/influxdata/influxdb-client-java
menu:
influxdb_cloud_dedicated:
name: Java
parent: v2 client libraries
params:
url: https://github.com/influxdata/influxdb-client-java
weight: 201
---
Java is one of the oldest and most popular class-based, object-oriented programming languages.
The documentation for this client library is available on GitHub.
<a href="https://github.com/influxdata/influxdb-client-java" target="_blank" class="btn github">Java InfluxDB client</a>

View File

@ -0,0 +1,20 @@
---
title: JavaScript client library for the InfluxDB v2 API
seotitle: Use the InfluxDB JavaScript client library for the InfluxDB v2 API
list_title: JavaScript
description: >
Use the InfluxDB JavaScript client library to interact with InfluxDB 2.x and the InfluxDB v2 API.
external_url: https://github.com/influxdata/influxdb-client-js
menu:
influxdb_cloud_dedicated:
name: JavaScript
parent: v2 client libraries
influxdb/cloud-dedicated/tags: [client libraries, JavaScript, NodeJS]
weight: 201
aliases:
- /influxdb/cloud-dedicated/reference/api/client-libraries/js/
---
Use the [InfluxDB JavaScript client library](https://github.com/influxdata/influxdb-client-js) to integrate InfluxDB into Node.js and browser applications.
{{< children type="list">}}

View File

@ -0,0 +1,115 @@
---
title: JavaScript client library for web browsers
seotitle: Use the InfluxDB JavaScript client library for web browsers
list_title: JavaScript for browsers
description: >
Use the InfluxDB JavaScript client library to interact with InfluxDB in web clients.
menu:
influxdb_cloud_dedicated:
name: Browsers and web clients
identifier: client_js_browsers
parent: JavaScript
influxdb/cloud-dedicated/tags: [client libraries, JavaScript]
weight: 201
aliases:
- /influxdb/cloud-dedicated/api-guide/client-libraries/browserjs/write
- /influxdb/cloud-dedicated/api-guide/client-libraries/browserjs/query
related:
- /influxdb/cloud-dedicated/api-guide/client-libraries/nodejs/write/
- /influxdb/cloud-dedicated/api-guide/client-libraries/nodejs/query/
---
Use the [InfluxDB JavaScript client library](https://github.com/influxdata/influxdb-client-js) to interact with the InfluxDB v2 API in browsers and front-end clients. This library supports both front-end and server-side environments and provides the following distributions:
* ECMAScript modules (ESM) and CommonJS modules (CJS)
* Bundled ESM
* Bundled UMD
This guide presumes some familiarity with JavaScript, browser environments, and InfluxDB.
If you're just getting started with InfluxDB, see [Get started with InfluxDB](/{{% latest "influxdb" %}}/get-started/).
{{% warn %}}
### Tokens in production applications
{{% api/browser-token-warning %}}
{{% /warn %}}
* [Before you begin](#before-you-begin)
* [Use with module bundlers](#use-with-module-bundlers)
* [Use bundled distributions with browsers and module loaders](#use-bundled-distributions-with-browsers-and-module-loaders)
* [Get started with the example app](#get-started-with-the-example-app)
## Before you begin
1. Install [Node.js](https://nodejs.org/en/download/package-manager/) to serve your front-end app.
2. Ensure that InfluxDB is running and you can connect to it.
For information about what URL to use to connect to your InfluxDB Cloud Dedicated cluster, contact your InfluxData account representative.
## Use with module bundlers
If you use a module bundler like Webpack or Parcel, install `@influxdata/influxdb-client-browser`.
## Use bundled distributions with browsers and module loaders
1. Configure InfluxDB properties for your script.
```html
<script>
window.INFLUX_ENV = {
url: 'https://cluster-id.influxdb.io',
token: 'YOUR_AUTH_TOKEN'
}
</script>
```
2. Import modules from the latest client library browser distribution.
`@influxdata/influxdb-client-browser` exports bundled ESM and UMD syntaxes.
{{< code-tabs-wrapper >}}
{{% code-tabs %}}
[ESM](#import-esm)
[UMD](#import-umd)
{{% /code-tabs %}}
{{% code-tab-content %}}
```html
<script type="module">
import {InfluxDB, Point} from 'https://unpkg.com/@influxdata/influxdb-client-browser/dist/index.browser.mjs'
const influxDB = new InfluxDB({INFLUX_ENV.url, INFLUX_ENV.token})
</script>
```
{{% /code-tab-content %}}
{{% code-tab-content %}}
```html
<script src="https://unpkg.com/@influxdata/influxdb-client-browser"></script>
<script>
const Influx = window['@influxdata/influxdb-client']
const InfluxDB = Influx.InfluxDB
const influxDB = new InfluxDB({INFLUX_ENV.url, INFLUX_ENV.token})
</script>
```
{{% /code-tab-content %}}
{{< /code-tabs-wrapper >}}
After you've imported the client library, you're ready to [write data](/{{% latest "influxdb" %}}/api-guide/client-libraries/nodejs/write/?t=nodejs) to InfluxDB.
## Get started with the example app
This library includes an example browser app that writes to your InfluxDB instance.
1. Clone the [influxdb-client-js](https://github.com/influxdata/influxdb-client-js) repo.
2. Navigate to the `examples` directory:
```js
cd examples
```
3. Update `./env_browser.js` with your InfluxDB Cloud Dedicated cluster URL, your database name as `bucket`, an arbitrary string as `org`, and your database token.
4. Run the following command to start the application at [http://localhost:3001/examples/index.html]()
```sh
npm run browser
```
`index.html` loads the `env_browser.js` configuration, the client library ESM modules, and the application in your browser.

View File

@ -0,0 +1,22 @@
---
title: Node.js JavaScript client library
seotitle: Use the InfluxDB JavaScript client library
list_title: Node.js
description: >
Use the InfluxDB JavaScript client library to interact with InfluxDB.
external_url: https://github.com/influxdata/influxdb-client-js
menu:
influxdb_cloud_dedicated:
name: Node.js
parent: JavaScript
influxdb/cloud-dedicated/tags: [client libraries, JavaScript, NodeJS]
weight: 201
aliases:
- /influxdb/cloud-dedicated/reference/api/client-libraries/nodejs/
---
Use the [InfluxDB JavaScript client library](https://github.com/influxdata/influxdb-client-js) to integrate InfluxDB into Node.js and browser applications.
## Use the client library in a Node.js application
{{< children type="list">}}

View File

@ -0,0 +1,97 @@
---
title: Install the InfluxDB JavaScript client library
seotitle: Install the InfluxDB Node.js JavaScript client library
description: >
Install the Node.js JavaScript client library to interact with the InfluxDB v2 API.
menu:
influxdb_cloud_dedicated:
name: Install
parent: Node.js
influxdb/cloud-dedicated/tags: [client libraries, JavaScript]
weight: 100
aliases:
- /influxdb/cloud-dedicated/reference/api/client-libraries/nodejs/install
---
## Install Node.js
1. Install [Node.js](https://nodejs.org/en/download/package-manager/).
2. Ensure that InfluxDB is running and you can connect to it.
For information about what URL to use to connect to your InfluxDB Cloud Dedicated cluster, contact your InfluxData account representative.
3. Start a new Node.js project.
The `npm` package manager is included with Node.js.
```sh
npm init -y influx-node-app
```
## Install TypeScript
Many of the client library examples use [TypeScript](https://www.typescriptlang.org/). Follow these steps to initialize the TypeScript project.
1. Install TypeScript and type definitions for Node.js.
```sh
npm i -g typescript && npm i --save-dev @types/node
```
2. Create a TypeScript configuration with default values.
```sh
tsc --init
```
3. Run the TypeScript compiler. To recompile your code automatically as you make changes, pass the `watch` flag to the compiler.
```sh
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:
```sh
npm install --save @influxdata/influxdb-client
```
3. Install `@influxdata/influxdb-client-apis` for access to the InfluxDB management APIs:
```sh
npm install --save @influxdata/influxdb-client-apis
```
## Next steps
Once you've installed the Javascript client library, you're ready to [write data](/influxdb/cloud-dedicated/api-guide/client-libraries/nodejs/write/) to InfluxDB or [get started](#get-started-with-examples) with other examples from the client library.
## Get started with examples
{{% note %}}
The client examples include an [`env`](https://github.com/influxdata/influxdb-client-js/blob/master/examples/env.js) module for accessing your InfluxDB properties from environment variables or from `env.js`.
The examples use these properties to interact with the InfluxDB API.
{{% /note %}}
1. Set environment variables or update `env.js` with your InfluxDB [database](/influxdb/cloud-dedicated/admin/databases/) (bucket), organization (required, but ignored), [token](/influxdb/cloud-dedicated/admin/tokens/), and cluster URL.
```sh
export INFLUX_URL=https://cluster-id.influxdb.io
export INFLUX_TOKEN=YOUR_API_TOKEN
export INFLUX_ORG=YOUR_ORG
export INFLUX_BUCKET=YOUR_BUCKET
```
Replace the following:
- *`YOUR_API_TOKEN`*: InfluxDB database token
- *`YOUR_ORG`*: An arbitrary string (this credential is ignored)
- *`YOUR_BUCKET`*: InfluxDB database name
2. Run an example script.
```sh
query.ts
```
{{% api/v2dot0/nodejs/learn-more %}}

View File

@ -0,0 +1,16 @@
---
title: Query data with the InfluxDB JavaScript client library
description: >
Use the JavaScript client library to query data with the InfluxDB API in Node.js.
menu:
influxdb_cloud_dedicated:
name: Query
parent: Node.js
influxdb/cloud-dedicated/tags: [client libraries, JavaScript]
weight: 201
aliases:
- /influxdb/cloud-dedicated/reference/api/client-libraries/nodejs/query
---
The [InfluxDB JavaScript client library](https://github.com/influxdata/influxdb-client-js) cannot query an InfluxDB Cloud dedicated cluster.
To query your dedicated instance, use a Flight SQL client with gRPC.

View File

@ -0,0 +1,117 @@
---
title: Write data with the InfluxDB JavaScript client library
description: >
Use the JavaScript client library to write data with the InfluxDB API in Node.js.
menu:
influxdb_cloud_dedicated:
name: Write
parent: Node.js
influxdb/cloud-dedicated/tags: [client libraries, JavaScript]
weight: 101
aliases:
- /influxdb/cloud-dedicated/reference/api/client-libraries/nodejs/write
related:
- /influxdb/cloud-dedicated/write-data/troubleshoot/
---
Use the [InfluxDB Javascript client library](https://github.com/influxdata/influxdb-client-js) to write data from a Node.js environment to InfluxDB.
The Javascript client library includes the following convenient features for writing data to InfluxDB:
- Apply default tags to data points.
- Buffer points into batches to optimize data transfer.
- Automatically retry requests on failure.
- Set an optional HTTP proxy address for your network.
### Before you begin
- [Install the client library and other dependencies](/influxdb/cloud-dedicated/api-guide/client-libraries/nodejs/install/).
### Write data with the client library
1. Instantiate an `InfluxDB` client. Provide your InfluxDB URL and API token.
```js
import {InfluxDB, Point} from '@influxdata/influxdb-client'
const influxDB = new InfluxDB({YOUR_URL, YOUR_API_TOKEN})
```
Replace the following:
- *`YOUR_URL`*: InfluxDB Cloud Dedicated cluster URL
- *`YOUR_API_TOKEN`*: InfluxDB database token
2. Use the `getWriteApi()` method of the client to create a **write client**.
Provide your InfluxDB organization ID and bucket name.
```js
const writeApi = influxDB.getWriteApi(YOUR_ORG, YOUR_BUCKET)
```
Replace the following:
- *`YOUR_ORG`*: Arbitrary string (ignored by InfluxDB, but required for the method)
- *`YOUR_BUCKET`*: InfluxDB database name
3. To apply one or more [tags](/influxdb/cloud-dedicated/reference/glossary/#tag) to all points, use the `useDefaultTags()` method.
Provide tags as an object of key/value pairs.
```js
writeApi.useDefaultTags({region: 'west'})
```
4. Use the `Point()` constructor to create a [point](/influxdb/cloud-dedicated/reference/glossary/#point).
1. Call the constructor and provide a [measurement](/influxdb/cloud-dedicated/reference/glossary/#measurement).
2. To add one or more tags, chain the `tag()` method to the constructor.
Provide a `name` and `value`.
3. To add a field of type `float`, chain the `floatField()` method to the constructor.
Provide a `name` and `value`.
```js
const point1 = new Point('temperature')
.tag('sensor_id', 'TLM010')
.floatField('value', 24)
```
5. Use the `writePoint()` method to write the point to your InfluxDB bucket.
Finally, use the `close()` method to flush all pending writes.
The example logs the new data point followed by "WRITE FINISHED" to stdout.
```js
writeApi.writePoint(point1)
writeApi.close().then(() => {
console.log('WRITE FINISHED')
})
```
### Complete example
{{< code-tabs-wrapper >}}
{{% code-tabs %}}
[Curl](#curl)
[Node.js](#nodejs)
{{% /code-tabs %}}
{{% code-tab-content %}}
```sh
{{< get-shared-text "api/v2.0/write/write.sh" >}}
```
{{% /code-tab-content %}}
{{% code-tab-content %}}
```js
{{< get-shared-text "api/v2.0/write/write.mjs" >}}
```
{{% /code-tab-content %}}
{{< /code-tabs-wrapper >}}
To run the example from a file, set your InfluxDB environment variables and use `node` to execute the JavaScript file.
```sh
export INFLUX_URL=https://cluster-id.influxdb.io && \
export INFLUX_TOKEN=YOUR_DATABASE_TOKEN && \
export INFLUX_ORG=YOUR_ORG && \
export INFLUX_BUCKET=YOUR_DATABASE_NAME && \
node write.js
```
### Response codes
_For information about **InfluxDB API response codes**, see
[InfluxDB API Write documentation](/influxdb/cloud/api/#operation/PostWrite)._

View File

@ -0,0 +1,20 @@
---
title: Kotlin client library
seotitle: Use the Kotlin client library
list_title: Kotlin
description: Use the InfluxDB Kotlin client library to interact with InfluxDB.
external_url: https://github.com/influxdata/influxdb-client-java/tree/master/client-kotlin
menu:
influxdb_cloud_dedicated:
name: Kotlin
parent: v2 client libraries
params:
url: https://github.com/influxdata/influxdb-client-java/tree/master/client-kotlin
weight: 201
---
Kotlin is an open-source programming language that runs on the Java Virtual Machine (JVM).
The documentation for this client library is available on GitHub.
<a href="https://github.com/influxdata/influxdb-client-java/tree/master/client-kotlin" target="_blank" class="btn github">Kotlin InfluxDB client</a>

View File

@ -0,0 +1,20 @@
---
title: PHP client library
seotitle: Use the InfluxDB PHP client library
list_title: PHP
description: Use the InfluxDB PHP client library to interact with InfluxDB.
external_url: https://github.com/influxdata/influxdb-client-php
menu:
influxdb_cloud_dedicated:
name: PHP
parent: v2 client libraries
params:
url: https://github.com/influxdata/influxdb-client-php
weight: 201
---
PHP is a popular general-purpose scripting language primarily used for web development.
The documentation for this client library is available on GitHub.
<a href="https://github.com/influxdata/influxdb-client-php" target="_blank" class="btn github">PHP InfluxDB client</a>

View File

@ -0,0 +1,109 @@
---
title: Python client library
seotitle: Use the InfluxDB Python client library
list_title: Python
description: >
Use the InfluxDB Python client library to interact with InfluxDB.
menu:
influxdb_cloud_dedicated:
name: Python
parent: v2 client libraries
influxdb/cloud-dedicated/tags: [client libraries, python]
aliases:
- /influxdb/cloud-dedicated/reference/api/client-libraries/python/
- /influxdb/cloud-dedicated/reference/api/client-libraries/python-cl-guide/
- /influxdb/cloud-dedicated/tools/client-libraries/python/
weight: 201
---
Use the [InfluxDB Python client library](https://github.com/influxdata/influxdb-client-python) to integrate InfluxDB into Python scripts and applications.
This guide presumes some familiarity with Python and InfluxDB.
If just getting started, see [Get started with InfluxDB](/influxdb/cloud-dedicated/get-started/).
## Before you begin
1. Install the InfluxDB Python library:
```sh
pip install influxdb-client
```
2. Ensure that InfluxDB is running.
If running InfluxDB locally, visit http://localhost:8086.
(If using InfluxDB Cloud, visit the URL of your InfluxDB Cloud UI.
For example: https://us-west-2-1.aws.cloud2.influxdata.com.)
## Write data to InfluxDB with Python
We are going to write some data in [line protocol](/influxdb/cloud-dedicated/reference/syntax/line-protocol/) using the Python library.
1. In your Python program, import the InfluxDB client library and use it to write data to InfluxDB.
```python
import influxdb_client
from influxdb_client.client.write_api import SYNCHRONOUS
```
2. Define a few variables with the name of your [database](/influxdb/cloud-dedicated/admin/databases/) (bucket), organization (required, but ignored), and [token](/influxdb/cloud-dedicated/admin/tokens/).
```python
bucket = "DATABASE_NAME"
org = "ignored"
token = "DATABASE_TOKEN"
# Store the URL of your InfluxDB instance
url="https://cluster-id.influxdb.io"
```
3. Instantiate the client. The `InfluxDBClient` object takes three named parameters: `url`, `org`, and `token`. Pass in the named parameters.
```python
client = influxdb_client.InfluxDBClient(
url=url,
token=token,
org=org
)
```
The `InfluxDBClient` object has a `write_api` method used for configuration.
4. Instantiate a **write client** using the `client` object and the `write_api` method. Use the `write_api` method to configure the writer object.
```python
write_api = client.write_api(write_options=SYNCHRONOUS)
```
5. Create a [point](/influxdb/cloud-dedicated/reference/glossary/#point) object and write it to InfluxDB using the `write` method of the API writer object. The write method requires three parameters: `bucket`, `org`, and `record`.
```python
p = influxdb_client.Point("my_measurement").tag("location", "Prague").field("temperature", 25.3)
write_api.write(bucket=bucket, org=org, record=p)
```
### Complete example write script
```python
import influxdb_client
from influxdb_client.client.write_api import SYNCHRONOUS
bucket = "DATABASE_NAME"
org = "ignored"
token = "DATABASE_TOKEN"
# Store the URL of your InfluxDB instance
url="https://cluster-id.influxdb.io"
client = influxdb_client.InfluxDBClient(
url=url,
token=token,
org=org
)
# Write script
write_api = client.write_api(write_options=SYNCHRONOUS)
p = influxdb_client.Point("my_measurement").tag("location", "Prague").field("temperature", 25.3)
write_api.write(bucket=bucket, org=org, record=p)
```
## Query data from InfluxDB with Python
The InfluxDB v2 Python client cannot query InfluxDB Cloud Dedicated.
To query your dedicated instance, use a Flight SQL client with gRPC.

View File

@ -0,0 +1,20 @@
---
title: R package client library
list_title: R
seotitle: Use the InfluxDB client R package
description: Use the InfluxDB client R package to interact with InfluxDB.
external_url: https://github.com/influxdata/influxdb-client-r
menu:
influxdb_cloud_dedicated:
name: R
parent: v2 client libraries
params:
url: https://github.com/influxdata/influxdb-client-r
weight: 201
---
R is a programming language and software environment for statistical analysis, reporting, and graphical representation primarily used in data science.
The documentation for this client library is available on GitHub.
<a href="https://github.com/influxdata/influxdb-client-r" target="_blank" class="btn github">R InfluxDB client</a>

View File

@ -0,0 +1,20 @@
---
title: Ruby client library
seotitle: Use the InfluxDB Ruby client library
list_title: Ruby
description: Use the InfluxDB Ruby client library to interact with InfluxDB.
external_url: https://github.com/influxdata/influxdb-client-ruby
menu:
influxdb_cloud_dedicated:
name: Ruby
parent: v2 client libraries
params:
url: https://github.com/influxdata/influxdb-client-ruby
weight: 201
---
Ruby is a highly flexible, open-source, object-oriented programming language.
The documentation for this client library is available on GitHub.
<a href="https://github.com/influxdata/influxdb-client-ruby" target="_blank" class="btn github">Ruby InfluxDB client</a>

View File

@ -0,0 +1,20 @@
---
title: Scala client library
seotitle: Use the InfluxDB Scala client library
list_title: Scala
description: Use the InfluxDB Scala client library to interact with InfluxDB.
external_url: https://github.com/influxdata/influxdb-client-java/tree/master/client-scala
menu:
influxdb_cloud_dedicated:
name: Scala
parent: v2 client libraries
params:
url: https://github.com/influxdata/influxdb-client-java/tree/master/client-scala
weight: 201
---
Scala is a general-purpose programming language that supports both object-oriented and functional programming.
The documentation for this client library is available on GitHub.
<a href="https://github.com/influxdata/influxdb-client-java/tree/master/client-scala" target="_blank" class="btn github">Scala InfluxDB client</a>

View File

@ -0,0 +1,20 @@
---
title: Swift client library
seotitle: Use the InfluxDB Swift client library
list_title: Swift
description: Use the InfluxDB Swift client library to interact with InfluxDB.
external_url: https://github.com/influxdata/influxdb-client-swift
menu:
influxdb_cloud_dedicated:
name: Swift
parent: v2 client libraries
params:
url: https://github.com/influxdata/influxdb-client-swift
weight: 201
---
Swift is a programming language created by Apple for building applications accross multiple Apple platforms.
The documentation for this client library is available on GitHub.
<a href="https://github.com/influxdata/influxdb-client-swift" target="_blank" class="btn github">Swift InfluxDB client</a>

View File

@ -0,0 +1,25 @@
---
title: InfluxDB v3 API client libraries
description: >
InfluxDB v3 client libraries work with InfluxDB powered by the IOx storage engine, including InfluxDB Cloud Serverless and Cloud Dedicated.
View the list of available client libraries.
weight: 30
menu:
influxdb_cloud_dedicated:
name: v3 client libraries
parent: Client libraries
influxdb/cloud-dedicated/tags: [client libraries, API, developer tools]
---
## Client libraries for InfluxDB v3
InfluxDB v3 client libraries work with IOx-powered InfluxDB v3, including InfluxDB Cloud Dedicated.
v3 client libraries use the InfluxDB HTTP API to write data and include [Flight SQL clients](/Users/ja/Documents/GitHub/docs-v2/content/influxdb/cloud-dedicated/reference/client-libraries/flight-sql)
for querying data stored in InfluxDB v3.
Functionality varies among client libraries.
These client libraries are in active development and may not be feature-complete.
For specifics about a client library, see the library's GitHub repository.
{{< children depth="999" description="true" >}}

View File

@ -0,0 +1,22 @@
---
title: Python client library for InfluxDB v3
list_title: Python
description: The InfluxDB v3 `pyinflux3` Python client library integrates with Python scripts and applications and provides a standalone CLI to write and query data stored in an InfluxDB Cloud Dedicated database.
external_url: https://github.com/InfluxCommunity/pyinflux3
menu:
influxdb_cloud_dedicated:
name: Python
parent: v3 client libraries
params:
url: https://github.com/InfluxCommunity/pyinflux3
identifier: pyinflux3
influxdb/cloud-dedicated/tags: [python, gRPC, SQL, Flight SQL, client libraries]
weight: 201
---
The InfluxDB v3 [`pyinflux3` Python client library](https://github.com/InfluxCommunity/pyinflux3) integrates with Python scripts and applications
and provides a standalone CLI to write and query data stored in an InfluxDB Cloud Dedicated database.
The documentation for this client library is available on GitHub.
<a href="https://github.com/InfluxCommunity/pyinflux3" target="_blank" class="btn github">pyinflux3 Python client library and CLI</a>

View File

@ -20,7 +20,7 @@ list_code_example: |
client = FlightSQLClient(host='cloud2.influxdata.com',
token='INFLUX_READ_WRITE_TOKEN',
metadata={'bucket-name': 'INFLUX_BUCKET'},
metadata={'bucket-name': 'BUCKET_NAME'},
features={'metadata-reflection': 'true'})
info = client.execute("SELECT * FROM home")
@ -204,14 +204,14 @@ and the _DB API 2_ interface to instantiate a Flight SQL client configured for a
# Instantiate a FlightSQLClient configured for your bucket
client = FlightSQLClient(host='cloud2.influxdata.com',
token='INFLUX_READ_WRITE_TOKEN',
metadata={'bucket-name': 'INFLUX_BUCKET'},
metadata={'bucket-name': 'BUCKET_NAME'},
features={'metadata-reflection': 'true'})
```
2. Replace the following configuration values:
- **`INFLUX_READ_WRITE_TOKEN`**: Your InfluxDB token with read permissions on the databases you want to query.
- **`INFLUX_BUCKET`**: The name of your InfluxDB bucket.
- **`INFLUX_READ_WRITE_TOKEN`**: An InfluxDB token with _read_ permission to the bucket.
- **`BUCKET_NAME`**: The name of the InfluxDB bucket to query.
### Execute a query
@ -232,13 +232,18 @@ from flightsql import FlightSQLClient
client = FlightSQLClient(host='cloud2.influxdata.com',
token='INFLUX_READ_WRITE_TOKEN',
metadata={'bucket-name': 'INFLUX_BUCKET'},
metadata={'bucket-name': 'BUCKET_NAME'},
features={'metadata-reflection': 'true'})
# Execute the query
info = client.execute("SELECT * FROM home")
```
Replace the following:
- **`INFLUX_READ_WRITE_TOKEN`**: An InfluxDB token with _read_ permission to the bucket.
- **`BUCKET_NAME`**: The name of the InfluxDB bucket to query.
The response contains a `flight.FlightInfo` object that contains metadata and an `endpoints: [...]` list. Each endpoint contains the following:
- A list of addresses where you can retrieve the data.
@ -268,7 +273,7 @@ from flightsql import FlightSQLClient
# Instantiate a FlightSQLClient configured for a bucket
client = FlightSQLClient(host='cloud2.influxdata.com',
token='INFLUX_READ_WRITE_TOKEN',
metadata={'bucket-name': 'INFLUX_BUCKET'},
metadata={'bucket-name': 'BUCKET_NAME'},
features={'metadata-reflection': 'true'})
# Execute the query to retrieve FlightInfo

View File

@ -93,8 +93,8 @@ The following steps use Python, `flightsql-dbapi`, and `pyarrow` to query Influx
2. Replace the following configuration values:
- **`INFLUX_READ_WRITE_TOKEN`**: Your InfluxDB token with read permissions on the databases you want to query.
- **`INFLUX_BUCKET`**: The name of your InfluxDB bucket.
- **`INFLUX_READ_WRITE_TOKEN`**: An InfluxDB token with _read_ permission to the bucket.
- **`INFLUX_BUCKET`**: The name of the InfluxDB bucket to query.
3. In your terminal, use the Python interpreter to run the file:

View File

@ -61,7 +61,7 @@ The following example shows how to use Python with `flightsql-dbapi` and `pyarro
# Instantiate a FlightSQLClient configured for a bucket
client = FlightSQLClient(host='cloud2.influxdata.com',
token='INFLUX_READ_WRITE_TOKEN',
metadata={'bucket-name': 'INFLUX_BUCKET'},
metadata={'bucket-name': 'BUCKET_NAME'},
features={'metadata-reflection': 'true'})
# Execute the query to retrieve FlightInfo
@ -79,8 +79,8 @@ The following example shows how to use Python with `flightsql-dbapi` and `pyarro
2. Replace the following configuration values:
- **`INFLUX_READ_WRITE_TOKEN`**: Your InfluxDB token with read permissions on the databases you want to query.
- **`INFLUX_BUCKET`**: The name of your InfluxDB bucket.
- **`INFLUX_READ_WRITE_TOKEN`**: An InfluxDB token with _read_ permission to the bucket.
- **`BUCKET_NAME`**: The name of the InfluxDB bucket to query.
3. In your terminal, use the Python interpreter to run the file:
@ -108,7 +108,7 @@ from flightsql import FlightSQLClient
client = FlightSQLClient(host='cloud2.influxdata.com',
token='INFLUX_READ_WRITE_TOKEN',
metadata={'bucket-name': 'INFLUX_BUCKET'},
metadata={'bucket-name': 'BUCKET_NAME'},
features={'metadata-reflection': 'true'})
info = client.execute('SELECT * FROM home')
@ -134,4 +134,9 @@ room: [["Kitchen","Living Room"]]
{{% /expand %}}
{{< /expand-wrapper >}}
Replace the following:
- **`INFLUX_READ_WRITE_TOKEN`**: An InfluxDB token with _read_ permission to the bucket.
- **`BUCKET_NAME`**: The name of the InfluxDB bucket to query.
For more detail and examples, see the [PyArrow documentation](https://arrow.apache.org/docs/python/getstarted.html) and the [Apache Arrow Python Cookbook](https://arrow.apache.org/cookbook/py/data.html).

View File

@ -0,0 +1,21 @@
---
title: InfluxDB API client libraries
description: >
InfluxDB client libraries are language-specific tools that integrate with InfluxDB APIs.
View the list of available client libraries.
list_title: API client libraries
weight: 105
aliases:
- /influxdb/cloud-serverless/reference/api/client-libraries/
- /influxdb/cloud-serverless/tools/client-libraries/
- /influxdb/cloud-serverless/api-guide/client-libraries/
menu:
influxdb_cloud_serverless:
name: Client libraries
parent: Reference
influxdb/cloud-serverless/tags: [client libraries, API, developer tools]
---
InfluxDB client libraries are language-specific packages that integrate with InfluxDB APIs.
{{< children depth="999" type="list" >}}

View File

@ -0,0 +1,20 @@
---
title: Flight SQL clients
description: >
Flight SQL clients are language-specific drivers that can interact with SQL databases using the Arrow in-memory format and the Flight RPC framework.
View the list of available clients.
weight: 30
menu:
influxdb_cloud_serverless:
name: Flight SQL clients
parent: Client libraries
influxdb/cloud-serverless/tags: [client libraries, Flight SQL]
---
Flight SQL clients are language-specific drivers that can interact with SQL databases using the Arrow in-memory format and the Flight RPC framework.
Clients provide a [`FlightClient`](https://arrow.apache.org/docs/python/generated/pyarrow.flight.FlightClient.html#pyarrow.flight.FlightClient) that can query and retrieve data from InfluxDB v3 using gRPC and Flight SQL.
Some [InfluxDB v3 client libraries](/influxdb/cloud-serverless/reference/client-libraries/v3) include Flight SQL clients.
For specifics about a client library, see the library's GitHub repository.
{{< children depth="999" description="true" >}}

View File

@ -0,0 +1,20 @@
---
title: Go Flight SQL client
description: The Go Flight SQL client integrates with golang scripts and applications to query data stored in an InfluxDB Cloud Serverless bucket.
external_url: https://pkg.go.dev/github.com/apache/arrow/go/v12/arrow/flight/flightsql
menu:
influxdb_cloud_serverless:
name: Go Flight SQL client
parent: Flight SQL clients
params:
url: https://pkg.go.dev/github.com/apache/arrow/go/v12/arrow/flight/flightsql
identifier: go-flightsql
influxdb/cloud-serverless/tags: [Golang, gRPC, SQL, Flight SQL, client libraries]
weight: 201
---
The [Go Flight SQL client](https://pkg.go.dev/github.com/apache/arrow/go/v12/arrow/flight/flightsql) integrates with golang scripts and applications to query data stored in an InfluxDB Cloud Serverless bucket.
<!--
For an example, see [Get started querying data](/influxdb/cloud-serverless/get-started/query/?t=Go#execute-a-sql-query).
-->
For more information, see the [Go client README on GitHub](https://github.com/influxdata/influxdb-client-go).

View File

@ -0,0 +1,19 @@
---
title: Python FlightSQL-DBAPI client
description: The Python `flightsql-dbapi` library integrates with Python scripts and applications to query data stored in an InfluxDB Cloud Serverless bucket.
external_url: https://github.com/influxdata/flightsql-dbapi
menu:
influxdb_cloud_serverless:
name: Python Flight SQL client
parent: Flight SQL clients
params:
url: https://github.com/influxdata/flightsql-dbapi
influxdb/cloud-serverless/tags: [Python, gRPC, SQL, Flight SQL, client libraries]
weight: 201
---
The [Python Flight SQL DBAPI library](https://github.com/influxdata/flightsql-dbapi) integrates with Python scripts and applications to query data stored in an InfluxDB Cloud Serverless bucket.
The documentation for this client library is available on GitHub.
<a href="https://github.com/influxdata/flightsql-dbapi" target="_blank" class="btn github">Python Flight SQL DBAPI library</a>

View File

@ -0,0 +1,146 @@
---
title: InfluxDB v1 client libraries
description: >
v1 client libraries work with the InfluxDB 1.7 API and should be fully compatible with InfluxDB 1.5+.
View the list of available client libraries.
menu:
influxdb_cloud_serverless:
weight: 201
name: v1 client libraries
parent: Client libraries
influxdb/cloud-serverless/tags: [client libraries, API, developer tools]
---
InfluxDB client libraries are language-specific tools that integrate with InfluxDB APIs.
Client libraries for InfluxDB v1 work with the InfluxDB 1.7 API and should be fully compatible with InfluxDB 1.5+.
{{% note %}}
We highly recommend upgrading to InfluxDB 1.8 to use new client libraries compatible with both InfluxDB 1.8 and InfluxDB 2.0. For more information, see [InfluxDB client libraries](/influxdb/v1.8/tools/api_client_libraries/).
{{% /note %}}
Functionality varies among client libraries.
These client libraries are in active development and may not be feature-complete.
For specifics about a client library, see the library's GitHub repository.
## C++
* [influxdb-cxx](https://github.com/offa/influxdb-cxx)
* Maintained by [offa](https://github.com/offa)
## Elixir
* [Instream (instream)](https://github.com/mneudert/instream)
* Maintained by [Marc Neudert (mneudert)](https://github.com/mneudert)
## Erlang
* [Erlang InfluxDB UDP Writer](https://github.com/palkan/influx_udp)
* Maintained by [Vladimir Dementyev (palkan)](https://github.com/palkan)
* [InfluxDB line encoder](https://github.com/Pouriya-Jahanbakhsh/influxdb_encoderl)
* Maintained by [Pouriya Jahanbakhsh](https://github.com/Pouriya-Jahanbakhsh)
## Go
* [InfluxDB Client](https://github.com/influxdata/influxdb1-client)
* Maintained by [InfluxData](https://github.com/influxdata)
## Haskell
* [influxdb-haskell](https://github.com/maoe/influxdb-haskell)
* Maintained by [Mitsutoshi Aoe (maoe)](https://github.com/maoe)
## Java
* [influxdb-java](https://github.com/influxdb/influxdb-java)
* Maintained by [Stefan Majer (majst01)](https://github.com/majst01)
* [Alpakka InfluxDB](https://doc.akka.io/docs/alpakka/current/influxdb.html)
* Maintained by the Alpakka community with help from [Lightbend](https://www.lightbend.com/)
* [JFlux](https://github.com/nickRm/jflux)
* Maintained by [Nick Rammos (nickRm)](https://github.com/nickRm)
## JavaScript/Node.js
* [node-influx](https://github.com/node-influx/node-influx)
* Maintained by [Ben Evans (bencevans)](https://github.com/bencevans) and [Connor Peet (connor4312)](https://github.com/connor4312)
## Lisp
* [CL-INFLUXDB](https://github.com/mmaul/cl-influxdb)
* Maintained by [Mike Maul (mmaul)](https://github.com/mmaul)
## MATLAB
* [influxdb-matlab](https://github.com/EnricSala/influxdb-matlab)
* Maintained by [Enric Sala (EnricSala)](https://github.com/EnricSala)
## .Net
* [InfluxDB.Client.Net](https://github.com/AdysTech/InfluxDB.Client.Net)
* Maintained by [Adarsha (mvadu)](https://github.com/mvadu)
* Supports .Net and .Net Core
* [InfluxData.Net](https://github.com/pootzko/InfluxData.Net)
* Maintained by [Tijhomir Kit (pootzko)](https://github.com/pootzko)
* [InfluxDB Client for .NET](https://github.com/MikaelGRA/InfluxDB.Client)
* Maintained by [Mikael Guldborg Rask Andersen (MikaelGRA)](https://github.com/MikaelGRA)
* [InfluxClient](https://github.com/danesparza/InfluxClient)
* Maintained by [Dan Esparza (danesparza)](https://github.com/danesparza)
## Perl
* [AnyEvent::InfluxDB](https://github.com/ajgb/anyevent-influxdb)
 * Maintained by [Alex Burzyński (ajgb)](https://github.com/ajgb)
* [InfluxDB-LineProtocol](http://search.cpan.org/~domm/InfluxDB-LineProtocol/)
* Maintained by [Thomas Klausner (domm)](https://domm.plix.at/)
* [InfluxDB::HTTP](https://github.com/raphaelthomas/InfluxDB-HTTP)
* Maintained by [Raphael Seebacher (raphaelthomas)](https://github.com/raphaelthomas)
## PHP
* [influxdb-php](https://github.com/influxdb/influxdb-php)
* Maintained by [TheCodeAssassin (thecodeassassin)](https://github.com/thecodeassassin) and [Gianluca Arbezzano (gianarb)](https://github.com/gianarb)
* [InfluxDB PHP SDK (influxdb-php-sdk)](https://github.com/corley/influxdb-php-sdk)
* Maintained by [Corley (corley)](https://github.com/corley)
## Python
* [InfluxDB-Python (influxdb-python)](https://github.com/influxdb/influxdb-python)
* Maintained by [Alexandre Viau (aviau)](https://github.com/aviau), [xginn8](https://github.com/xginn8), and [Sebastian Borza (sebito91)](https://github.com/sebito91)
## R
* [influxdbr](https://cran.r-project.org/web/packages/influxdbr/)
* Maintained by [Dominik Leutnant (dleutant)](https://github.com/dleutnant)
## Ruby
* [influxdb-ruby](https://github.com/influxdb/influxdb-ruby)
* Maintained by [Todd Persen (toddboom)](https://github.com/toddboom) and [Dominik Menke (dmke)](https://github.com/dmke).
* [Influxer (influxer)](https://github.com/palkan/influxer)
* Maintained by [Vladimir Dementyev (palkan)](https://github.com/palkan).
## Rust
* [Flux (flux)](https://crates.io/crates/flux)
* Maintained by [Chris Holcombe (cholcombe973)](https://crates.io/users/cholcombe973) and [Chris MacNaughton](https://crates.io/users/ChrisMacNaughton)
* [Influent (influent)](https://crates.io/crates/influent)
* Maintained by [gobwas](https://crates.io/users/gobwas) and [Eijebong](https://crates.io/users/Eijebong).
## Scala
* [scala-influxdb-client](https://github.com/paulgoldbaum/scala-influxdb-client)
* Maintained by [Paul Goldbaum (paulgoldbaum)](https://github.com/paulgoldbaum)
* [chronicler](https://github.com/fsanaulla/chronicler)
* Maintained by [Faiaz Sanaulla (fsanaulla)](https://github.com/fsanaulla)
* [Alpakka InfluxDB](https://doc.akka.io/docs/alpakka/current/influxdb.html)
* Maintained by the Alpakka community with help from [Lightbend](https://www.lightbend.com/)
## Sensu
* [sensu-influxdb-extension](https://github.com/jhrv/sensu-influxdb-extension)
* Maintained by [Johnny Horvi (jhrv)](https://github.com/jhrv)
## SNMP agent
* [SnmpCollector (snmpcollector)](https://github.com/toni-moreno/snmpcollector)
* Maintained by [Toni Moreno (toni-moreno)](https://github.com/toni-moreno).
* A full featured Generic SNMP data collector with Web Administration Interface for InfluxDB.

View File

@ -0,0 +1,24 @@
---
title: InfluxDB v2 API client libraries
description: >
InfluxDB v2 client libraries use InfluxDB `/api/v2` endpoints and work with [InfluxDB 2.0 API compatibility endpoints](/{{< latest "influxdb" "v1" >}}/tools/api/#influxdb-20-api-compatibility-endpoints).
View the list of available client libraries.
weight: 101
menu:
influxdb_cloud_serverless:
name: v2 client libraries
parent: Client libraries
influxdb/cloud-serverless/tags: [client libraries, API, developer tools]
---
## Client libraries for InfluxDB 2.x and 1.8+
InfluxDB client libraries are language-specific tools that integrate with InfluxDB APIs.
InfluxDB v2 client libraries use InfluxDB `/api/v2` endpoints and work with [InfluxDB 2.0 API compatibility endpoints](/{{< latest "influxdb" "v1" >}}/tools/api/#influxdb-20-api-compatibility-endpoints).
Functionality varies among client libraries.
These client libraries are in active development and may not be feature-complete.
For specifics about a client library, see the library's GitHub repository.
{{< children depth="999" type="list" >}}

View File

@ -0,0 +1,21 @@
---
title: Arduino client library
seotitle: Use the InfluxDB Arduino client library
list_title: Arduino
description: Use the InfluxDB Arduino client library to interact with InfluxDB.
external_url: https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino
list_note: _ contributed by [tobiasschuerg](https://github.com/tobiasschuerg)_
menu:
influxdb_cloud_serverless:
name: Arduino
parent: v2 client libraries
params:
url: https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino
weight: 201
---
Arduino is an open-source hardware and software platform used for building electronics projects.
The documentation for this client library is available on GitHub.
<a href="https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino" target="_blank" class="btn github">Arduino InfluxDB client</a>

View File

@ -0,0 +1,20 @@
---
title: C# client library
list_title: C#
seotitle: Use the InfluxDB C# client library
description: Use the InfluxDB C# client library to interact with InfluxDB.
external_url: https://github.com/influxdata/influxdb-client-csharp
menu:
influxdb_cloud_serverless:
name: C#
parent: v2 client libraries
params:
url: https://github.com/influxdata/influxdb-client-csharp
weight: 201
---
C# is a general-purpose object-oriented programming language.
The documentation for this client library is available on GitHub.
<a href="https://github.com/influxdata/influxdb-client-csharp" target="_blank" class="btn github">C# InfluxDB client</a>

View File

@ -0,0 +1,20 @@
---
title: Dart client library
list_title: Dart
seotitle: Use the InfluxDB Dart client library
description: Use the InfluxDB Dart client library to interact with InfluxDB.
external_url: https://github.com/influxdata/influxdb-client-dart
menu:
influxdb_cloud_serverless:
name: Dart
parent: v2 client libraries
params:
url: https://github.com/influxdata/influxdb-client-dart
weight: 201
---
Dart is a programming language created for quick application development for both web and mobile apps.
The documentation for this client library is available on GitHub.
<a href="https://github.com/influxdata/influxdb-client-dart" target="_blank" class="btn github">Dart InfluxDB client</a>

View File

@ -0,0 +1,121 @@
---
title: Go client library
seotitle: Use the InfluxDB Go client library
list_title: Go
description: >
Use the InfluxDB Go client library to interact with InfluxDB.
menu:
influxdb_cloud_serverless:
name: Go
parent: v2 client libraries
influxdb/cloud-serverless/tags: [client libraries, Go]
weight: 201
aliases:
- /influxdb/cloud-serverless/reference/api/client-libraries/go/
- /influxdb/cloud-serverless/tools/client-libraries/go/
---
Use the [InfluxDB Go client library](https://github.com/influxdata/influxdb-client-go) to integrate InfluxDB into Go scripts and applications.
This guide presumes some familiarity with Go and InfluxDB.
If just getting started, see [Get started with InfluxDB](/influxdb/cloud-serverless/get-started/).
## Before you begin
1. [Install Go 1.13 or later](https://golang.org/doc/install).
2. Add the client package your to your project dependencies.
```sh
# Add InfluxDB Go client package to your project go.mod
go get github.com/influxdata/influxdb-client-go/v2
```
3. Ensure that InfluxDB is running and you can connect to it.
For information about what URL to use to connect to InfluxDB Cloud, see [InfluxDB URLs](/influxdb/cloud-serverless/reference/urls/).
## Boilerplate for the InfluxDB Go Client Library
Use the Go library to write and query data from InfluxDB.
1. In your Go program, import the necessary packages and specify the entry point of your executable program.
```go
package main
import (
"context"
"fmt"
"time"
"github.com/influxdata/influxdb-client-go/v2"
)
```
2. Define variables for your InfluxDB [bucket](/influxdb/cloud-serverless/organizations/buckets/), [organization](/influxdb/cloud-serverless/organizations/), and [token](/influxdb/cloud-serverless/security/tokens/).
```go
bucket := "example-bucket"
org := "example-org"
token := "example-token"
// Store the URL of your InfluxDB instance
url := "https://cloud2.influxdata.com"
```
3. Create the the InfluxDB Go client and pass in the `url` and `token` parameters.
```go
client := influxdb2.NewClient(url, token)
```
4. Create a **write client** with the `WriteAPIBlocking` method and pass in the `org` and `bucket` parameters.
```go
writeAPI := client.WriteAPIBlocking(org, bucket)
```
5. To query data, create an InfluxDB **query client** and pass in your InfluxDB `org`.
```go
queryAPI := client.QueryAPI(org)
```
## Write data to InfluxDB with Go
Use the Go library to write data to InfluxDB.
1. Create a [point](/influxdb/cloud-serverless/reference/glossary/#point) and write it to InfluxDB using the `WritePoint` method of the API writer struct.
2. Close the client to flush all pending writes and finish.
```go
p := influxdb2.NewPoint("stat",
map[string]string{"unit": "temperature"},
map[string]interface{}{"avg": 24.5, "max": 45},
time.Now())
writeAPI.WritePoint(context.Background(), p)
client.Close()
```
### Complete example write script
```go
func main() {
bucket := "example-bucket"
org := "example-org"
token := "example-token"
// Store the URL of your InfluxDB instance
url := "https://cloud2.influxdata.com"
// Create new client with default option for server url authenticate by token
client := influxdb2.NewClient(url, token)
// User blocking write client for writes to desired bucket
writeAPI := client.WriteAPIBlocking(org, bucket)
// Create point using full params constructor
p := influxdb2.NewPoint("stat",
map[string]string{"unit": "temperature"},
map[string]interface{}{"avg": 24.5, "max": 45},
time.Now())
// Write point immediately
writeAPI.WritePoint(context.Background(), p)
// Ensures background processes finishes
client.Close()
}
```

View File

@ -0,0 +1,20 @@
---
title: Java client library
seotitle: Use the InfluxDB Java client library
list_title: Java
description: Use the Java client library to interact with InfluxDB.
external_url: https://github.com/influxdata/influxdb-client-java
menu:
influxdb_cloud_serverless:
name: Java
parent: v2 client libraries
params:
url: https://github.com/influxdata/influxdb-client-java
weight: 201
---
Java is one of the oldest and most popular class-based, object-oriented programming languages.
The documentation for this client library is available on GitHub.
<a href="https://github.com/influxdata/influxdb-client-java" target="_blank" class="btn github">Java InfluxDB client</a>

View File

@ -0,0 +1,20 @@
---
title: JavaScript client library for the InfluxDB v2 API
seotitle: Use the InfluxDB JavaScript client library for the InfluxDB v2 API
list_title: JavaScript
description: >
Use the InfluxDB JavaScript client library to interact with InfluxDB 2.x and the InfluxDB v2 API.
external_url: https://github.com/influxdata/influxdb-client-js
menu:
influxdb_cloud_serverless:
name: JavaScript
parent: v2 client libraries
influxdb/cloud-serverless/tags: [client libraries, JavaScript, NodeJS]
weight: 201
aliases:
- /influxdb/cloud-serverless/reference/api/client-libraries/js/
---
Use the [InfluxDB JavaScript client library](https://github.com/influxdata/influxdb-client-js) to integrate InfluxDB into Node.js and browser applications.
{{< children type="list">}}

View File

@ -0,0 +1,119 @@
---
title: JavaScript client library for web browsers
seotitle: Use the InfluxDB JavaScript client library for web browsers
list_title: JavaScript for browsers
description: >
Use the InfluxDB JavaScript client library to interact with InfluxDB in web clients.
menu:
influxdb_cloud_serverless:
name: Browsers and web clients
identifier: client_js_browsers
parent: JavaScript
influxdb/cloud-serverless/tags: [client libraries, JavaScript]
weight: 201
aliases:
- /influxdb/cloud-serverless/api-guide/client-libraries/browserjs/write
- /influxdb/cloud-serverless/api-guide/client-libraries/browserjs/query
related:
- /influxdb/cloud-serverless/api-guide/client-libraries/nodejs/write/
- /influxdb/cloud-serverless/api-guide/client-libraries/nodejs/query/
---
Use the [InfluxDB JavaScript client library](https://github.com/influxdata/influxdb-client-js) to interact with the InfluxDB v2 API in browsers and front-end clients. This library supports both front-end and server-side environments and provides the following distributions:
* ECMAScript modules (ESM) and CommonJS modules (CJS)
* Bundled ESM
* Bundled UMD
This guide presumes some familiarity with JavaScript, browser environments, and InfluxDB.
If you're just getting started with InfluxDB, see [Get started with InfluxDB](/{{% latest "influxdb" %}}/get-started/).
{{% warn %}}
### Tokens in production applications
{{% api/browser-token-warning %}}
{{% /warn %}}
* [Before you begin](#before-you-begin)
* [Use with module bundlers](#use-with-module-bundlers)
* [Use bundled distributions with browsers and module loaders](#use-bundled-distributions-with-browsers-and-module-loaders)
* [Get started with the example app](#get-started-with-the-example-app)
## Before you begin
1. Install [Node.js](https://nodejs.org/en/download/package-manager/) to serve your front-end app.
2. Ensure that InfluxDB is running and you can connect to it.
For information about what URL to use to connect to InfluxDB Cloud, see [InfluxDB URLs](/{{% latest "influxdb" %}}/reference/urls/).
## Use with module bundlers
If you use a module bundler like Webpack or Parcel, install `@influxdata/influxdb-client-browser`.
For more information and examples, see [Node.js](/{{% latest "influxdb" %}}/api-guide/client-libraries/nodejs/).
## Use bundled distributions with browsers and module loaders
1. Configure InfluxDB properties for your script.
```html
<script>
window.INFLUX_ENV = {
url: 'http://localhost:8086',
token: 'INFLUX_READ_WRITE_TOKEN'
}
</script>
```
Replace the following:
- **`INFLUX_READ_WRITE_TOKEN`**: An InfluxDB token with _write_ permission to the bucket.
2. Import modules from the latest client library browser distribution.
`@influxdata/influxdb-client-browser` exports bundled ESM and UMD syntaxes.
{{< code-tabs-wrapper >}}
{{% code-tabs %}}
[ESM](#import-esm)
[UMD](#import-umd)
{{% /code-tabs %}}
{{% code-tab-content %}}
```html
<script type="module">
import {InfluxDB, Point} from 'https://unpkg.com/@influxdata/influxdb-client-browser/dist/index.browser.mjs'
const influxDB = new InfluxDB({INFLUX_ENV.url, INFLUX_ENV.token})
</script>
```
{{% /code-tab-content %}}
{{% code-tab-content %}}
```html
<script src="https://unpkg.com/@influxdata/influxdb-client-browser"></script>
<script>
const Influx = window['@influxdata/influxdb-client']
const InfluxDB = Influx.InfluxDB
const influxDB = new InfluxDB({INFLUX_ENV.url, INFLUX_ENV.token})
</script>
```
{{% /code-tab-content %}}
{{< /code-tabs-wrapper >}}
After you've imported the client library, you're ready to [write data](/{{% latest "influxdb" %}}/api-guide/client-libraries/nodejs/write/?t=nodejs) to InfluxDB.
## Get started with the example app
This library includes an example browser app that queries from and writes to your InfluxDB instance.
1. Clone the [influxdb-client-js](https://github.com/influxdata/influxdb-client-js) repo.
2. Navigate to the `examples` directory:
```js
cd examples
```
3. Update `./env_browser.js` with your InfluxDB [url](/{{% latest "influxdb" %}}/reference/urls/), [bucket](/{{% latest "influxdb" %}}/organizations/buckets/), [organization](/{{% latest "influxdb" %}}/organizations/), and [token](/{{% latest "influxdb" %}}/security/tokens/)
4. Run the following command to start the application at [http://localhost:3001/examples/index.html]()
```sh
npm run browser
```
`index.html` loads the `env_browser.js` configuration, the client library ESM modules, and the application in your browser.

View File

@ -0,0 +1,22 @@
---
title: Node.js JavaScript client library
seotitle: Use the InfluxDB JavaScript client library
list_title: Node.js
description: >
Use the InfluxDB JavaScript client library to interact with InfluxDB.
external_url: https://github.com/influxdata/influxdb-client-js
menu:
influxdb_cloud_serverless:
name: Node.js
parent: JavaScript
influxdb/cloud-serverless/tags: [client libraries, JavaScript, NodeJS]
weight: 201
aliases:
- /influxdb/cloud-serverless/reference/api/client-libraries/nodejs/
---
Use the [InfluxDB JavaScript client library](https://github.com/influxdata/influxdb-client-js) to integrate InfluxDB into Node.js and browser applications.
## Use the client library in a Node.js application
{{< children type="list">}}

View File

@ -0,0 +1,99 @@
---
title: Install the InfluxDB JavaScript client library
seotitle: Install the InfluxDB Node.js JavaScript client library
description: >
Install the Node.js JavaScript client library to interact with the InfluxDB v2 API.
menu:
influxdb_cloud_serverless:
name: Install
parent: Node.js
influxdb/cloud-serverless/tags: [client libraries, JavaScript]
weight: 100
aliases:
- /influxdb/cloud-serverless/reference/api/client-libraries/nodejs/install
---
## Install Node.js
1. Install [Node.js](https://nodejs.org/en/download/package-manager/).
2. Ensure that InfluxDB is running and you can connect to it.
For information about what URL to use to connect to InfluxDB Cloud, see [InfluxDB URLs](/influxdb/cloud-serverless/reference/urls/).
3. Start a new Node.js project.
The `npm` package manager is included with Node.js.
```sh
npm init -y influx-node-app
```
## Install TypeScript
Many of the client library examples use [TypeScript](https://www.typescriptlang.org/). Follow these steps to initialize the TypeScript project.
1. Install TypeScript and type definitions for Node.js.
```sh
npm i -g typescript && npm i --save-dev @types/node
```
2. Create a TypeScript configuration with default values.
```sh
tsc --init
```
3. Run the TypeScript compiler. To recompile your code automatically as you make changes, pass the `watch` flag to the compiler.
```sh
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:
```sh
npm install --save @influxdata/influxdb-client
```
3. Install `@influxdata/influxdb-client-apis` for access to the InfluxDB management APIs:
```sh
npm install --save @influxdata/influxdb-client-apis
```
## Next steps
Once you've installed the Javascript client library, you're ready to [write data](/influxdb/cloud-serverless/api-guide/client-libraries/nodejs/write/) to InfluxDB or [get started](#get-started-with-examples) with other examples from the client library.
## Get started with examples
{{% note %}}
The client examples include an [`env`](https://github.com/influxdata/influxdb-client-js/blob/master/examples/env.js) module for accessing your InfluxDB properties from environment variables or from `env.js`.
The examples use these properties to interact with the InfluxDB API.
{{% /note %}}
1. Set environment variables or update `env.js` with your InfluxDB [bucket](/influxdb/cloud-serverless/organizations/buckets/), [organization](/influxdb/cloud-serverless/organizations/), [token](/influxdb/cloud-serverless/security/tokens/), and [url](/influxdb/cloud-serverless/reference/urls/).
```sh
export INFLUX_URL=https://cloud2.influxdata.com
export INFLUX_TOKEN=INFLUX_READ_WRITE_TOKEN
export INFLUX_ORG=ORG_ID
export INFLUX_BUCKET=BUCKET_NAME
```
Replace the following:
- *`INFLUX_READ_WRITE_TOKEN`*: InfluxDB token with _write_ permission to the bucket.
- *`ORG_ID`*: InfluxDB organization ID
- *`BUCKET_NAME`*: The name of the InfluxDB bucket to write to.
2. Run an example script.
```sh
query.ts
```
{{% api/v2dot0/nodejs/learn-more %}}

View File

@ -0,0 +1,116 @@
---
title: Write data with the InfluxDB JavaScript client library
description: >
Use the JavaScript client library to write data with the InfluxDB API in Node.js.
menu:
influxdb_cloud_serverless:
name: Write
parent: Node.js
influxdb/cloud-serverless/tags: [client libraries, JavaScript]
weight: 101
aliases:
- /influxdb/cloud-serverless/reference/api/client-libraries/nodejs/write
related:
- /influxdb/cloud-serverless/write-data/troubleshoot/
---
Use the [InfluxDB Javascript client library](https://github.com/influxdata/influxdb-client-js) to write data from a Node.js environment to InfluxDB.
The Javascript client library includes the following convenient features for writing data to InfluxDB:
- Apply default tags to data points.
- Buffer points into batches to optimize data transfer.
- Automatically retry requests on failure.
- Set an optional HTTP proxy address for your network.
### Before you begin
- [Install the client library and other dependencies](/influxdb/cloud-serverless/api-guide/client-libraries/nodejs/install/).
### Write data with the client library
1. Instantiate an `InfluxDB` client. Provide your InfluxDB URL and API token.
```js
import {InfluxDB, Point} from '@influxdata/influxdb-client'
const influxDB = new InfluxDB({YOUR_URL, YOUR_API_TOKEN})
```
Replace the following:
- *`YOUR_URL`*: InfluxDB URL
- *`YOUR_API_TOKEN`*: InfluxDB API token
2. Use the `getWriteApi()` method of the client to create a **write client**.
Provide your InfluxDB organization ID and bucket name.
```js
const writeApi = influxDB.getWriteApi(YOUR_ORG, YOUR_BUCKET)
```
Replace the following:
- *`YOUR_ORG`*: InfluxDB organization ID
- *`YOUR_BUCKET`*: InfluxDB bucket name
3. To apply one or more [tags](/influxdb/cloud-serverless/reference/glossary/#tag) to all points, use the `useDefaultTags()` method.
Provide tags as an object of key/value pairs.
```js
writeApi.useDefaultTags({region: 'west'})
```
4. Use the `Point()` constructor to create a [point](/influxdb/cloud-serverless/reference/glossary/#point).
1. Call the constructor and provide a [measurement](/influxdb/cloud-serverless/reference/glossary/#measurement).
2. To add one or more tags, chain the `tag()` method to the constructor.
Provide a `name` and `value`.
3. To add a field of type `float`, chain the `floatField()` method to the constructor.
Provide a `name` and `value`.
```js
const point1 = new Point('temperature')
.tag('sensor_id', 'TLM010')
.floatField('value', 24)
```
5. Use the `writePoint()` method to write the point to your InfluxDB bucket.
Finally, use the `close()` method to flush all pending writes.
The example logs the new data point followed by "WRITE FINISHED" to stdout.
```js
writeApi.writePoint(point1)
writeApi.close().then(() => {
console.log('WRITE FINISHED')
})
```
### Complete example
{{< code-tabs-wrapper >}}
{{% code-tabs %}}
[Node.js](#nodejs)
{{% /code-tabs %}}
{{% code-tab-content %}}
```js
{{< get-shared-text "api/v2.0/write/write.mjs" >}}
```
{{% /code-tab-content %}}
{{< /code-tabs-wrapper >}}
To run the example from a file, set your InfluxDB environment variables and use `node` to execute the JavaScript file.
```sh
export INFLUX_URL=http://localhost:8086 && \
export INFLUX_TOKEN=INFLUX_READ_WRITE_TOKEN && \
export INFLUX_ORG=ORG_ID && \
export INFLUX_BUCKET=BUCKET_NAME && \
node write.js
```
Replace the following:
- *`INFLUX_READ_WRITE_TOKEN`*: InfluxDB token with _write_ permission to the bucket.
- *`ORG_ID`*: InfluxDB organization ID
- *`BUCKET_NAME`*: The name of the InfluxDB bucket to write to.
### Response codes
_For information about **InfluxDB API response codes**, see
[InfluxDB API Write documentation](/influxdb/cloud/api/#operation/PostWrite)._

View File

@ -0,0 +1,20 @@
---
title: Kotlin client library
seotitle: Use the Kotlin client library
list_title: Kotlin
description: Use the InfluxDB Kotlin client library to interact with InfluxDB.
external_url: https://github.com/influxdata/influxdb-client-java/tree/master/client-kotlin
menu:
influxdb_cloud_serverless:
name: Kotlin
parent: v2 client libraries
params:
url: https://github.com/influxdata/influxdb-client-java/tree/master/client-kotlin
weight: 201
---
Kotlin is an open-source programming language that runs on the Java Virtual Machine (JVM).
The documentation for this client library is available on GitHub.
<a href="https://github.com/influxdata/influxdb-client-java/tree/master/client-kotlin" target="_blank" class="btn github">Kotlin InfluxDB client</a>

View File

@ -0,0 +1,20 @@
---
title: PHP client library
seotitle: Use the InfluxDB PHP client library
list_title: PHP
description: Use the InfluxDB PHP client library to interact with InfluxDB.
external_url: https://github.com/influxdata/influxdb-client-php
menu:
influxdb_cloud_serverless:
name: PHP
parent: v2 client libraries
params:
url: https://github.com/influxdata/influxdb-client-php
weight: 201
---
PHP is a popular general-purpose scripting language primarily used for web development.
The documentation for this client library is available on GitHub.
<a href="https://github.com/influxdata/influxdb-client-php" target="_blank" class="btn github">PHP InfluxDB client</a>

View File

@ -0,0 +1,105 @@
---
title: Python client library
seotitle: Use the InfluxDB Python client library
list_title: Python
description: >
Use the InfluxDB Python client library to interact with InfluxDB.
menu:
influxdb_cloud_serverless:
name: Python
parent: v2 client libraries
influxdb/cloud-serverless/tags: [client libraries, python]
aliases:
- /influxdb/cloud-serverless/reference/api/client-libraries/python/
- /influxdb/cloud-serverless/reference/api/client-libraries/python-cl-guide/
- /influxdb/cloud-serverless/tools/client-libraries/python/
weight: 201
---
Use the [InfluxDB Python client library](https://github.com/influxdata/influxdb-client-python) to integrate InfluxDB into Python scripts and applications.
This guide presumes some familiarity with Python and InfluxDB.
If just getting started, see [Get started with InfluxDB](/influxdb/cloud-serverless/get-started/).
## Before you begin
1. Install the InfluxDB Python library:
```sh
pip install influxdb-client
```
2. Visit your InfluxDB URL to ensure InfluxDB is running:
```http
http://localhost:8086
```
## Write data to InfluxDB with Python
We are going to write some data in [line protocol](/influxdb/cloud-serverless/reference/syntax/line-protocol/) using the Python library.
1. In your Python program, import the InfluxDB client library and use it to write data to InfluxDB.
```python
import influxdb_client
from influxdb_client.client.write_api import SYNCHRONOUS
```
2. Define a few variables with the name of your [bucket](/influxdb/cloud-serverless/organizations/buckets/), [organization](/influxdb/cloud-serverless/organizations/), and [token](/influxdb/cloud-serverless/security/tokens/).
```python
bucket = "INFLUX_BUCKET"
org = "INFLUX_ORG"
token = "INFLUX_TOKEN"
url="http://localhost:8086"
```
3. Instantiate the client. The `InfluxDBClient` object takes three named parameters: `url`, `org`, and `token`. Pass in the named parameters.
```python
client = influxdb_client.InfluxDBClient(
url=url,
token=token,
org=org
)
```
The `InfluxDBClient` object has a `write_api` method used for configuration.
4. Instantiate a **write client** using the `client` object and the `write_api` method. Use the `write_api` method to configure the writer object.
```python
write_api = client.write_api(write_options=SYNCHRONOUS)
```
5. Create a [point](/influxdb/cloud-serverless/reference/glossary/#point) object and write it to InfluxDB using the `write` method of the API writer object. The write method requires three parameters: `bucket`, `org`, and `record`.
```python
p = influxdb_client.Point("my_measurement").tag("location", "Prague").field("temperature", 25.3)
write_api.write(bucket=bucket, org=org, record=p)
```
### Complete example write script
```python
import influxdb_client
from influxdb_client.client.write_api import SYNCHRONOUS
bucket = "<my-bucket>"
org = "<my-org>"
token = "<my-token>"
# Store the URL of your InfluxDB instance
url="http://localhost:8086"
client = influxdb_client.InfluxDBClient(
url=url,
token=token,
org=org
)
# Write script
write_api = client.write_api(write_options=SYNCHRONOUS)
p = influxdb_client.Point("my_measurement").tag("location", "Prague").field("temperature", 25.3)
write_api.write(bucket=bucket, org=org, record=p)
```

View File

@ -0,0 +1,20 @@
---
title: R package client library
list_title: R
seotitle: Use the InfluxDB client R package
description: Use the InfluxDB client R package to interact with InfluxDB.
external_url: https://github.com/influxdata/influxdb-client-r
menu:
influxdb_cloud_serverless:
name: R
parent: v2 client libraries
params:
url: https://github.com/influxdata/influxdb-client-r
weight: 201
---
R is a programming language and software environment for statistical analysis, reporting, and graphical representation primarily used in data science.
The documentation for this client library is available on GitHub.
<a href="https://github.com/influxdata/influxdb-client-r" target="_blank" class="btn github">R InfluxDB client</a>

View File

@ -0,0 +1,20 @@
---
title: Ruby client library
seotitle: Use the InfluxDB Ruby client library
list_title: Ruby
description: Use the InfluxDB Ruby client library to interact with InfluxDB.
external_url: https://github.com/influxdata/influxdb-client-ruby
menu:
influxdb_cloud_serverless:
name: Ruby
parent: v2 client libraries
params:
url: https://github.com/influxdata/influxdb-client-ruby
weight: 201
---
Ruby is a highly flexible, open-source, object-oriented programming language.
The documentation for this client library is available on GitHub.
<a href="https://github.com/influxdata/influxdb-client-ruby" target="_blank" class="btn github">Ruby InfluxDB client</a>

View File

@ -0,0 +1,20 @@
---
title: Scala client library
seotitle: Use the InfluxDB Scala client library
list_title: Scala
description: Use the InfluxDB Scala client library to interact with InfluxDB.
external_url: https://github.com/influxdata/influxdb-client-java/tree/master/client-scala
menu:
influxdb_cloud_serverless:
name: Scala
parent: v2 client libraries
params:
url: https://github.com/influxdata/influxdb-client-java/tree/master/client-scala
weight: 201
---
Scala is a general-purpose programming language that supports both object-oriented and functional programming.
The documentation for this client library is available on GitHub.
<a href="https://github.com/influxdata/influxdb-client-java/tree/master/client-scala" target="_blank" class="btn github">Scala InfluxDB client</a>

View File

@ -0,0 +1,20 @@
---
title: Swift client library
seotitle: Use the InfluxDB Swift client library
list_title: Swift
description: Use the InfluxDB Swift client library to interact with InfluxDB.
external_url: https://github.com/influxdata/influxdb-client-swift
menu:
influxdb_cloud_serverless:
name: Swift
parent: v2 client libraries
params:
url: https://github.com/influxdata/influxdb-client-swift
weight: 201
---
Swift is a programming language created by Apple for building applications accross multiple Apple platforms.
The documentation for this client library is available on GitHub.
<a href="https://github.com/influxdata/influxdb-client-swift" target="_blank" class="btn github">Swift InfluxDB client</a>

View File

@ -0,0 +1,25 @@
---
title: InfluxDB v3 API client libraries
description: >
InfluxDB v3 client libraries work with InfluxDB powered by the IOx storage engine.
View the list of available client libraries.
weight: 30
menu:
influxdb_cloud_serverless:
name: v3 client libraries
parent: Client libraries
influxdb/cloud-serverless/tags: [client libraries, API, developer tools]
---
## Client libraries for InfluxDB v3
InfluxDB v3 client libraries work with IOx-powered InfluxDB v3, including InfluxDB Cloud Serverless.
v3 Client libraries use the InfluxDB HTTP API to write data and include [Flight SQL clients](/Users/ja/Documents/GitHub/docs-v2/content/influxdb/cloud-dedicated/reference/client-libraries/flight-sql)
for querying data stored in InfluxDB v3.
Functionality varies among client libraries.
These client libraries are in active development and may not be feature-complete.
For specifics about a client library, see the library's GitHub repository.
{{< children depth="999" description="true" >}}

View File

@ -0,0 +1,22 @@
---
title: Python client library for InfluxDB v3
list_title: Python
description: The InfluxDB v3 `pyinflux3` Python client library integrates with Python scripts and applications and provides a standalone CLI to write and query data stored in an InfluxDB Cloud Serverless bucket.
external_ur: https://github.com/InfluxCommunity/pyinflux3
menu:
influxdb_cloud_serverless:
name: Python
parent: v3 client libraries
identifier: pyinflux3
params:
url: https://github.com/InfluxCommunity/pyinflux3
weight: 201
influxdb/cloud-serverless/tags: [python, gRPC, SQL, Flight SQL, client libraries]
---
The InfluxDB v3 [`pyinflux3` Python client library](https://github.com/InfluxCommunity/pyinflux3) integrates with Python scripts and applications
and provides a standalone CLI to write and query data stored in an InfluxDB Cloud Serverless bucket.
The documentation for this client library is available on GitHub.
<a href="https://github.com/InfluxCommunity/pyinflux3" target="_blank" class="btn github">pyinflux3 Python client library and CLI</a>