Metadata-Version: 2.4
Name: infonite
Version: 0.0.1
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
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 access to the Infonite platform, including both the direct Clients API and the pre-built Widgets API.

## Installation

```bash
pip install infonite
```

## Overview

The SDK provides two primary clients depending on your integration needs:
- `InfoniteWidgetClient`: For clients integrating and managing pre-built widget experiences.
- `InfoniteDirectClient`: For clients building their own custom experiences over the core API.

Both clients automatically handle authentication headers (`X-APP-SECRET`), connection pooling, timeouts, and validation against the INFONITE servers upon initialization.

## Configuration

You can seamlessly initialize the SDK by deliberately passing credentials within your source code, or implicitly via standard OS Environment Variables. Storing these credentials as system variables guarantees your secrets remain out of your remote repositories securely, without requiring heavier standard ecosystem dependencies like `.env` packages.

### 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.

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

## Usage

### Zero-Code Configuration

```python
from infonite.clients import InfoniteWidgetClient

# Initializes seamlessly capturing standard OS variables from the runtime environment
client = InfoniteWidgetClient()

print(f"Verified App ID: {client.app_info.id}")
```

### Explicit Instantiation

#### Widgets API Integration

```python
from infonite.clients import InfoniteWidgetClient

client = InfoniteWidgetClient(app_secret="your_app_secret_here")

# Check your verified application state
print(f"Environment: {client.app_info.environment.value}")
print(f"Status: {client.app_info.status.value}")

# Manually refresh the application state from the server if networking fails gracefully
client.refresh_app_info()
```

#### Direct Clients API Integration

```python
from infonite.clients import InfoniteDirectClient

# Initialize the client for custom direct experiences architectures
client = InfoniteDirectClient(app_secret="your_app_secret_here")

print(f"Running in: {client.app_info.environment}")
```

## Features

- **Built-in Validation**: Validates your secret keys synchronously during `__init__` preventing late runtime execution failures.
- **Environment Native**: Fully reliant on `os.environ` fallback logic avoiding arbitrary configuration package dependencies.
- **Type Safety**: Fully typed models leveraging standard Python `dataclasses` alongside `Enum` logic (`AppEnvironment`, `AppStatus`).
- **Resiliency**: Built-in HTTP transport layer (`httpx`) bundled with automatic timeouts mapping ensuring resilient network executions.

## Development

To setup the project locally for development and testing pipelines:

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

# Create a virtual environment (optional but securely recommended)
python3 -m venv venv
source venv/bin/activate

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

# Run the test suite via the bash dev helper
./scripts/run_tests.sh
```

## License

MIT License
