Metadata-Version: 2.4
Name: nectarpy
Version: 0.14.5
Summary: A Python API module designed to run queries on Nectar
Home-page: https://github.com/NectarProtocol/python-nectar-module
Author: Tamarin Health
Author-email: phil@tamarin.health
License: Apache License 2.0
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.11.6,<3.12
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: web3<7.0.0
Requires-Dist: python-dotenv==1.1.0
Requires-Dist: hpke==0.3.2
Requires-Dist: dill==0.3.9
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# PYTHON NECTAR MODULE

This is a Python API module designed to run queries on Nectar, add bucket information, and set policies.

## Install

```bash
pip3 install nectarpy
```

## Python Example

```python
from nectarpy import Nectar
```

```python
API_SECRET = "<api-secret>"
```

```python
nectar = Nectar(API_SECRET)
```

```python
policy_id = nectar.add_policy(
    allowed_categories=["*"],
    allowed_addresses=[],
    allowed_columns=["*"],
    valid_days=1000,
    usd_price=0.0123,
)
```

```python
TEE_DATA_URL = "https://<ip-address>:5229/"
```

```python
bucket_id = nectar.add_bucket(
    policy_ids=[policy_id],
    data_format="std1",
    node_address=TEE_DATA_URL,
)
```

```python
result = nectar.train_model(
    type="linear-regression",
    parameters='{"xcols":["heart_rate","age"],"ycol":"height"}',
    filters='[{"column":"smoking","filter":"=","value":false}]',
    use_allowlists=[False],
    access_indexes=[0],
    bucket_ids=[bucket_id],
    policy_indexes=[0],
)
```

```python
print(result)
```

## Integration Tests

### 1: Create a .env file

```
API_SECRET=0x123...
NETWORK_MODE=<localhost | moonbase | moonbeam>
TEE_DATA_URL=https://<ip-address>:5229/
```

### 2: Run

```bash
python3 tests.py
```
