cyberjunky / python-garminconnect

Python 3 API wrapper for Garmin Connect to get activity statistics
MIT License
966 stars 151 forks source link

Add blood pressure endpoint and function #120

Closed psdupvi closed 1 year ago

psdupvi commented 1 year ago

Adds a get_blood_pressure function that calls a newly added blood pressure URL and returns blood pressure summaries and detailed measurements for each day.

There may be a better way to get an individual day, but as this works with a single date, it's fine.

Days without blood pressure measurements do not appear in the data.

-------------------- api.get_blood_pressure('2023-01-19, 2023-01-26') --------------------
{
    'from': '2023-01-19',
    'until': '2023-01-26',
    'measurementSummaries':
        [
            {
                'startDate': '2023-01-26',
                'endDate': '2023-01-26',
                'highSystolic': 119,
                'highDiastolic': 72,
                'lowSystolic': 118,
                'lowDiastolic': 71,
                'numOfMeasurements': 3,
                'category': 'NORMAL',
                'measurements':
                    [
                        {'version': ****,
                         'systolic': **,
                         'diastolic': **,
                         'pulse': None,
                         'multiMeasurement': False,
                         'notes': '',
                         'sourceType': 'MANUAL',
                         'measurementTimestampLocal': '2023-01-26T17:34:50.822',
                         'measurementTimestampGMT': '2023-01-26T22:34:50.822',
                         'category': 'NORMAL'
                         },
                         ...
                    ]
            },
            {
                'startDate': '2023-01-23',
                'endDate': '2023-01-23',
                'highSystolic': 134,
                'highDiastolic': 78,
                'lowSystolic': 134,
                'lowDiastolic': 78,
                'numOfMeasurements': 1,
                'category': 'STAGE_1_HIGH',
                'measurements':
                    [
                        {
                            'version': ****,
                            'systolic': **,
                            'diastolic': **,
                            'pulse': None,
                            'multiMeasurement': False,
                            'notes': '',
                            'sourceType': 'MANUAL',
                            'measurementTimestampLocal': '2023-01-23T17:32:18.728',
                            'measurementTimestampGMT': '2023-01-23T22:32:18.728',
                            'category': 'STAGE_1_HIGH'
                        }
                    ]
            },
            ...
        ],
    'categoryStats': {
                        'from': '2023-01-19',
                        'until': '2023-01-26',
                        'noOfDaysNormal': 1,
                        'noOfDaysElevated': 2,
                        'noOfDaysStage1': 1,
                        'noOfDaysStage2': 1,
                        'noOfDaysCritical': 0
                      }
}
psdupvi commented 1 year ago

Added to example.py with a second/third commit (second I tried to use 'bp' but I missed that it's a single character input).

cyberjunky commented 1 year ago

Very nice, will merge, and create new version soon!