Skip to content

Commit 7edd83b

Browse files
committed
WIP: adding python example
1 parent 956659c commit 7edd83b

File tree

1 file changed

+30
-0
lines changed
  • content/shared/influxdb3-admin/tokens

1 file changed

+30
-0
lines changed

content/shared/influxdb3-admin/tokens/_index.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The mechanism for providing your token depends on the client you use to interact
1010
{{% tabs %}}
1111
[influxdb3 CLI](#influxdb3-cli-auth)
1212
[cURL](#curl-auth)
13+
[Python (requests)](#python-auth-requests)
1314
{{% /tabs %}}
1415

1516
{{% tab-content %}}
@@ -63,6 +64,35 @@ Replace `your-token` with your actual InfluxDB 3 token.
6364

6465
{{% /tab-content %}}
6566

67+
{{% tab-content %}}
68+
69+
Use Python with the `requests` library to send an authenticated query:
70+
71+
{{% code-placeholders "YOUR_TOKEN" %}}
72+
73+
```python
74+
import requests
75+
76+
url = "http://localhost:8181/api/v3/query_sql"
77+
headers = {
78+
"Authorization": "Bearer YOUR_TOKEN",
79+
"Content-Type": "application/json"
80+
}
81+
data = {
82+
"db": "example-db",
83+
"sql": "SELECT * FROM 'example-table' WHERE time > now() - INTERVAL '10 minutes'"
84+
}
85+
86+
response = requests.post(url, json=data, headers=headers)
87+
print(response.json())
88+
```
89+
90+
{{% /code-placeholders %}}
91+
92+
Replace `YOUR_TOKEN` with your InfluxDB 3 token.
93+
94+
{{% /tab-content %}}
95+
6696
{{< /tabs-wrapper >}}
6797

6898
{{< children hlevel="h2" readmore=true hr=true >}}

0 commit comments

Comments
 (0)