Skip to main content

A Python API module designed to run queries on Nectar

Project description

PYTHON NECTAR MODULE

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


Installation

To install the nectarpy module, use the following command:

pip3 install nectarpy

Getting Started

Importing the Module

To use nectarpy, first import the Nectar class:

from nectarpy import Nectar

Setting Up API Credentials

You must provide your API_SECRET key to authenticate requests:

API_SECRET = "<api-secret>"

Creating an Instance

Initialize the Nectar client using the API secret:

nectar = Nectar(API_SECRET)

Policy Management

Adding Policies

Policies define which columns can be accessed and under what conditions.

Adding a Policy for All Columns

Allows access to all columns with a validity period of 1000 days and a price of 0.0123 USD:

policy_id = nectar.add_policy(
    allowed_categories=["*"],                   # All data categories are allowed
    allowed_addresses=["<address-value>"],      # Only this wallet address is allowed to query. Example: 0x39Ccc3519e16ec309Fe89Eb782792faFfB1b399d
    allowed_columns=["*"],                      # All columns in the dataset are accessible
    valid_days=1000,                            # Policy is valid for 1000 days
    usd_price=0.0123,                           # Cost per query in USD
)

Adding a Policy for Specific Columns

Restricts access to only the age and height columns:

policy_id = nectar.add_policy(
    allowed_categories=["*"],                   # All data categories are allowed
    allowed_addresses=["<address-value>"],      # Only this wallet address is allowed to query. Example: 0x39Ccc3519e16ec309Fe89Eb782792faFfB1b399d
    allowed_columns=["age", "height"],          # Only the age and height column in the dataset are accessible
    valid_days=1000,                            # Policy is valid for 1000 days
    usd_price=0.0123,                           # Cost per query in USD
)

Parameters

Parameter Description
allowed_categories List of allowed data categories (e.g., ["ONLY_PHARMA"], ["*"] for all).
allowed_addresses List of wallet addresses allowed to access this policy, this address can be found at https://nectar.tamarin.health. Required
allowed_columns List of accessible data columns (e.g., ["age", "income"], or ["*"]).
valid_days How long (in days) the policy remains active.
usd_price Price per access in USD (floating-point number).


Bucket Management

Adding a Bucket

The TEE_DATA_URL represents the secure enclave node where the data is stored.

TEE_DATA_URL = "tls://<ip-address>:5229"
bucket_id = nectar.add_bucket(
    policy_ids=[policy_id],
    data_format="std1",
    node_address=TEE_DATA_URL,
)

Executing Queries

You can retrieve results from stored data using defined policies and bucket IDs.

print(bucket_id)

Exception Handling

Case 1: API_SECRET Has No Balance

If your API_SECRET does not have sufficient funds, transactions will fail.

API_SECRET = "<api-secret>"
nectar = Nectar(API_SECRET)
policy_id = nectar.add_policy(
    allowed_categories=["*"],
    allowed_addresses=[],
    allowed_columns=["*"],
    valid_days=1000,
    usd_price=0.0123,
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dev_nectarpy-0.0.48.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dev_nectarpy-0.0.48-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file dev_nectarpy-0.0.48.tar.gz.

File metadata

  • Download URL: dev_nectarpy-0.0.48.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for dev_nectarpy-0.0.48.tar.gz
Algorithm Hash digest
SHA256 15b8d2aca9711153e69d0ee8a77e3d47fbe346273b8176e4f38b18c553b08e47
MD5 de1f50edea4e2ef41b4cd25c56c5d165
BLAKE2b-256 334db6e6109772a236ad2794cf5cd47039fcc5caff51640c10aeb5ece32e746e

See more details on using hashes here.

File details

Details for the file dev_nectarpy-0.0.48-py3-none-any.whl.

File metadata

  • Download URL: dev_nectarpy-0.0.48-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for dev_nectarpy-0.0.48-py3-none-any.whl
Algorithm Hash digest
SHA256 56d9d2f8843d207c40e46ea9494cdf6abe2e103df283e089da49d4852aed3b46
MD5 df94dc6507a9aa55b1d8bf7dfcef2f01
BLAKE2b-256 1a5bf431a814d2bcfd908fc2db625e32de11b42e3a2eb0ca86486ac20913f1c7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page