Metadata-Version: 2.4
Name: infonite
Version: 0.3.0
Summary: Official Python SDK for the INFONITE API
Author-email: Infonite Technologies <support@infonite.tech>
Project-URL: Homepage, https://infonite.tech
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.24.0
Requires-Dist: python-dotenv>=1.0.0
Provides-Extra: test
Requires-Dist: pytest>=7.0.0; extra == "test"
Requires-Dist: respx>=0.20.0; extra == "test"

# Infonite Python SDK

The official Python SDK for the INFONITE API. This SDK provides simple, convenient asynchronous access to the Infonite platform, including both the core internal Clients API and the pre-built Widgets API.

## Installation

```bash
pip install infonite
```

## Overview

The SDK relies **entirely on modern Python standard asynchronous patterns (`asyncio`)** ensuring zero-blocking event loop integrations out-of-the-box for highly concurrent backend systems:
- `InfoniteWidgetClient`: For backend pipelines integrating and securely configuring remote Widget configurations.
- `InfoniteDirectClient`: For architects building raw standalone abstractions directly addressing Infonite APIs.

## Configuration

You can seamlessly initialize the SDK by deliberately passing credentials within your source code, or implicitly via standard OS Environment Variables. The SDK natively incorporates `python-dotenv`, meaning it will automatically detect and securely load any `.env` file present at the root of your application execution context.

### Supported Environment Variables
- `INFONITE_APP_SECRET`: Your fundamental application integration secret token.
- `INFONITE_WIDGETS_API`: *(Optional)* Absolute URL override for the Widgets API infrastructure.
- `INFONITE_CLIENTS_API`: *(Optional)* Absolute URL override for the Custom Clients direct API.
- `INFONITE_LOG_LEVEL`: *(Optional)* Defines standard Python SDK logging levels (e.g., `DEBUG`, `INFO`). Extremely useful for debugging active application connections securely evaluating contextual TCP pools.

```bash
export INFONITE_APP_SECRET="sk_prod_12345"
export INFONITE_WIDGETS_API="https://sandbox-widgets.infonite.tech"
```

## Usage

### Zero-Code Configuration

```python
import asyncio
from infonite.clients import InfoniteWidgetClient

# Execute natively leveraging local contexts inside Python operational scopes
async def main():
    async with InfoniteWidgetClient() as client:
        print(f"Verified App ID: {client.app_info.id}")

asyncio.run(main())
```

### Explicit Instantiation

#### Widgets API Integration

```python
import asyncio
from infonite.clients import InfoniteWidgetClient

async def evaluate_environment():
    async with InfoniteWidgetClient(app_secret="your_app_secret_here") as client:
        # Check your internally authorized operational state securely
        print(f"Environment: {client.app_info.environment.value}")
        print(f"Status: {client.app_info.status.value}")

        # Manually invoke connection validations updating active configurations
        await client.refresh_app_info()
        
asyncio.run(evaluate_environment())
```

#### Direct Clients API Integration (Explicit Connect)

```python
import asyncio
from infonite.clients import InfoniteDirectClient

async def custom_worker():
    # Execute native independent TCP configurations for restrictive orchestrators
    client = InfoniteDirectClient(app_secret="your_app_secret_here")
    await client.connect()
    
    print(f"Execution Target: {client.app_info.environment.value}")
    
    # Properly finalize underlying TCP mappings guaranteeing memory hygiene natively
    await client.close()

asyncio.run(custom_worker())
```

## Features

- **Built-in Validation**: Validates your secret keys asynchronously fetching data proactively protecting downstream pipelines safely.
- **Environment Native**: Fully reliant on elegant `.env` parsing mapping directly into `os.environ` fallback logic securely.
- **Async Exclusive**: Implemented radically adopting asynchronous Python 3 patterns `httpx.AsyncClient` maximizing parallel executions.
- **Context Handling**: Adopts exclusively context managers ensuring unmapped TCP socket leakage is structurally avoided.

## Development

```bash
# Clone the repository natively
git clone git@github.com:INFONITE-Technologies/py-infonite-sdk.git
cd py-infonite-sdk

# Create a securely localized virtual environment 
python3 -m venv venv
source venv/bin/activate

# Install with testing distribution dependencies ensuring tests pass
pip install -e ".[test]"

# Run the localized async evaluation bash logic suite
./scripts/run_tests.sh
```

## License

MIT License
