Go and InfluxDB

Use This InfluxDB Integration for Free

Build IoT, analytics, and cloud applications using the Go client library with InfluxDB.

Why use the InfluxDB Go Client Library?

InfluxDB is an API-first time series database for your Go lang applications. Use the InfluxDB open-source Go API client to write and query data and even manage your InfluxDB instance from within your application.

Key features

  • Provides API access to all InfluxDB Write and Read functionality, settings, and advanced features like managing your instance,
  • Write data in InfluxDB line protocol or point data structure
  • Write data both asynchronously or synchronously
  • Automatically retry requests on failure
  • Parameterized queries (InfluxDB Cloud only)
  • Checking the state of your server
    • Health - Detailed info about the server status, along with version string (OSS)
    • Ready - Server uptime info (OSS)
    • Ping - Whether a server is up

Get started

Getting Started with Go and InfluxDB

This tutorial shows you how to use the InfluxDB Go client library, create a connection to the database and store and query data from it.

Learn more

Getting Started with the InfluxDB Go Client

Looking to build an application with a fast way to fetch data concurrently with an easy binary deploy? Then use the InfluxDB Go Client.

Learn more

Read

Write


package main

import (
	"context"
	"fmt"

	influxdb2 "github.com/influxdata/influxdb-client-go/v2"
)

func main() {
	url := "https://us-west-2-1.aws.cloud2.influxdata.com"
	token := "my-token"
	org := "my-org"
	bucket := "my-bucket"

	client := influxdb2.NewClient(url, token)
	queryAPI := client.QueryAPI(org)
	query := fmt.Sprintf(`from(bucket: "%v") |> range(start: -1d)`, bucket)
	result, err := queryAPI.Query(context.Background(), query)
	if err != nil {
		panic(err)
	}
	for result.Next() {
		record := result.Record()
		fmt.Printf("%v %v: %v=%v\n", record.Time(), record.Measurement(), record.Field(), record.Value())
	}
	client.Close()
}

For more information, please check out the documentation.

Project URL   Documentation for Go client library

Related resources

InfluxDb-cloud-logo

The most powerful time series
database as a service

Get Started for Free
Influxdbu

Developer Education

Training for time series app developers.

View All Education