Data & API

Complete documentation available on GitHub.

Data Sources

Location: Apple Watch

The location data for this project is provided via GPS location from my Apple Watch. I'm pulling the location data from my iCloud account using the pyicloud python library.

Weather/AQI data: OpenWeatherMap.org

OpenWeatherMap.org (OWM) provides APIs for weather data, including AQI data. Using the lat and lon coordinates from my Apple Watch, I'm running API requests for AQI and weather data.

DynamoDB

The formatted data returned from OpenWeatherMap are uploaded to AWS DynamoDB tables (one for AQI data, one for Weather). Note that I am not storing the lat/lon data to the database: I have no interest in tracking my location over time, just the air quality and weather of wherever I am over time.

The tables in DynamoDB are configured with the partition key entry_type and sort key unix_time. I plan to eventually create daily/weekly/monthly averages, which would have an appropriate partition key to reflect that they are aggregated data, but for now, every entry in the tables have an entry_type of "sample".

With this combination of partition and sort key, I can query data that has a "sample" partition key and filter for specific ranges of time.

API: Flask and Zappa

Data are called from DynamoDB using an API developed in Flask and deployed via Zappa. Zappa automatically sets up AWS API Gateway and AWS Lambda to route the API calls and run the Flask app, respectively. The API call returns the previous 24 hours of data by filtering the unix_time sort key in DynamoDB.

API Routes

The Zappa deployment for the API is hosted here:
https://wthdz1g2p5.execute-api.us-west-1.amazonaws.com/dev/

Available Routes:
/api/v1.0/aqi_last24hrs
/api/v1.0/weather_last24hrs