InfluxDB Docs

http.get() function

The http.get() function submits an HTTP GET request to the specified URL and returns the HTTP status code, response body, and response headers.

Function type: Miscellaneous

The http.get() function is currently experimental and subject to change at any time. By using this function, you accept the risks of experimental functions.

import "experimental/http"

http.get(
  url: "http://localhost:9999/",
  headers: {x:"a", y:"b", z:"c"},
  timeout: 30s
)

Parameters

url

The URL to send the GET request to.

Data type: String

headers

Headers to include with the GET request.

Data type: Object

timeout

Timeout for the GET request. Default is 30s.

Data type: Duration

Response format

http.get returns an object that contains the following:

statusCode

The HTTP status code returned by the GET request.

Data type: Integer

body

The response body.

Data type: Byte Array

headers

Headers included with the response.

Data type: Object

Examples

Get the status of InfluxDB
import "influxdata/influxdb/secrets"
import "experimental/http"

token = secrets.get(key: "READONLY_TOKEN")

response = http.get(
    url: "http://localhost.com:9999/health",
    headers: {Authorization: "Token ${token}"}
  )

httpStatus = response.statusCode
responseBody = string(v: response.body)
responseHeaders = response.headers