Created
October 17, 2022 18:27
-
-
Save Sparrow0hawk/e1ecf697c22ac44a79c1049a4b05270b to your computer and use it in GitHub Desktop.
Simple POST request to influxdb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| headers = {"Authorization": "Token super-secret-token", | |
| "Content-Type": "text/plain; charset=utf-8", | |
| "Accept": "application/json"} | |
| data = "airSensors,sensor_id=THP0101 temperature=37.94,humidity=35.231,pressure=1010" | |
| res = requests.post("http://INFLUXDB_IP:8086/api/v2/write?org=home&bucket=weather-pi&precision=ns", | |
| headers=headers, | |
| data=data) | |
| print(res) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Need to make changes here to include an authorisation token from InfluxDB and include it as the value for the
Authorizationkey within theheadersdictionary, changeINFLUXDB_IPto the IP address of your influxdb instance, and change the URL parameter values fororgandbucketto whatever organisation and bucket you've created via influxdb.