Skip to content

Instantly share code, notes, and snippets.

@Sparrow0hawk
Created October 17, 2022 18:27
Show Gist options
  • Select an option

  • Save Sparrow0hawk/e1ecf697c22ac44a79c1049a4b05270b to your computer and use it in GitHub Desktop.

Select an option

Save Sparrow0hawk/e1ecf697c22ac44a79c1049a4b05270b to your computer and use it in GitHub Desktop.
Simple POST request to influxdb
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)
@Sparrow0hawk
Copy link
Author

Need to make changes here to include an authorisation token from InfluxDB and include it as the value for the Authorization key within the headers dictionary, change INFLUXDB_IP to the IP address of your influxdb instance, and change the URL parameter values for org and bucket to whatever organisation and bucket you've created via influxdb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment