diff --git a/api-docs/influxdb/v2/.config.yml b/api-docs/influxdb/v2/.config.yml index c99715a57..c0b0b9205 100644 --- a/api-docs/influxdb/v2/.config.yml +++ b/api-docs/influxdb/v2/.config.yml @@ -10,7 +10,5 @@ apis: root: v2/ref.yml x-influxdata-docs-aliases: - /influxdb/v2/api/ - v1-compatibility@2: - root: v1-compatibility/swaggerV1Compat.yml - x-influxdata-docs-aliases: + - /influxdb/v2/api/v1-compatibility/ - /influxdb/v2/api/v1/ diff --git a/api-docs/influxdb/v2/v2/content/tag-groups.yml b/api-docs/influxdb/v2/v2/content/tag-groups.yml index 7fcd8cc8d..905c380ef 100644 --- a/api-docs/influxdb/v2/v2/content/tag-groups.yml +++ b/api-docs/influxdb/v2/v2/content/tag-groups.yml @@ -6,5 +6,6 @@ - Headers - Pagination - Response codes + - Compatibility endpoints - name: All endpoints tags: [] diff --git a/api-docs/influxdb/v2/v2/ref.yml b/api-docs/influxdb/v2/v2/ref.yml index 547f37265..ffc826338 100644 --- a/api-docs/influxdb/v2/v2/ref.yml +++ b/api-docs/influxdb/v2/v2/ref.yml @@ -58,6 +58,7 @@ tags: - [Manage API tokens](/influxdb/v2/security/tokens/) - [Assign a token to a specific user](/influxdb/v2/security/tokens/create-token/) name: Authorizations (API tokens) + - name: Authorizations (v1-compatible) - name: Backup - description: | Store your data in InfluxDB [buckets](/influxdb/v2/reference/glossary/#bucket). @@ -88,6 +89,15 @@ tags: | `orgID` | 16-byte string | The organization ID ([find your organization](/influxdb/v2/organizations/view-orgs/). | name: Common parameters x-traitTag: true + - name: Compatibility endpoints + description: | + InfluxDB v2 provides a v1-compatible API for backward compatibility with InfluxDB 1.x clients and integrations. + + Use these endpoints with InfluxDB 1.x client libraries and third-party integrations such as Grafana, Telegraf, and other tools designed for InfluxDB 1.x. The compatibility layer maps InfluxDB 1.x concepts (databases, retention policies) to InfluxDB v2 resources (buckets, organizations) through database retention policy (DBRP) mappings. + + - [Write data (v1-compatible)](#tag/Write-data-(v1-compatible)) + - [Query data using InfluxQL (v1-compatible)](#tag/Query-data-(v1-compatible)) + - [Manage v1-compatible users and permissions](#tag/Authorizations-(v1-compatible)) - name: Config - name: Dashboards - name: Data I/O endpoints @@ -99,7 +109,7 @@ tags: databases and retention policies are mapped to buckets using the database and retention policy (DBRP) mapping service. The DBRP mapping service uses the database and retention policy - specified in 1.x compatibility API requests to route operations to a bucket. + specified in v1 compatibility API requests to route operations to a bucket. ### Related guides @@ -139,9 +149,6 @@ tags: x-traitTag: true - name: Health - name: Labels - - name: Legacy Authorizations - - name: Legacy Query - - name: Legacy Write - name: Metrics - name: NotificationEndpoints - name: NotificationRules @@ -194,6 +201,7 @@ tags: - description: | Retrieve data, analyze queries, and get query suggestions. name: Query + - name: Query data (v1-compatible) - description: | See the [**API Quick Start**](/influxdb/v2/api-guide/api_intro/) to get up and running authenticating with tokens, writing to buckets, and querying data. @@ -314,6 +322,7 @@ tags: - description: | Write time series data to [buckets](/influxdb/v2/reference/glossary/#bucket). name: Write + - name: Write data (v1-compatible) paths: /api/v2: get: @@ -12756,7 +12765,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: '#/components/schemas/Error' description: The request was well-formed, but some or all the points were rejected due to semantic errors--for example, schema conflicts or retention policy violations. Error message contains details for one or more rejected points. '429': description: | @@ -12869,7 +12878,7 @@ paths: description: Unexpected error summary: List all legacy authorizations tags: - - Legacy Authorizations + - Authorizations (v1-compatible) post: description: | Creates a legacy authorization and returns the legacy authorization. @@ -12932,7 +12941,7 @@ paths: description: Unexpected error summary: Create a legacy authorization tags: - - Legacy Authorizations + - Authorizations (v1-compatible) servers: - url: /private /legacy/authorizations/{authID}: @@ -12954,7 +12963,7 @@ paths: description: Unexpected error summary: Delete a legacy authorization tags: - - Legacy Authorizations + - Authorizations (v1-compatible) get: operationId: GetLegacyAuthorizationsID parameters: @@ -12977,7 +12986,7 @@ paths: description: Unexpected error summary: Retrieve a legacy authorization tags: - - Legacy Authorizations + - Authorizations (v1-compatible) patch: operationId: PatchLegacyAuthorizationsID parameters: @@ -13007,7 +13016,7 @@ paths: description: Unexpected error summary: Update a legacy authorization to be active or inactive tags: - - Legacy Authorizations + - Authorizations (v1-compatible) servers: - url: /private /legacy/authorizations/{authID}/password: @@ -13040,94 +13049,29 @@ paths: description: Unexpected error summary: Set a legacy authorization password tags: - - Legacy Authorizations + - Authorizations (v1-compatible) servers: - url: /private /query: get: - description: Queries InfluxDB using InfluxQL. + summary: Execute InfluxQL query (v1-compatible) + description: | + Executes an InfluxQL query to retrieve data from the specified database. + + This endpoint is compatible with InfluxDB 1.x client libraries and third-party integrations such as Grafana. + Use query parameters to specify the database and the InfluxQL query. operationId: GetLegacyQuery parameters: - $ref: '#/components/parameters/TraceSpan' - - in: header - name: Accept - schema: - default: application/json - description: | - Media type that the client can understand. - - **Note**: With `application/csv`, query results include [**unix timestamps**](/influxdb/v2/reference/glossary/#unix-timestamp) instead of [RFC3339 timestamps](/influxdb/v2/reference/glossary/#rfc3339-timestamp). - enum: - - application/json - - application/csv - - text/csv - - application/x-msgpack - type: string - - description: The content encoding (usually a compression algorithm) that the client can understand. - in: header - name: Accept-Encoding - schema: - default: identity - description: The content coding. Use `gzip` for compressed data or `identity` for unmodified, uncompressed data. - enum: - - gzip - - identity - type: string - - in: header - name: Content-Type - schema: - enum: - - application/json - type: string - - description: The InfluxDB 1.x username to authenticate the request. - in: query - name: u - schema: - type: string - - description: The InfluxDB 1.x password to authenticate the request. - in: query - name: p - schema: - type: string - - description: | - The database to query data from. - This is mapped to an InfluxDB [bucket](/influxdb/v2/reference/glossary/#bucket). - For more information, see [Database and retention policy mapping](/influxdb/v2/api/influxdb-1x/dbrp/). - in: query - name: db - required: true - schema: - type: string - - description: | - The retention policy to query data from. - This is mapped to an InfluxDB [bucket](/influxdb/v2/reference/glossary/#bucket). - For more information, see [Database and retention policy mapping](/influxdb/v2/api/influxdb-1x/dbrp/). - in: query - name: rp - schema: - type: string - - description: The InfluxQL query to execute. To execute multiple queries, delimit queries with a semicolon (`;`). - in: query - name: q - required: true - schema: - type: string - - description: | - A unix timestamp precision. - Formats timestamps as [unix (epoch) timestamps](/influxdb/v2/reference/glossary/#unix-timestamp) with the specified precision - instead of [RFC3339 timestamps](/influxdb/v2/reference/glossary/#rfc3339-timestamp) with nanosecond precision. - in: query - name: epoch - schema: - enum: - - ns - - u - - µ - - ms - - s - - m - - h - type: string + - $ref: '#/components/parameters/AuthV1Username' + - $ref: '#/components/parameters/AuthV1Password' + - $ref: '#/components/parameters/Accept' + - $ref: '#/components/parameters/AcceptEncoding' + - $ref: '#/components/parameters/Content-Type' + - $ref: '#/components/parameters/V1Database' + - $ref: '#/components/parameters/V1RetentionPolicy' + - $ref: '#/components/parameters/V1Epoch' + - $ref: '#/components/parameters/V1Query' responses: '200': content: @@ -13191,19 +13135,87 @@ paths: schema: $ref: '#/components/schemas/Error' description: Error processing query - summary: Query with the 1.x compatibility API tags: - - Legacy Query + - Query data (v1-compatible) + post: + operationId: PostQueryV1 + summary: Execute InfluxQL query (v1-compatible) + description: | + Executes an InfluxQL query to retrieve data from the specified database. + + This endpoint is compatible with InfluxDB 1.x client libraries and third-party integrations such as Grafana. + Use query parameters to specify the database and the InfluxQL query. + tags: + - Query data (v1-compatible) + requestBody: + description: InfluxQL query to execute. + content: + text/plain: + schema: + type: string + parameters: + - $ref: '#/components/parameters/TraceSpan' + - $ref: '#/components/parameters/AuthV1Username' + - $ref: '#/components/parameters/AuthV1Password' + - $ref: '#/components/parameters/Accept' + - $ref: '#/components/parameters/AcceptEncoding' + - $ref: '#/components/parameters/Content-Type' + - $ref: '#/components/parameters/V1Database' + - $ref: '#/components/parameters/V1RetentionPolicy' + - $ref: '#/components/parameters/V1Epoch' + responses: + '200': + description: Query results + headers: + Content-Encoding: + description: The Content-Encoding entity header is used to compress the media-type. When present, its value indicates which encodings were applied to the entity-body + schema: + type: string + description: Specifies that the response in the body is encoded with gzip or not encoded with identity. + default: identity + enum: + - gzip + - identity + Trace-Id: + description: The Trace-Id header reports the request's trace ID, if one was generated. + schema: + type: string + description: Specifies the request's trace ID. + content: + application/csv: + schema: + $ref: '#/components/schemas/InfluxqlCsvResponse' + application/json: + schema: + $ref: '#/components/schemas/InfluxqlJsonResponse' + text/csv: + schema: + $ref: '#/components/schemas/InfluxqlCsvResponse' + examples: + influxql-chunk_size_2: + value: | + {"results":[{"statement_id":0,"series":[{"name":"mymeas","columns":["time","myfield","mytag"],"values":[["2016-05-19T18:37:55Z",90,"1"],["2016-05-19T18:37:56Z",90,"1"]],"partial":true}],"partial":true}]} + {"results":[{"statement_id":0,"series":[{"name":"mymeas","columns":["time","myfield","mytag"],"values":[["2016-05-19T18:37:57Z",90,"1"],["2016-05-19T18:37:58Z",90,"1"]]}]}]} + application/x-msgpack: + schema: + type: string + format: binary + '429': + description: Token is temporarily over quota. The Retry-After header describes when to try the read again. + headers: + Retry-After: + description: A non-negative decimal integer indicating the seconds to delay after the response is received. + schema: + type: integer + format: int32 + default: + description: Error processing query + content: + application/json: + schema: + $ref: '#/components/schemas/Error' /write: post: - description: |- - Writes line protocol to the specified bucket. - - This endpoint provides backward compatibility for InfluxDB 1.x write workloads using tools such as InfluxDB 1.x client libraries, the Telegraf `outputs.influxdb` output plugin, or third-party tools. - - Use this endpoint to send data in [line protocol](https://docs.influxdata.com/influxdb/v2/reference/syntax/line-protocol/) format to InfluxDB. - Use query parameters to specify options for writing data. - operationId: PostLegacyWrite parameters: - $ref: '#/components/parameters/TraceSpan' @@ -13281,7 +13293,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: '#/components/schemas/Error' description: The request was well-formed, but some or all the points were rejected due to semantic errors--for example, schema conflicts or retention policy violations. Error message contains details for one or more rejected points. '429': description: Token is temporarily over quota. The Retry-After header describes when to try the write again. @@ -13305,9 +13317,31 @@ paths: schema: $ref: '#/components/schemas/Error' description: Internal server error - summary: Write time series data into InfluxDB in a V1-compatible format + summary: Write data using a v1-compatible request + description: | + Writes data in [line protocol](/influxdb/v2/reference/syntax/line-protocol/) syntax to the specified bucket using a v1-compatible request. + + This endpoint provides backward compatibility for InfluxDB 1.x write workloads using tools such as InfluxDB 1.x client libraries, the Telegraf `outputs.influxdb` output plugin, or third-party tools. + + Use query parameters to specify options for writing data. + + #### InfluxDB Cloud + + - Validates and queues the request. + - Handles the write asynchronously - the write might not have completed yet. + - Returns a `Retry-After` header that describes when to try the write again. + + #### InfluxDB OSS v2 + + - Validates the request and handles the write synchronously. + - If all points were written successfully, responds with HTTP `2xx` status code + - If any points were rejected, responds with HTTP `4xx` status code and details about the problem. + + #### Related guides + + - [Write data with the InfluxDB API](/influxdb/v2/write-data/developer-tools/api) tags: - - Legacy Write + - Write data (v1-compatible) components: examples: AuthorizationPostRequest: @@ -13412,6 +13446,96 @@ components: required: false schema: type: string + Accept: + in: header + name: Accept + schema: + default: application/json + description: | + Media type that the client can understand. + + **Note**: With `application/csv`, query results include [**unix timestamps**](/influxdb/v2/reference/glossary/#unix-timestamp) instead of [RFC3339 timestamps](/influxdb/v2/reference/glossary/#rfc3339-timestamp). + enum: + - application/json + - application/csv + - text/csv + - application/x-msgpack + type: string + AcceptEncoding: + description: The content encoding (usually a compression algorithm) that the client can understand. + in: header + name: Accept-Encoding + schema: + default: identity + description: The content coding. Use `gzip` for compressed data or `identity` for unmodified, uncompressed data. + enum: + - gzip + - identity + type: string + Content-Type: + in: header + name: Content-Type + schema: + enum: + - application/json + type: string + AuthV1Username: + description: | + The InfluxDB 1.x username to authenticate the request. + If you provide an API token as the password, `u` is required, but can be any value. + in: query + name: u + schema: + type: string + AuthV1Password: + description: The InfluxDB 1.x password to authenticate the request. + in: query + name: p + schema: + type: string + V1Database: + description: | + The database to query data from. + This is mapped to an InfluxDB [bucket](/influxdb/v2/reference/glossary/#bucket). + For more information, see [Database and retention policy mapping](/influxdb/v2/api/influxdb-1x/dbrp/). + in: query + name: db + required: true + schema: + type: string + V1RetentionPolicy: + description: | + The retention policy to query data from. + This is mapped to an InfluxDB [bucket](/influxdb/v2/reference/glossary/#bucket). + For more information, see [Database and retention policy mapping](/influxdb/v2/api/influxdb-1x/dbrp/). + in: query + name: rp + schema: + type: string + V1Query: + description: The InfluxQL query to execute. To execute multiple queries, delimit queries with a semicolon (`;`). + in: query + name: q + required: true + schema: + type: string + V1Epoch: + description: | + A unix timestamp precision. + Formats timestamps as [unix (epoch) timestamps](/influxdb/v2/reference/glossary/#unix-timestamp) with the specified precision + instead of [RFC3339 timestamps](/influxdb/v2/reference/glossary/#rfc3339-timestamp) with nanosecond precision. + in: query + name: epoch + schema: + enum: + - ns + - u + - µ + - ms + - s + - m + - h + type: string responses: AuthorizationError: content: @@ -20058,13 +20182,16 @@ x-tagGroups: - Headers - Pagination - Response codes + - Compatibility endpoints - name: All endpoints tags: - Authorizations (API tokens) + - Authorizations (v1-compatible) - Backup - Buckets - Cells - Checks + - Compatibility endpoints - Config - Dashboards - DBRPs @@ -20072,15 +20199,13 @@ x-tagGroups: - Delete - Health - Labels - - Legacy Authorizations - - Legacy Query - - Legacy Write - Metrics - NotificationEndpoints - NotificationRules - Organizations - Ping - Query + - Query data (v1-compatible) - Ready - RemoteConnections - Replications @@ -20102,3 +20227,4 @@ x-tagGroups: - Variables - Views - Write + - Write data (v1-compatible) diff --git a/content/influxdb/v2/api-guide/_index.md b/content/influxdb/v2/api-guide/_index.md index e9218d9d8..3a1520b5f 100644 --- a/content/influxdb/v2/api-guide/_index.md +++ b/content/influxdb/v2/api-guide/_index.md @@ -34,8 +34,8 @@ and visit the `/docs` endpoint in a browser ([localhost:8086/docs](http://localh ## InfluxDB v1 compatibility API documentation -The InfluxDB v2 API includes [InfluxDB 1.x compatibility endpoints](/influxdb/v2/reference/api/influxdb-1x/) +The InfluxDB v2 API includes [InfluxDB v1 compatibility endpoints and authentication](/influxdb/v2/api-guide/influxdb-1x/) that work with InfluxDB 1.x client libraries and third-party integrations like [Grafana](https://grafana.com) and others. -View full v1 compatibility API documentation +View full v1 compatibility API documentation diff --git a/content/influxdb/v2/api-guide/api_intro.md b/content/influxdb/v2/api-guide/api_intro.md index bc12a32b4..aa559566d 100644 --- a/content/influxdb/v2/api-guide/api_intro.md +++ b/content/influxdb/v2/api-guide/api_intro.md @@ -14,4 +14,5 @@ source: /shared/influxdb-v2/api-guide/api_intro.md --- +// SOURCE content/shared/influxdb-v2/api-guide/api_intro.md +--> diff --git a/content/influxdb/v2/api-guide/influxdb-1x/_index.md b/content/influxdb/v2/api-guide/influxdb-1x/_index.md index 021dbb523..50cca1b79 100644 --- a/content/influxdb/v2/api-guide/influxdb-1x/_index.md +++ b/content/influxdb/v2/api-guide/influxdb-1x/_index.md @@ -18,4 +18,5 @@ source: /shared/influxdb-v2/api-guide/influxdb-1x/_index.md --- +// SOURCE content/shared/influxdb-v2/api-guide/influxdb-1x/_index.md +--> diff --git a/content/influxdb/v2/api-guide/influxdb-1x/query.md b/content/influxdb/v2/api-guide/influxdb-1x/query.md index 284ebd6e2..b236d74e0 100644 --- a/content/influxdb/v2/api-guide/influxdb-1x/query.md +++ b/content/influxdb/v2/api-guide/influxdb-1x/query.md @@ -14,17 +14,15 @@ list_code_example: | GET http://localhost:8086/query related: + - /influxdb/v2/query-data/execute-queries/influx-api/ - /influxdb/v2/query-data/influxql aliases: - /influxdb/v2/reference/api/influxdb-1x/query/ --- The `/query` 1.x compatibility endpoint queries InfluxDB {{< current-version >}} using **InfluxQL**. -Use the `GET` request method to query data from the `/query` endpoint. +Send an InfluxQL query in an HTTP `GET` or `POST` request to query data from the `/query` endpoint. -
-GET http://localhost:8086/query
-
The `/query` compatibility endpoint uses the **database** and **retention policy**
specified in the query request to map the request to an InfluxDB bucket.
@@ -32,31 +30,32 @@ For more information, see [Database and retention policy mapping](/influxdb/v2/r
{{% show-in "cloud,cloud-serverless" %}}
-{{% note %}}
-If you have an existing bucket that doesn't follow the **database/retention-policy** naming convention,
-you **must** [manually create a database and retention policy mapping](/influxdb/v2/query-data/influxql/dbrp/#create-dbrp-mappings)
-to query that bucket with the `/query` compatibility API.
-{{% /note %}}
+> [!Note]
+> If you have an existing bucket that doesn't follow the **database/retention-policy** naming convention,
+> you **must** [manually create a database and retention policy mapping](/influxdb/v2/query-data/influxql/dbrp/#create-dbrp-mappings)
+> to query that bucket with the `/query` compatibility API.
{{% /show-in %}}
## Authentication
Use one of the following authentication methods:
-* **token authentication**
-* **basic authentication with username and password**
-* **query string authentication with username and password**
-_For more information, see [Authentication](/influxdb/v2/reference/api/influxdb-1x/#authentication)._
+- the 2.x `Authorization: Token` scheme in the header
+- the v1-compatible `u` and `p` query string parameters
+- the v1-compatible `Basic` authentication scheme in the header
+
+For more information, see [Authentication for the 1.x compatibility API](/influxdb/v2/api-guide/influxdb-1x/).
## Query string parameters
### u
(Optional) The 1.x **username** to authenticate the request.
+If you provide an API token as the password, `u` is required, but can be any value.
_See [query string authentication](/influxdb/v2/reference/api/influxdb-1x/#query-string-authentication)._
### p
-(Optional) The 1.x **password** to authenticate the request.
+(Optional) The 1.x **password** or the 2.x API token to authenticate the request.
_See [query string authentication](/influxdb/v2/reference/api/influxdb-1x/#query-string-authentication)._
### db
@@ -94,61 +93,65 @@ The following precisions are available:
- [Return query results with millisecond Unix timestamps](#return-query-results-with-millisecond-unix-timestamps)
- [Execute InfluxQL queries from a file](#execute-influxql-queries-from-a-file)
-{{% code-placeholders "API_TOKEN" %}}
+{{% code-placeholders "INFLUX_USERNAME|INFLUX_PASSWORD_OR_TOKEN|API_TOKEN" %}}
##### Query using basic authentication
+The following example:
+
+- sends a `GET` request to the `/query` endpoint
+- uses the `Authorization` header with the `Basic` scheme (compatible with InfluxDB 1.x) to provide username and password credentials
+- uses the default retention policy for the database
+
{{% show-in "v2" %}}
-
-{{< code-tabs-wrapper >}}
-{{% code-tabs %}}
-[curl](#curl)
-[Node.js](#nodejs)
-{{% /code-tabs %}}
-{{% code-tab-content %}}
-
```sh
-{{% get-shared-text "api/v1-compat/auth/oss/basic-auth.sh" %}}
-```
-{{% /code-tab-content %}}
-{{% code-tab-content %}}
-```js
-{{% get-shared-text "api/v1-compat/auth/oss/basic-auth.js" %}}
-```
-{{% /code-tab-content %}}
-{{< /code-tabs-wrapper >}}
+##############################################################################
+# Use Basic authentication with an
+# InfluxDB v1-compatible username and password
+# to query the InfluxDB 1.x compatibility API.
+#
+# INFLUX_USERNAME: your v1-compatible username.
+# INFLUX_PASSWORD_OR_TOKEN: your API token or v1-compatible password.
+##############################################################################
+curl --get "http://{{< influxdb/host >}}/query" \
+ --user "INFLUX_USERNAME":"INFLUX_PASSWORD_OR_TOKEN" \
+ --data-urlencode "db=BUCKET_NAME" \
+ --data-urlencode "q=SELECT * FROM cpu_usage"
+```
{{% /show-in %}}
{{% show-in "cloud,cloud-serverless" %}}
-{{< code-tabs-wrapper >}}
-{{% code-tabs %}}
-[curl](#curl)
-[Node.js](#nodejs)
-{{% /code-tabs %}}
-{{% code-tab-content %}}
-
```sh
{{% get-shared-text "api/v1-compat/auth/cloud/basic-auth.sh" %}}
```
-{{% /code-tab-content %}}
-{{% code-tab-content %}}
-```js
-{{% get-shared-text "api/v1-compat/auth/cloud/basic-auth.js" %}}
-```
-{{% /code-tab-content %}}
-{{< /code-tabs-wrapper >}}
-
{{% /show-in %}}
+##### Query using an HTTP POST request
+
+```bash
+curl \
+ --request POST \
+ "http://{{< influxdb/host >}}/query?db=DATABASE_NAME&rp=RETENTION_POLICY" \
+ --user "INFLUX_USERNAME":"INFLUX_PASSWORD_OR_TOKEN" \
+ --header "Content-type: application/vnd.influxql" \
+ --data "SELECT * FROM cpu_usage WHERE time > now() - 1h"
+```
+
##### Query a non-default retention policy
+The following example:
+
+- sends a `GET` request to the `/query` endpoint
+- uses the `Authorization` header with the `Token` scheme (compatible with InfluxDB 2.x) to provide the API token
+- queries a custom retention policy mapped for the database
+
```sh
-curl --get http://localhost:8086/query \
+curl --get http://{{< influxdb/host >}}/query \
--header "Authorization: Token API_TOKEN" \
- --data-urlencode "db=mydb" \
- --data-urlencode "rp=customrp" \
+ --data-urlencode "db=DATABASE_NAME" \
+ --data-urlencode "rp=RETENTION_POLICY_NAME" \
--data-urlencode "q=SELECT used_percent FROM mem WHERE host=host1"
```
##### Execute multiple queries
```sh
-curl --get http://localhost:8086/query \
+curl --get http://{{< influxdb/host >}}/query \
--header "Authorization: Token API_TOKEN" \
- --data-urlencode "db=mydb" \
+ --data-urlencode "db=DATABASE_NAME" \
--data-urlencode "q=SELECT * FROM mem WHERE host=host1;SELECT mean(used_percent) FROM mem WHERE host=host1 GROUP BY time(10m)"
```
##### Return query results with millisecond Unix timestamps
```sh
-curl --get http://localhost:8086/query \
+curl --get http://{{< influxdb/host >}}/query \
--header "Authorization: Token API_TOKEN" \
- --data-urlencode "db=mydb" \
- --data-urlencode "rp=myrp" \
+ --data-urlencode "db=DATABASE_NAME" \
+ --data-urlencode "rp=RETENTION_POLICY_NAME" \
--data-urlencode "q=SELECT used_percent FROM mem WHERE host=host1" \
--data-urlencode "epoch=ms"
```
##### Execute InfluxQL queries from a file
```sh
-curl --get http://localhost:8086/query \
+curl --get http://{{< influxdb/host >}}/query \
--header "Authorization: Token API_TOKEN" \
- --data-urlencode "db=mydb" \
- --data-urlencode "q@path/to/influxql.txt" \
- --data-urlencode "async=true"
+ --data-urlencode "db=DATABASE_NAME" \
+ --data-urlencode "q@path/to/influxql.txt"
```
+##### Return a gzip-compressed response
+```sh
+curl --get http://{{< influxdb/host >}}/query \
+ --header 'Accept-Encoding: gzip' \
+ --header "Authorization: Token API_TOKEN" \
+ --data-urlencode "db=DATABASE_NAME" \
+ --data-urlencode "q=SELECT used_percent FROM mem WHERE host=host1"
+```
{{% /code-placeholders %}}
Replace the following:
- {{% code-placeholder-key %}}`API_TOKEN`{{% /code-placeholder-key %}}: your InfluxDB [API token](/influxdb/v2/admin/tokens/)
+- {{% code-placeholder-key %}}`DATABASE_NAME`{{% /code-placeholder-key %}}: the name of the database to query.
+In InfluxDB 2.x, databases and retention policies map to [buckets](/influxdb/v2/admin/buckets/).
+- {{% code-placeholder-key %}}`RETENTION_POLICY_NAME`{{% /code-placeholder-key %}}: the name of the retention policy to query.
+In InfluxDB 2.x, databases and retention policies map to [buckets](/influxdb/v2/admin/buckets/).
+
+_For more information about the database and retention policy mapping, see [Database and retention policy mapping](/influxdb/v2/reference/api/influxdb-1x/dbrp)._
\ No newline at end of file
diff --git a/content/influxdb/v2/api-guide/tutorials/_index.md b/content/influxdb/v2/api-guide/tutorials/_index.md
index b9fb91f28..a30a77c85 100644
--- a/content/influxdb/v2/api-guide/tutorials/_index.md
+++ b/content/influxdb/v2/api-guide/tutorials/_index.md
@@ -12,4 +12,5 @@ source: /shared/influxdb-v2/api-guide/tutorials/_index.md
---
+// SOURCE content/shared/influxdb-v2/api-guide/tutorials/_index.md
+-->
diff --git a/content/influxdb/v2/install/upgrade/v1-to-v2/automatic-upgrade.md b/content/influxdb/v2/install/upgrade/v1-to-v2/automatic-upgrade.md
index 6dc3fea9b..e505d6e96 100644
--- a/content/influxdb/v2/install/upgrade/v1-to-v2/automatic-upgrade.md
+++ b/content/influxdb/v2/install/upgrade/v1-to-v2/automatic-upgrade.md
@@ -328,6 +328,6 @@ which requires authentication.
**For these external clients to work with InfluxDB {{< current-version >}}:**
-1. [Manually create a 1.x-compatible authorization](/influxdb/v2/upgrade/v1-to-v2/manual-upgrade/#create-a-1x-compatible-authorization).
+1. [Manually create a v1-compatible authorization](/influxdb/v2/upgrade/v1-to-v2/manual-upgrade/#create-a-1x-compatible-authorization).
2. Update the client configuration to use the username and password associated
- with your 1.x-compatible authorization.
+ with your v1-compatible authorization.
diff --git a/content/influxdb/v2/install/upgrade/v1-to-v2/manual-upgrade.md b/content/influxdb/v2/install/upgrade/v1-to-v2/manual-upgrade.md
index dbab1a0d1..ff973238f 100644
--- a/content/influxdb/v2/install/upgrade/v1-to-v2/manual-upgrade.md
+++ b/content/influxdb/v2/install/upgrade/v1-to-v2/manual-upgrade.md
@@ -3,7 +3,7 @@ title: Manually upgrade from InfluxDB 1.x to 2.7
list_title: Manually upgrade from 1.x to 2.7
description: >
To manually upgrade from InfluxDB 1.x to InfluxDB 2.7, migrate data, create
- 1.x-compatible authorizations, and create database and retention policy
+ v1-compatible authorizations, and create database and retention policy
(DBRP) mappings.
menu:
influxdb_v2:
diff --git a/content/influxdb/v2/query-data/execute-queries/influx-api.md b/content/influxdb/v2/query-data/execute-queries/influx-api.md
index d088dc2b6..cff681793 100644
--- a/content/influxdb/v2/query-data/execute-queries/influx-api.md
+++ b/content/influxdb/v2/query-data/execute-queries/influx-api.md
@@ -11,4 +11,5 @@ source: /shared/influxdb-v2/query-data/execute-queries/influx-api.md
---
+// SOURCE content/shared/influxdb-v2/query-data/execute-queries/influx-api.md
+-->
diff --git a/content/influxdb/v2/query-data/influxql/_index.md b/content/influxdb/v2/query-data/influxql/_index.md
index a4ca6434b..4e7e6b229 100644
--- a/content/influxdb/v2/query-data/influxql/_index.md
+++ b/content/influxdb/v2/query-data/influxql/_index.md
@@ -1,8 +1,8 @@
---
title: Query data with InfluxQL
description: >
- Use the [InfluxDB 1.x `/query` compatibility endpoint](/influxdb/v2/reference/api/influxdb-1x/query)
- to query data in InfluxDB Cloud and InfluxDB OSS 2.4 with **InfluxQL**.
+ Use the InfluxDB v1 `/query` compatibility endpoint
+ to query data in InfluxDB v2 using InfluxQL.
weight: 102
influxdb/v2/tags: [influxql, query]
menu:
diff --git a/content/influxdb/v2/write-data/developer-tools/api.md b/content/influxdb/v2/write-data/developer-tools/api.md
index 85b09d4d1..519657369 100644
--- a/content/influxdb/v2/write-data/developer-tools/api.md
+++ b/content/influxdb/v2/write-data/developer-tools/api.md
@@ -26,7 +26,7 @@ The URL in the examples depends on the version and location of your InfluxDB {{<
{{< code-tabs-wrapper >}}
{{% code-tabs %}}
-[Curl](#curl)
+[cURL](#curl)
[Node.js](#nodejs)
{{% /code-tabs %}}
{{% code-tab-content %}}
diff --git a/content/influxdb/v2/write-data/troubleshoot.md b/content/influxdb/v2/write-data/troubleshoot.md
index 81cbc2e58..3d4fba878 100644
--- a/content/influxdb/v2/write-data/troubleshoot.md
+++ b/content/influxdb/v2/write-data/troubleshoot.md
@@ -10,7 +10,8 @@ menu:
parent: Write data
influxdb/v2/tags: [write, line protocol, errors]
related:
- - /influxdb/v2/api/#tag/Write, InfluxDB API /write endpoint
+ - /influxdb/v2/api/v2/#operation/PostLegacyWrite, InfluxDB API /write endpoint
+ - /influxdb/v2/api/v2/#operation/PostWrite, InfluxDB API /api/v2/write endpoint
- /influxdb/v2/reference/internals
- /influxdb/v2/reference/cli/influx/write
source: /shared/influxdb-v2/write-data/troubleshoot.md
diff --git a/content/shared/influxdb-v2/api-guide/api_intro.md b/content/shared/influxdb-v2/api-guide/api_intro.md
index d5cdd1702..e4210f033 100644
--- a/content/shared/influxdb-v2/api-guide/api_intro.md
+++ b/content/shared/influxdb-v2/api-guide/api_intro.md
@@ -5,13 +5,12 @@ This section guides you through the most commonly used API methods.
For detailed documentation on the entire API, see the [InfluxDB v2 API Reference](/influxdb/version/reference/api/#influxdb-v2-api-documentation).
-{{% note %}}
-If you need to use InfluxDB {{< current-version >}} with **InfluxDB 1.x** API clients and integrations, see the [1.x compatibility API](/influxdb/version/reference/api/#influxdb-v1-compatibility-api-reference-documentation).
-{{% /note %}}
+> [!Note]
+> If you need to use InfluxDB {{< current-version >}} with **InfluxDB 1.x** API clients and integrations, see the [1.x compatibility API guide](/influxdb/version/api-guide/influxdb-1x).
## Bootstrap your application
-With most API requests, you'll need to provide a minimum of your InfluxDB URL and Authorization Token (API Token).
+With most API requests, you'll need to provide a minimum of your InfluxDB URL and [Authorization Token (API Token)](/influxdb/version/admin/tokens/).
[Install InfluxDB OSS v2.x](/influxdb/version/install/) or upgrade to
an [InfluxDB Cloud account](/influxdb/cloud/sign-up).
@@ -19,11 +18,14 @@ an [InfluxDB Cloud account](/influxdb/cloud/sign-up).
### Authentication
InfluxDB uses [API tokens](/influxdb/version/admin/tokens/) to authorize API requests.
+InfluxDB filters API requests and response data based on the permissions associated with the token.
-1. Before exploring the API, use the InfluxDB UI to
+1. Before exploring the API, use the `influx` CLI or the InfluxDB UI to
[create an initial API token](/influxdb/version/admin/tokens/create-token/) for your application.
-2. Include your API token in an `Authorization: Token YOUR_API_TOKEN` HTTP header with each request.
+1. Include your API token in an `Authorization: Token API_TOKEN` HTTP header with each request--for example:
+
+{{% code-placeholders "API_TOKEN" %}}
{{< code-tabs-wrapper >}}
{{% code-tabs %}}
@@ -31,28 +33,94 @@ InfluxDB uses [API tokens](/influxdb/version/admin/tokens/) to authorize API req
[Node.js](#nodejs)
{{% /code-tabs %}}
{{% code-tab-content %}}
-```sh
-{{% get-shared-text "api/v2.0/auth/oss/token-auth.sh" %}}
+```bash
+# Use a token to authorize a GET request to the InfluxDB API.
+# List buckets in your organization that the token can read.
+curl -X GET "http://{{< influxdb/host >}}/api/v2/buckets" \
+ --header 'Accept: application/json' \
+ --header 'Authorization: Token API_TOKEN'
```
{{% /code-tab-content %}}
{{% code-tab-content %}}
```js
-{{% get-shared-text "api/v2.0/auth/oss/token-auth.js" %}}
+/**
+ * Use a token to authorize a GET request to the InfluxDB API.
+ * List buckets in your organization that the token can read.
+ */
+
+const https = require('https');
+
+function listBuckets() {
+
+ const options = {
+ host: '{{< influxdb/host >}}',
+ path: "/api/v2/buckets",
+ headers: {
+ 'Authorization': 'Token API_TOKEN',
+ 'Content-type': 'application/json'
+ },
+ };
+
+ const request = https.get(options, (response) => {
+ let rawData = '';
+ response.on('data', () => {
+ response.on('data', (chunk) => { rawData += chunk; });
+ })
+ response.on('end', () => {
+ console.log(rawData);
+ })
+ });
+
+ request.end();
+}
```
{{% /code-tab-content %}}
{{< /code-tabs-wrapper >}}
-Postman is another popular tool for exploring APIs. See how to [send authenticated requests with Postman](/influxdb/version/tools/postman/#send-authenticated-api-requests-with-postman).
+{{% /code-placeholders %}}
+
+> [!Note]
+> Postman is another popular tool for exploring APIs.
+> See how to [send authenticated requests with Postman](/influxdb/version/tools/postman/#send-authenticated-api-requests-with-postman).
## Buckets API
-Before writing data you'll need to create a Bucket in InfluxDB.
-[Create a bucket](/influxdb/version/admin/buckets/create-bucket/#create-a-bucket-using-the-influxdb-api) using an HTTP request to the InfluxDB API `/buckets` endpoint.
+Before writing data you'll need to create a bucket in your InfluxDB instance.
+To use the API to create a bucket, send a request to the following endpoint:
-```sh
-{{% get-shared-text "api/v2.0/buckets/oss/create.sh" %}}
+{{% api-endpoint method="POST" endpoint="/api/v2/buckets" api-ref="/influxdb/version/api/v2/#operation/PostBuckets" %}}
+
+{{% code-placeholders "API_TOKEN|ORG_ID|BUCKET_NAME|RETENTION_PERIOD_SECONDS" %}}
+
+```bash
+curl --request POST \
+ "http://localhost:8086/api/v2/buckets" \
+ --header "Authorization: Token API_TOKEN" \
+ --json '{
+ "orgID": "'"ORG_ID"'",
+ "name": "BUCKET_NAME",
+ "retentionRules": [
+ {
+ "type": "expire",
+ "everySeconds": RETENTION_PERIOD_SECONDS,
+ "shardGroupDurationSeconds": 0
+ }
+ ]
+ }'
```
+{{% /code-placeholders %}}
+
+Replace the following placeholders with your values:
+
+- {{% code-placeholder-key %}}`API_TOKEN`{{% /code-placeholder-key %}} - your [token](/influxdb/version/admin/tokens/).
+- {{% code-placeholder-key %}}`ORG_ID`{{% /code-placeholder-key %}} - the ID of the [organization](/influxdb/version/admin/organizations/) that owns the bucket.
+- {{% code-placeholder-key %}}`BUCKET_NAME`{{% /code-placeholder-key %}} - the name of the [bucket](/influxdb/version/admin/buckets/) to create.
+- Optional: {{% code-placeholder-key %}}`RETENTION_PERIOD_SECONDS`{{% /code-placeholder-key %}} - the [retention period](/influxdb/version/reference/glossary/#retention-period) (in number of seconds) to retain data in the bucket. Default is `0` (infinite retention).
+ - For example, `31536000` (1 year) or `604800` (7 days).
+
+For more information, see [Create a bucket](/influxdb/version/admin/buckets/create-bucket/#create-a-bucket-using-the-influxdb-api).
+
## Write API
[Write data to InfluxDB](/influxdb/version/write-data/developer-tools/api/) using an HTTP request to the InfluxDB API `/api/v2/write` endpoint.
diff --git a/content/shared/influxdb-v2/api-guide/influxdb-1x/_index.md b/content/shared/influxdb-v2/api-guide/influxdb-1x/_index.md
index fc992830d..a762beef4 100644
--- a/content/shared/influxdb-v2/api-guide/influxdb-1x/_index.md
+++ b/content/shared/influxdb-v2/api-guide/influxdb-1x/_index.md
@@ -7,7 +7,7 @@ InfluxDB 1.x client libraries and third-party integrations like [Grafana](https:
## Authentication
InfluxDB 1.x compatibility endpoints require all query and write requests to be authenticated with an
-[API token](/influxdb/version/admin/tokens/) or 1.x-compatible
+[API token](/influxdb/version/admin/tokens/) or v1-compatible
credentials.
* [Authenticate with the Token scheme](#authenticate-with-the-token-scheme)
@@ -67,12 +67,12 @@ Username and password schemes require the following credentials:
{{% note %}}
#### Password or Token
-If you have [set a password](/influxdb/version/install/upgrade/v1-to-v2/manual-upgrade/#1x-compatible-authorizations) for the 1.x-compatible username, provide the 1.x-compatible password.
-If you haven't set a password for the 1.x-compatible username, provide the InfluxDB [authentication token](/influxdb/version/admin/tokens/) as the password.
+If you have [set a password](/influxdb/version/install/upgrade/v1-to-v2/manual-upgrade/#1x-compatible-authorizations) for the v1-compatible username, provide the v1-compatible password.
+If you haven't set a password for the v1-compatible username, provide the InfluxDB [authentication token](/influxdb/version/admin/tokens/) as the password.
{{% /note %}}
For more information, see how to create and manage
-[1.x-compatible authorizations](/influxdb/version/install/upgrade/v1-to-v2/manual-upgrade/#1x-compatible-authorizations)
+[v1-compatible authorizations](/influxdb/version/install/upgrade/v1-to-v2/manual-upgrade/#1x-compatible-authorizations)
when manually upgrading from InfluxDB v1 to v2.
{{% /show-in %}}
diff --git a/content/shared/influxdb-v2/get-started/query.md b/content/shared/influxdb-v2/get-started/query.md
index ccb6ec3e2..0b80ef0da 100644
--- a/content/shared/influxdb-v2/get-started/query.md
+++ b/content/shared/influxdb-v2/get-started/query.md
@@ -496,7 +496,7 @@ To query data from InfluxDB using InfluxQL and the InfluxDB HTTP API, send a req
to the InfluxDB API [`/query` 1.X compatibility endpoint](/influxdb/version/reference/api/influxdb-1x/query/)
using the `POST` request method.
-{{< api-endpoint endpoint="http://localhost:8086/query" method="post" api-ref="/influxdb/version/api/v1-compatibility/#operation/PostQueryV1" >}}
+{{< api-endpoint endpoint="http://localhost:8086/query" method="post" api-ref="/influxdb/version/api/v1/#operation/PostQueryV1" >}}
Include the following with your request:
diff --git a/content/shared/influxdb-v2/query-data/execute-queries/influx-api.md b/content/shared/influxdb-v2/query-data/execute-queries/influx-api.md
index 80c8cb4e7..5e8c65be1 100644
--- a/content/shared/influxdb-v2/query-data/execute-queries/influx-api.md
+++ b/content/shared/influxdb-v2/query-data/execute-queries/influx-api.md
@@ -2,63 +2,71 @@
The [InfluxDB v2 API](/influxdb/version/reference/api) provides a programmatic interface for all interactions with InfluxDB.
To query InfluxDB {{< current-version >}}, do one of the following:
-- Send a Flux query request to the [`/api/v2/query`](/influxdb/version/api/#operation/PostQueryAnalyze) endpoint.
-- Send an InfluxQL query request to the [/query 1.x compatibility API](/influxdb/version/reference/api/influxdb-1x/query/).
+- [Send a Flux query request](#send-a-flux-query-request)
+- [Send an InfluxQL query request](#send-an-influxql-query-request)
+
+## Send a Flux query request
+
+Send a Flux query request to the following endpoint:
+
+{{% api-endpoint method="POST" endpoint="/api/v2/query" api-ref="/influxdb/version/api/#operation/PostQueryAnalyze" %}}
In your request, set the following:
-- Your organization via the `org` or `orgID` URL parameters.
-- `Authorization` header to `Token ` + your API token.
-- `Accept` header to `application/csv`.
-- `Content-type` header to `application/vnd.flux` (Flux only) or `application/json` (Flux or InfluxQL).
-- Query in Flux or InfluxQL with the request's raw data.
+- Your organization via the `org` or `orgID` URL parameters
+- Headers:
+ - `Authorization: Token