Standardize formatting of curl API examples (#1714)

Standardize formatting of curl API examples
pull/1721/head
pierwill 2020-10-26 18:01:09 -05:00 committed by GitHub
parent cb3cc221fe
commit f2e458ea96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 80 additions and 76 deletions

View File

@ -81,10 +81,10 @@ Below is an example `curl` command that queries InfluxDB:
{{% code-tab-content %}} {{% code-tab-content %}}
```bash ```bash
curl http://localhost:8086/api/v2/query?org=my-org -XPOST -sS \ curl http://localhost:8086/api/v2/query?org=my-org -XPOST -sS \
-H 'Authorization: Token YOURAUTHTOKEN' \ --header 'Authorization: Token YOURAUTHTOKEN' \
-H 'Accept: application/csv' \ --header 'Accept: application/csv' \
-H 'Content-type: application/vnd.flux' \ --header 'Content-type: application/vnd.flux' \
-d 'from(bucket:"example-bucket") --data 'from(bucket:"example-bucket")
|> range(start: -12h) |> range(start: -12h)
|> filter(fn: (r) => r._measurement == "example-measurement") |> filter(fn: (r) => r._measurement == "example-measurement")
|> aggregateWindow(every: 1h, fn: mean)' |> aggregateWindow(every: 1h, fn: mean)'
@ -93,12 +93,12 @@ curl http://localhost:8086/api/v2/query?org=my-org -XPOST -sS \
{{% code-tab-content %}} {{% code-tab-content %}}
```bash ```bash
curl http://localhost:8086/api/v2/query?org=my-org -XPOST -sS \ curl --request POST http://localhost:8086/api/v2/query?org=my-org \
-H 'Authorization: Token YOURAUTHTOKEN' \ --header 'Authorization: Token YOURAUTHTOKEN' \
-H 'Accept: application/csv' \ --header 'Accept: application/csv' \
-H 'Content-type: application/vnd.flux' \ --header 'Content-type: application/vnd.flux' \
-H 'Accept-Encoding: gzip' \ --header 'Accept-Encoding: gzip' \
-d 'from(bucket:"example-bucket") --data 'from(bucket:"example-bucket")
|> range(start: -12h) |> range(start: -12h)
|> filter(fn: (r) => r._measurement == "example-measurement") |> filter(fn: (r) => r._measurement == "example-measurement")
|> aggregateWindow(every: 1h, fn: mean)' |> aggregateWindow(every: 1h, fn: mean)'

View File

@ -75,7 +75,8 @@ Use `curl` and the `influx write` command to write bird migration line protocol
Replace `example-bucket` with your destination bucket: Replace `example-bucket` with your destination bucket:
```sh ```sh
curl https://raw.githubusercontent.com/influxdata/influxdb2-sample-data/master/bird-migration-data/bird-migration.line --output ./tmp-data curl https://raw.githubusercontent.com/influxdata/influxdb2-sample-data/master/bird-migration-data/bird-migration.line \
--output ./tmp-data
influx write -b example-bucket @./tmp-data influx write -b example-bucket @./tmp-data
rm -f ./tmp-data rm -f ./tmp-data
``` ```

View File

@ -233,10 +233,10 @@ to store your database credentials as secrets.
{{% /tabs %}} {{% /tabs %}}
{{% tab-content %}} {{% tab-content %}}
```sh ```sh
curl -X PATCH http://localhost:8086/api/v2/orgs/<org-id>/secrets \ curl --request PATCH http://localhost:8086/api/v2/orgs/<org-id>/secrets \
-H 'Authorization: Token YOURAUTHTOKEN' \ --header 'Authorization: Token YOURAUTHTOKEN' \
-H 'Content-type: application/json' \ --header 'Content-type: application/json' \
-d '{ --data '{
"POSTGRES_HOST": "http://example.com", "POSTGRES_HOST": "http://example.com",
"POSTGRES_USER": "example-username", "POSTGRES_USER": "example-username",
"POSTGRES_PASS": "example-password" "POSTGRES_PASS": "example-password"

View File

@ -36,10 +36,10 @@ Verify the buckets that you want to query are mapped to a database and retention
- To find a specific bucket (`bucket_id`), database (`database`), retention policy (`retention_policy`), or mapping ID (`id`), include the parameter in your request. - To find a specific bucket (`bucket_id`), database (`database`), retention policy (`retention_policy`), or mapping ID (`id`), include the parameter in your request.
```sh ```sh
curl -GET https://cloud2.influxdata.com/api/v2/dbrps \ curl --request GET https://cloud2.influxdata.com/api/v2/dbrps \
-H "Authorization: Token YourAuthToken" \ --header "Authorization: Token YourAuthToken" \
-H 'Content-type: application/json' \ --header 'Content-type: application/json' \
-d '{ --data '{
"bucket_id": "12ab34cd56ef", "bucket_id": "12ab34cd56ef",
"database": "example-db", "database": "example-db",
"id": "example-mapping-id" "id": "example-mapping-id"
@ -62,10 +62,10 @@ To map an unmapped bucket to a database and retention policy, use the [`POST /db
- database and retention policy to map to bucket (`database` and `retention_policy`) - database and retention policy to map to bucket (`database` and `retention_policy`)
```sh ```sh
curl -XPOST https://cloud2.influxdata.com/api/v2/dbrps \ curl --request POST https://cloud2.influxdata.com/api/v2/dbrps \
-H "Authorization: Token YourAuthToken" \ --header "Authorization: Token YourAuthToken" \
-H 'Content-type: application/json' \ --header 'Content-type: application/json' \
-d '{ --data '{
"bucket_id": "12ab34cd56ef", "bucket_id": "12ab34cd56ef",
"database": "example-db", "database": "example-db",
"default": true "default": true
@ -95,8 +95,8 @@ To query a mapped bucket with InfluxQL, use the `/query` 1.x compatibility endpo
{{% /note %}} {{% /note %}}
```sh ```sh
curl -G https://cloud2.influxdata.com/query?database=MyDB&retention_policy=MyRP \ curl --request GET https://cloud2.influxdata.com/query?database=MyDB&retention_policy=MyRP \
-H "Authorization: Token YourAuthToken" \ --header "Authorization: Token YourAuthToken" \
--data-urlencode "q=SELECT used_percent FROM example-db.example-rp.example-measurement WHERE host=host1" --data-urlencode "q=SELECT used_percent FROM example-db.example-rp.example-measurement WHERE host=host1"
``` ```

View File

@ -17,8 +17,8 @@ Include your authentication token as an `Authorization` header in each request.
```sh ```sh
curl --request POST \ curl --request POST \
--url http://localhost:8086/api/v2/write?org=my-org&bucket=example-bucket \ http://localhost:8086/api/v2/write?org=my-org&bucket=example-bucket \
--header 'Authorization: Token YOURAUTHTOKEN' --header "Authorization: Token YOURAUTHTOKEN"
``` ```
## View InfluxDB v2 API Documentation ## View InfluxDB v2 API Documentation

View File

@ -81,16 +81,16 @@ The following precisions are available:
##### Query using basic authentication ##### Query using basic authentication
```sh ```sh
curl -G https://cloud2.influxdata.com/query \ curl --request GET https://cloud2.influxdata.com/query \
-u username:YourAuthToken \ --user "username:YourAuthToken" \
--data-urlencode "db=mydb" \ --data-urlencode "db=mydb" \
--data-urlencode "q=SELECT used_percent FROM mem WHERE host=host1" --data-urlencode "q=SELECT used_percent FROM mem WHERE host=host1"
``` ```
##### Query a non-default retention policy ##### Query a non-default retention policy
```sh ```sh
curl -G https://cloud2.influxdata.com/query \ curl --request GET https://cloud2.influxdata.com/query \
-H "Authorization: Basic username:YourAuthToken" \ --header "Authorization: Basic username:YourAuthToken" \
--data-urlencode "db=mydb" \ --data-urlencode "db=mydb" \
--data-urlencode "rp=customrp" \ --data-urlencode "rp=customrp" \
--data-urlencode "q=SELECT used_percent FROM mem WHERE host=host1" --data-urlencode "q=SELECT used_percent FROM mem WHERE host=host1"
@ -98,27 +98,27 @@ curl -G https://cloud2.influxdata.com/query \
##### Execute multiple queries ##### Execute multiple queries
```sh ```sh
curl -G https://cloud2.influxdata.com/query \ curl --request GET https://cloud2.influxdata.com/query \
-H "Authorization: Token YourAuthToken" \ --header "Authorization: Token YourAuthToken" \
--data-urlencode "db=mydb" \ --data-urlencode "db=mydb" \
--data-urlencode "q=SELECT * FROM mem WHERE host=host1;SELECT mean(used_percent) FROM mem WHERE host=host1 GROUP BY time(10m)" --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 ##### Return query results with millisecond Unix timestamps
```sh ```sh
curl -G https://cloud2.influxdata.com/query \ curl --request GET https://cloud2.influxdata.com/query \
-H "Authorization: Token YourAuthToken" \ --header "Authorization: Token YourAuthToken" \
--data-urlencode "db=mydb" \ --data-urlencode "db=mydb" \
--data-urlencode "rp=myrp" \ --data-urlencode "rp=myrp" \
--data-urlencode "q=SELECT used_percent FROM mem WHERE host=host1" --data-urlencode "q=SELECT used_percent FROM mem WHERE host=host1" \
--data-urlencode "epoch=ms" --data-urlencode "epoch=ms"
``` ```
##### Use curl to execute InfluxQL queries from a file ##### Use curl to execute InfluxQL queries from a file
```sh ```sh
curl -G https://cloud2.influxdata.com/query \ curl --request GET https://cloud2.influxdata.com/query \
-H "Authorization: Token YourAuthToken" \ --header "Authorization: Token YourAuthToken" \
--data-urlencode "db=mydb" \ --data-urlencode "db=mydb" \
-F "q=@path/to/influxql.txt" --form "q=@path/to/influxql.txt" \
-F "async=true" --form "async=true"
``` ```

View File

@ -71,22 +71,23 @@ The following precisions are available:
##### Write data using basic authentication ##### Write data using basic authentication
```sh ```sh
curl -XPOST https://cloud2.influxdata.com/write?db=mydb \ curl --request POST https://cloud2.influxdata.com/write?db=mydb \
-H "Authorization: Basic username:YourAuthToken" \ --header "Authorization: Basic username:YourAuthToken" \
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000" --data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000"
``` ```
##### Write data to a non-default retention policy ##### Write data to a non-default retention policy
```sh ```sh
curl -XPOST https://cloud2.influxdata.com/write?db=mydb&rp=customrp \ curl --request POST https://cloud2.influxdata.com/write?db=mydb&rp=customrp \
-H "Authorization: Basic username:YourAuthToken" \ --header "Authorization: Basic" \
--header "username:YourAuthToken" \
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000" --data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000"
``` ```
##### Write multiple lines of line protocol ##### Write multiple lines of line protocol
```sh ```sh
curl -XPOST https://cloud2.influxdata.com/write?db=mydb \ curl --request POST https://cloud2.influxdata.com/write?db=mydb \
-H "Authorization: Token YourAuthToken" \ --header "Authorization: Token YourAuthToken" \
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000 --data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000
measurement,host=host2 field1=14i,field2=12.7 1577836800000000000 measurement,host=host2 field1=14i,field2=12.7 1577836800000000000
measurement,host=host3 field1=5i,field2=6.8 1577836800000000000" measurement,host=host3 field1=5i,field2=6.8 1577836800000000000"
@ -94,14 +95,14 @@ measurement,host=host3 field1=5i,field2=6.8 1577836800000000000"
##### Write data with millisecond Unix timestamps ##### Write data with millisecond Unix timestamps
```sh ```sh
curl -XPOST https://cloud2.influxdata.com/write?db=mydb&precision=ms \ curl --request POST https://cloud2.influxdata.com/write?db=mydb&precision=ms \
-H "Authorization: Token YourAuthToken" \ --header "Authorization: Token YourAuthToken" \
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000" --data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000"
``` ```
##### Use curl to write data from a file ##### Use curl to write data from a file
```sh ```sh
curl -XPOST https://cloud2.influxdata.com/write?db=mydb \ curl --request POST https://cloud2.influxdata.com/write?db=mydb \
-H "Authorization: Token YourAuthToken" \ --header "Authorization: Token YourAuthToken" \
--data-binary @path/to/line-protocol.txt --data-binary @path/to/line-protocol.txt
``` ```

View File

@ -43,9 +43,9 @@ add a new secret to your organization.
<!-- --> <!-- -->
```sh ```sh
curl -XPATCH http://localhost:8086/api/v2/orgs/<org-id>/secrets \ curl --request PATCH http://localhost:8086/api/v2/orgs/<org-id>/secrets \
-H 'Authorization: Token YOURAUTHTOKEN' \ --header 'Authorization: Token YOURAUTHTOKEN' \
-H 'Content-type: application/json' \ --header 'Content-type: application/json' \
--data '{ --data '{
"<secret-key>": "<secret-value>" "<secret-key>": "<secret-value>"
}' }'

View File

@ -35,8 +35,8 @@ to delete one or more secrets.
<!-- --> <!-- -->
```bash ```bash
curl -XGET http://localhost:8086/api/v2/orgs/<org-id>/secrets/delete \ curl --request GET http://localhost:8086/api/v2/orgs/<org-id>/secrets/delete \
--H 'Authorization: Token YOURAUTHTOKEN' --header 'Authorization: Token YOURAUTHTOKEN' \
--data '{ --data '{
"secrets": [ "secrets": [
"<secret-key>" "<secret-key>"

View File

@ -43,9 +43,9 @@ to update a secret in your organization.
<!-- --> <!-- -->
```sh ```sh
curl -XPATCH http://localhost:8086/api/v2/orgs/<org-id>/secrets \ curl --request PATCH http://localhost:8086/api/v2/orgs/<org-id>/secrets \
-H 'Authorization: Token YOURAUTHTOKEN' \ --header 'Authorization: Token YOURAUTHTOKEN' \
-H 'Content-type: application/json' \ --header 'Content-type: application/json' \
--data '{ --data '{
"<secret-key>": "<secret-value>" "<secret-key>": "<secret-value>"
}' }'

View File

@ -29,6 +29,6 @@ to view your organization's secrets keys.
<!-- --> <!-- -->
```sh ```sh
curl -XGET http://localhost:8086/api/v2/orgs/<org-id>/secrets \ curl --request GET http://localhost:8086/api/v2/orgs/<org-id>/secrets \
-H 'Authorization: Token YOURAUTHTOKEN' --header 'Authorization: Token YOURAUTHTOKEN'
``` ```

View File

@ -94,7 +94,7 @@ When using the InfluxDB API `/write` endpoint to write data, set the `Content-En
header to `gzip` to compress the request data. header to `gzip` to compress the request data.
```sh ```sh
curl -XPOST "http://localhost:8086/api/v2/write?org=YOUR_ORG&bucket=YOUR_BUCKET&precision=s" \ curl --request POST "http://localhost:8086/api/v2/write?org=YOUR_ORG&bucket=YOUR_BUCKET&precision=s" \
--header "Authorization: Token YOURAUTHTOKEN" \ --header "Authorization: Token YOURAUTHTOKEN" \
--header "Content-Encoding: gzip" \ --header "Content-Encoding: gzip" \
--data-raw "mem,host=host1 used_percent=23.43234543 1556896326" --data-raw "mem,host=host1 used_percent=23.43234543 1556896326"

View File

@ -108,10 +108,11 @@ The `influx` CLI is installed with **InfluxDB OSS**. If you're using **InfluxDB
#### Delete data in InfluxDB Cloud #### Delete data in InfluxDB Cloud
```sh ```sh
curl -X POST 'https://us-west-2-1.aws.cloud2.influxdata.com/api/v2/delete?orgID=<ORGID>' curl --request POST \
-H 'Authorization: Token <TOKEN WITH WRITE PERMISSIONS' https://us-west-2-1.aws.cloud2.influxdata.com/api/v2/delete?orgID=<ORGID> \
-H 'Content-Type: application/json' --header 'Authorization: Token <TOKEN WITH WRITE PERMISSIONS' \
-d '{ --header 'Content-Type: application/json' \
--data '{
"predicate": "_measurement=\"<MEASUREMENT NAME>\" and _field=\"<FIELD>\"", "predicate": "_measurement=\"<MEASUREMENT NAME>\" and _field=\"<FIELD>\"",
"start": "2020-08-16T08:00:00Z", "start": "2020-08-16T08:00:00Z",
"stop": "2020-08-17T08:00:00Z" "stop": "2020-08-17T08:00:00Z"
@ -121,9 +122,10 @@ curl -X POST 'https://us-west-2-1.aws.cloud2.influxdata.com/api/v2/delete?orgID=
#### Delete data in InfluxDB OSS #### Delete data in InfluxDB OSS
```sh ```sh
curl -XPOST http://localhost:8086/api/v2/delete/?org=myOrg&bucket=myBucket \ curl --request POST http://localhost:8086/api/v2/delete/?org=myOrg&bucket=myBucket \
-H 'Authorization: Token <YOURAUTHTOKEN>' \ --header 'Authorization: Token <YOURAUTHTOKEN>' \
-d '{ --header 'Content-Type: application/json' \
--data '{
"start": "1970-01-01T00:00:00.00Z", "start": "1970-01-01T00:00:00.00Z",
"stop": "2020-01-01T00:00:00.00Z" "stop": "2020-01-01T00:00:00.00Z"
}' }'

View File

@ -36,7 +36,7 @@ Compressing write requests reduces network bandwidth, but increases server-side
{{% /code-tabs %}} {{% /code-tabs %}}
{{% code-tab-content %}} {{% code-tab-content %}}
```sh ```sh
curl -XPOST "http://localhost:8086/api/v2/write?org=YOUR_ORG&bucket=YOUR_BUCKET&precision=s" \ curl --request POST "http://localhost:8086/api/v2/write?org=YOUR_ORG&bucket=YOUR_BUCKET&precision=s" \
--header "Authorization: Token YOURAUTHTOKEN" \ --header "Authorization: Token YOURAUTHTOKEN" \
--data-raw " --data-raw "
mem,host=host1 used_percent=23.43234543 1556896326 mem,host=host1 used_percent=23.43234543 1556896326
@ -48,7 +48,7 @@ mem,host=host2 used_percent=27.18294630 1556896336
{{% /code-tab-content %}} {{% /code-tab-content %}}
{{% code-tab-content %}} {{% code-tab-content %}}
```bash ```bash
curl -XPOST "http://localhost:8086/api/v2/write?org=YOUR_ORG&bucket=YOUR_BUCKET&precision=s" \ curl --request POST "http://localhost:8086/api/v2/write?org=YOUR_ORG&bucket=YOUR_BUCKET&precision=s" \
--header "Authorization: Token YOURAUTHTOKEN" \ --header "Authorization: Token YOURAUTHTOKEN" \
--header "Content-Encoding: gzip" \ --header "Content-Encoding: gzip" \
--data-raw " --data-raw "