Metadata-Version: 2.4
Name: django-api-utility
Version: 0.1.0
Summary: Reusable API integration utility for Django services
Author: Nexgensis
License: MIT
Project-URL: Repository, https://example.com/django-api-utility
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Django>=3.2
Requires-Dist: requests>=2.28
Requires-Dist: cryptography>=41.0
Requires-Dist: jsonschema>=4.0
Provides-Extra: test
Requires-Dist: pytest>=7.0; extra == "test"
Requires-Dist: pytest-django>=4.5; extra == "test"
Dynamic: license-file

# django-api-utility

Reusable API integration utility for Django services.

## Features
- Service + endpoint registry models
- Definition-key based endpoint resolution
- OAuth token fetch/refresh flow with encrypted token storage
- Consistent utility exceptions for config, token, and request errors
- Thin request wrapper with retry support

## Install
```bash
pip install -e .
```

## Django setup
Add app:
```python
INSTALLED_APPS = [
    # ...
    "django_api_utility",
]
```

## Definition key mapping
Provide a JSON mapping file via `EXTERNAL_DEFINITION_KEYS_FILE`, or use the packaged default at `config/external_definition_keys.json`.

Example:
```json
{
  "users_get": "service_users_get"
}
```

## Usage
```python
from django_api_utility import get_by_key, post_by_key

response = get_by_key("users_get", params={"page": 1})
create_response = post_by_key("users_create", payload={"name": "Alice"})
```

## Internal layout
- `django_api_utility/transport/`: HTTP transport and outbound execution primitives
- `django_api_utility/domain/`: definition keys, endpoint resolution, token lifecycle
- `django_api_utility/orchestration/`: request orchestration with retries and token refresh fallback

## Tests
```bash
pip install -e ".[test]"
pytest -q
```
