# iLevel Investment Portfolio API Integration

**Source**: `prototype/src/talentverse/nodes/ilevel_connector.py`
**Protocol**: HTTP/requests + Async (aiohttp)
**Auth**: OAuth2 (client credentials flow)
**Purpose**: Fetch investment portfolio performance data for investment professionals

### Environment Variables

```env
ILEVEL_CLIENT_ID=
ILEVEL_CLIENT_SECRET=
```

## OAuth2 Authentication

```python
class ILevelAPIClient:
    def __init__(self, base_url, client_id, client_secret):
        self.base_url = base_url
        self.client_id = client_id
        self.client_secret = client_secret
        self._access_token = None

    def _authenticate(self):
        """OAuth token exchange via client credentials."""
        token_url = f"{self.base_url}/token"
        auth_data = {
            "grant_type": "client_credentials",
            "client_id": self.client_id,
            "client_secret": self.client_secret
        }
        response = requests.post(token_url, data=auth_data)
        if response.status_code == 200:
            self._access_token = response.json()["access_token"]

    def _get_auth_headers(self):
        if not self._access_token:
            self._authenticate()
        return {
            "Authorization": f"Bearer {self._access_token}",
            "Content-Type": "application/json"
        }
```

## Key Features

- Portfolio performance metrics retrieval
- Investment data correlated with employee assignments
- TalentVerse framework score calculation for investment professionals
- File-based caching (same pattern as BIPO connector)
- NO MOCK DATA policy - production only

## Caching Pattern (Shared with BIPO)

```python
# Same MD5-based cache key generation
cache_dir = Path.home() / ".talentverse" / "cache" / "ilevel"
cache_ttl = 3600  # 1 hour default

# Cache key: MD5 of endpoint + request data
# File: {cache_dir}/{hash}.json
# Format: {"data": {...}, "timestamp": float, "expires_at": float}
```

## Note
The iLevel connector follows the same Kailash Node architecture as BIPO and Profit.co connectors, using `Node` base class with `get_parameters()` and `execute()` methods. The full file is 1800+ lines including portfolio scoring algorithms.
