from datetime import *from pytz import timezoneeastern = timezone("EST")
Sentenai's python library is safe to
import *. When writing queries this can make it easier to work with. Let's start by initializing an API Client:
from sentenai import Sentenai, hql, Vsentenai = Sentenai(auth_key="<api-key>")
This sentenai client is not a "connection" to Sentenai, but provides methods which expose Sentenai's API.
This is useful for seeing what's available, but if we know the name of a stream we can reference it by using the
.Stream() function. There is no need to create a stream as a stream is instantiated within Sentenai as soon as data is logged to that stream.
hweather = sentenai.Stream("weather-boston-hour")print(weather)# Note that the print function returns "prettified" syntax.(stream "weather-boston-hour")
Streams have a __bool__ method so you can use a stream's existence in branches. A new stream is created when an event is put into a non-existent stream. Streams with zero events may still exist if all events have been deleted from them but the stream itself has not been deleted.
The name of a stream is accessible with the
Stream paths that contain a reserved word can be made as follows: