PurpleAirAPIConstants module

Constants and configuration values used throughout the PurpleAir API wrapper.

Overview

This module contains all the constant values used by the API wrapper, including:

  • API endpoint URLs

  • Valid field names for sensor data queries

  • Default configuration values

  • API version information

  • Valid parameter values for API requests

These constants ensure consistency across the API and make it easier to reference valid options when making API calls.

API Reference

Copyright 2024 carlkidcrypto, All rights reserved. A python with constants with for use in PurpleAirAPI.py

PurpleAirAPIConstants.ACCEPTED_FIELD_NAMES_DICT = {'0.3_um_count': 0.0, '0.3_um_count_a': 0.0, '0.3_um_count_b': 0.0, '0.5_um_count': 0.0, '0.5_um_count_a': 0.0, '0.5_um_count_b': 0.0, '1.0_um_count': 0.0, '1.0_um_count_a': 0.0, '1.0_um_count_b': 0.0, '10.0_um_count': 0.0, '10.0_um_count_a': 0.0, '10.0_um_count_b': 0.0, '2.5_um_count': 0.0, '2.5_um_count_a': 0.0, '2.5_um_count_b': 0.0, '5.0_um_count': 0.0, '5.0_um_count_a': 0.0, '5.0_um_count_b': 0.0, 'altitude': 0.0, 'analog_input': 0.0, 'channel_flags': 0, 'channel_flags_auto': 0, 'channel_flags_manual': 0, 'channel_state': 0, 'confidence': 0, 'confidence_auto': 0, 'confidence_manual': 0, 'date_created': 0, 'firmware_upgrade': '', 'firmware_version': '', 'hardware': '', 'humidity': 0, 'humidity_a': 0, 'humidity_b': 0, 'icon': 0, 'last_modified': 0, 'last_seen': 0, 'latitude': 0.0, 'led_brightness': 0, 'location_type': 0, 'longitude': 0.0, 'memory': 0, 'model': '', 'name': '', 'ozone1': 0.0, 'pa_latency': 0, 'pm1.0': 0.0, 'pm1.0_a': 0.0, 'pm1.0_atm': 0.0, 'pm1.0_atm_a': 0.0, 'pm1.0_atm_b': 0.0, 'pm1.0_b': 0.0, 'pm1.0_cf_1': 0.0, 'pm1.0_cf_1_a': 0.0, 'pm1.0_cf_1_b': 0.0, 'pm10.0': 0.0, 'pm10.0_a': 0.0, 'pm10.0_atm': 0.0, 'pm10.0_atm_a': 0.0, 'pm10.0_atm_b': 0.0, 'pm10.0_b': 0.0, 'pm10.0_cf_1': 0.0, 'pm10.0_cf_1_a': 0.0, 'pm10.0_cf_1_b': 0.0, 'pm2.5': 0.0, 'pm2.5_10minute': 0.0, 'pm2.5_10minute_a': 0.0, 'pm2.5_10minute_b': 0.0, 'pm2.5_1week': 0.0, 'pm2.5_1week_a': 0.0, 'pm2.5_1week_b': 0.0, 'pm2.5_24hour': 0.0, 'pm2.5_24hour_a': 0.0, 'pm2.5_24hour_b': 0.0, 'pm2.5_30minute': 0.0, 'pm2.5_30minute_a': 0.0, 'pm2.5_30minute_b': 0.0, 'pm2.5_60minute': 0.0, 'pm2.5_60minute_a': 0.0, 'pm2.5_60minute_b': 0.0, 'pm2.5_6hour': 0.0, 'pm2.5_6hour_a': 0.0, 'pm2.5_6hour_b': 0.0, 'pm2.5_a': 0.0, 'pm2.5_alt': 0.0, 'pm2.5_alt_a': 0.0, 'pm2.5_alt_b': 0.0, 'pm2.5_atm': 0.0, 'pm2.5_atm_a': 0.0, 'pm2.5_atm_b': 0.0, 'pm2.5_b': 0.0, 'pm2.5_cf_1': 0.0, 'pm2.5_cf_1_a': 0.0, 'pm2.5_cf_1_b': 0.0, 'position_rating': 0, 'pressure': 0.0, 'pressure_a': 0.0, 'pressure_b': 0.0, 'primary_id_a': 0, 'primary_id_b': 0, 'primary_key_a': '', 'primary_key_b': '', 'private': 0, 'rssi': 0, 'secondary_id_a': 0, 'secondary_id_b': 0, 'secondary_key_a': '', 'secondary_key_b': '', 'temperature': 0, 'temperature_a': 0, 'temperature_b': 0, 'uptime': 0, 'voc': 0.0, 'voc_a': 0.0, 'voc_b': 0.0}

Store the dict/json keys to access data fields. And define default empty/null values for them These keys are derived from the PurpleAir documentation: https://api.purpleair.com/#api-sensors-get-sensor-data

PurpleAirAPIConstants.ERROR_CODES_LIST = [400, 402, 403, 404, 409, 415, 503]

Accepted Error Codes

PurpleAirAPIConstants.PRINT_DEBUG_MSGS = False

A constant to see if debug statements are enabled in the PurpleAirAPI module.

PurpleAirAPIConstants.SUCCESS_CODE_LIST = [200, 201, 204]

Success Code