Metadata-Version: 2.4
Name: pylibrelinkup
Version: 0.9.1
Summary: A client for the Abbott LibreLinkUp API
Author-email: Rob Berwick <rob.berwick@gmail.com>
License: MIT License
        
        Copyright (c) 2024 Rob Berwick
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Homepage, https://github.com/robberwick/pylibrelinkup
Project-URL: Issues, https://github.com/robberwick/pylibrelinkup/issues
Project-URL: Documentation, https://pylibrelinkup.readthedocs.io/
Keywords: librelink,librelinkup,abbott,diabetes,glucose,api,client,health,medical,blood-sugar,continuous-glucose-monitoring,cgm
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.31.0
Requires-Dist: pydantic>=2.5.0
Provides-Extra: docs
Requires-Dist: sphinx<8.1,>=8.0.2; extra == "docs"
Requires-Dist: sphinx-rtd-theme<3.1,>=3.0.0rc4; extra == "docs"
Requires-Dist: sphinx-autobuild<2025.0,>=2024.10.3; extra == "docs"
Requires-Dist: sphinx-autodoc-typehints<2.5,>=2.4.4; extra == "docs"
Requires-Dist: autodoc_pydantic<2.3,>=2.2.0; extra == "docs"
Requires-Dist: enum-tools[sphinx]<0.13,>=0.12.0; extra == "docs"
Requires-Dist: setuptools_scm<8.2,>=8.1.0; extra == "docs"
Provides-Extra: dev
Requires-Dist: black; extra == "dev"
Requires-Dist: isort; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Requires-Dist: types-requests; extra == "dev"
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Requires-Dist: pytest-mock; extra == "test"
Requires-Dist: polyfactory; extra == "test"
Requires-Dist: responses; extra == "test"
Dynamic: license-file

# pylibrelinkup

`pylibrelinkup` is a Python client for the LibreLinkUp API, which allows you to interact with the LibreLinkUp service to retrieve glucose data and other related information. This project is a Python implementation inspired by the [libre-link-up-api-client](https://github.com/DiaKEM/libre-link-up-api-client) project.

![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pylibrelinkup) ![PyPI - Version](https://img.shields.io/pypi/v/pylibrelinkup) ![PyPI - License](https://img.shields.io/pypi/l/pylibrelinkup) ![Read the Docs](https://img.shields.io/readthedocs/pylibrelinkup) ![PyPI - Downloads](https://img.shields.io/pypi/dm/pylibrelinkup) 




## Installation

To install `pylibrelinkup`, you can use `pip`:

```bash
pip install pylibrelinkup
```

## Usage

### Initialization

First, you need to import the necessary modules, initialize the client, and authenticate with your LibreLinkUp credentials:

```python
from pylibrelinkup import PyLibreLinkUp

client = PyLibreLinkUp(email='your_username', password='your_password')
client.authenticate()
```

### Getting Patient List

You can fetch the list of patients using the `get_patients` method:

```python
patient_list = client.get_patients()
print(patient_list)
```

### Getting Patient data

PyLibreLinkUp provides three methods to retrieve patient data: `current`, `graph`, and `logbook`. 

- The `current` method retrieves the most recent glucose measurement reported by the LLU api for a patient.
- The `graph` method retrieves the glucose measurements for the previous 12 hours which are used to display the recent history graph in the LLU app.
- The `logbook` method retrieves the glucose event data for approximately the last two weeks.

All three methods accept a `patient_identifier` parameter in the form of a `UUID`, `str`, or `Patient` object.

**Note:** The `read` method also exists as a way to retrieve both recent and latest patient data, but it is deprecated and will be removed in a future release. Use the `graph` method for retrieving graph data and `latest` to access the most recent glucose measurement.

#### Current Glucose:

```python
latest_glucose = client.latest(patient_identifier=patient_list[0])
print(latest_glucose)
```

#### Graph Data:

```python
graph_data = client.graph(patient_identifier=patient_list[0])
print(graph_data)
```


#### Logbook Data:

```python
logbook_data = client.logbook(patient_identifier=patient_list[0])
print(logbook_data)
```

full example:

```python
from pylibrelinkup import PyLibreLinkUp

client = PyLibreLinkUp(email='your_username', password='your_password')
client.authenticate()
patient_list = client.get_patients()
print(patient_list)
patient = patient_list[0]
print(f"latest: {client.latest(patient_identifier=patient)}")
graph_data = client.graph(patient_identifier=patient)
print(f"graph data ({len(graph_data)} measurements):")
for measurement in graph_data:
    print(f"{measurement.value} {measurement.timestamp} {measurement.factory_timestamp}")
logbook_data = client.logbook(patient_identifier=patient)
print(f"logbook data: ({len(logbook_data)} entries)")
for measurement in logbook_data:
    print(f"{measurement.value} {measurement.timestamp} {measurement.factory_timestamp}")
```

For full documentation, please refer to the [API documentation](https://pylibrelinkup.readthedocs.io/en/latest/).
