Using the API¶
API objects are the primary way to get access to assets and events. CityIq
is the top level access
object. The API offers access to Locations, Events and Events.
Typically, you will construct CityIq
from a Config
. If a configuration is not specific,
the system will look for the file in default locations. You can also override individual configuration parameters
with keyword arguments to the constructor.
Metadata Access¶
Metadata, for both locations and assets, can be fetched with property accessors. The bounding box for the queries can
be set in the configuration, or on the CityIq
constructor.
The asset metadata properties are:
CityIq.assets
: All assetsCityIq.nodes
: Nodes, the parents for other assets on a poleCityIq.cameras
: All assetsCityIq.em_sensors
: ?CityIq.env_sensors
: Environmental sensors
The location metadata properties are:
CityIq.locations
: All locationsCityIq.walkways
:CityIq.parking_zones
:CityIq.traffic_lane
:
Events can be fetched with cityiq.api.CityIq.events()
Each of these acessor properties or functions returns a generator that generates objects of a specific type, one base class for each of Locations, Assets or Events:
Asset
Location
Event
bbox = '32.718987:-117.174244,32.707356:-117.154850'
c = CityIq(bbox=bbox) # Use default config, override bbox
# Get Locations
locations = list(c.locations)
# Get the assets at this location:
for location in locations:
do_something_with(location.assets