Metadata-Version: 2.4
Name: autonomath
Version: 0.1.0
Summary: Python SDK for the jpcite API (Japanese institutional data: subsidies, loans, tax rulesets, 採択事例).
Project-URL: Homepage, https://jpcite.com
Project-URL: Repository, https://github.com/shigetosidumeda-cyber/jpintel-mcp
Project-URL: Bug Tracker, https://github.com/shigetosidumeda-cyber/jpintel-mcp/issues
Author: Bookyou K.K.
License: MIT
Keywords: autonomath,japan,mcp,sdk,subsidy
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: httpx>=0.28
Requires-Dist: pydantic>=2.9
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
Requires-Dist: pytest>=8.3; extra == 'dev'
Requires-Dist: ruff>=0.8; extra == 'dev'
Description-Content-Type: text/markdown

# autonomath (Python SDK)

Python client for the [AutonoMath](https://autonomath.ai) REST API - a catalog
of Japanese institutional programs (subsidies, loans, tax incentives) with an
exclusion-rule engine.

## Install

```bash
pip install autonomath
```

(Currently unpublished; install locally with `pip install -e path/to/sdk/python`.)

## Quick start

```python
from autonomath import Client

c = Client(api_key="am_...")  # or leave None for anonymous free tier

meta = c.meta()
print(meta.total_programs, meta.tier_counts)

resp = c.search_programs(tier=["S", "A"], prefecture="東京都", limit=10)
for p in resp.results:
    print(p.unified_id, p.primary_name, p.tier)

detail = c.get_program(resp.results[0].unified_id)
print(detail.enriched)

check = c.check_exclusions([p.unified_id for p in resp.results])
for hit in check.hits:
    print(hit.rule_id, hit.severity, hit.programs_involved)
```

## Async

```python
import asyncio
from autonomath import AsyncClient

async def main():
    async with AsyncClient(api_key="am_...") as c:
        meta = await c.meta()
        print(meta.total_programs)

asyncio.run(main())
```

## Configuration

| Option        | Default                     | Notes                                         |
| ------------- | --------------------------- | --------------------------------------------- |
| `api_key`     | `None`                      | `X-API-Key` header. `None` = anonymous/free.  |
| `base_url`    | `https://api.autonomath.ai` | Override for self-hosted deployments.         |
| `timeout`     | `30.0`                      | Per-request seconds.                          |
| `max_retries` | `3`                         | Applied to 429 and 5xx responses.             |

Retry behavior:

- `429 Too Many Requests` respects the `Retry-After` header (seconds).
- `5xx` retried with exponential backoff (0.5s, 1s, 2s, ...).
- 4xx other than 429 are raised immediately.

## Errors

All SDK errors inherit from `autonomath.AutonoMathError`:

- `AuthError` (401 / 403)
- `NotFoundError` (404)
- `RateLimitError` (429, carries `retry_after`)
- `ServerError` (5xx)

`autonomath.JpintelError` is retained as a deprecated alias for `AutonoMathError`.
New code should import `AutonoMathError`.

## Develop

```bash
cd sdk/python
python -m venv .venv
.venv/bin/pip install -e ".[dev]"
.venv/bin/pytest
```
