Python code to find datetime of first measurement

Hello! I hope you’re doing well. I’m still new to working with Python and the new API, is there an existing code that I can use to find the datetime for the first measurement collected by a specific sensor? If there isn’t, do you know where would be a good place to start? Thank you in advance.

—Ben

The “date_created” field returned by the API for a sensor is described as “The UNIX time stamp from when the device was created.”. (see [https://api.purpleair.com/#api-sensors-get-sensor-data](https://api.purpleair.com/#api-sensors-get-sensor-data))

That might not be the time of the “first” measurement by a specific sensor, but it would seem that there can’t be any measurements older than that time.

Since the value is a UNIX timestamp, you can use datetime.fromtimestamp() to convert it to a Python datetime object.