Metadata-Version: 2.4
Name: localize-io-client
Version: 0.2.0
Summary: Python client for the Localize.io Public API (generated from OpenAPI)
Project-URL: Homepage, https://github.com/localizeio/hub
Project-URL: Documentation, https://docs.localize.io/api
Project-URL: Source, https://github.com/localizeio/hub/tree/main/sdks/python
Author: Localize.io
License-Expression: MIT
License-File: LICENSE
Keywords: ai,i18n,localization,tms,translation
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.11
Requires-Dist: attrs>=22.2.0
Requires-Dist: httpx<0.29.0,>=0.23.1
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: respx>=0.21; extra == 'dev'
Description-Content-Type: text/markdown

# localize-io-client

Python client for the [Localize.io](https://localize.io) Public API.

Generated from the platform's own OpenAPI 3.1 spec (`openapi.json`, committed alongside
this package) with [`openapi-python-client`](https://github.com/openapi-generators/openapi-python-client)
0.29.0. Full coverage of all 154 public operations across all 17 resource
groups — projects, translation jobs, translation memories, glossaries,
prompts, pipelines, post-editing sessions, agent sessions, approval requests,
workspace, TMS connections, style guides, storages, analytics, operations,
AI/LLM, webhooks, and languages.

Every operation ships four call styles: `sync`, `sync_detailed`, `asyncio`,
`asyncio_detailed` — the `_detailed` variants return the full `Response`
(status code, headers, parsed body); the plain variants return just the
parsed body (or `None` on an undocumented status code).

## Install

```bash
pip install localize-io-client
```

## Quick start

```python
from localize_io_client import AuthenticatedClient, DEFAULT_BASE_URL
from localize_io_client.api.projects import list_projects_projects_get

client = AuthenticatedClient(base_url=DEFAULT_BASE_URL, token="lh_your_api_key")

with client as client:
    response = list_projects_projects_get.sync(client=client)
    for project in response.data:
        print(project.id, project.name)
```

`DEFAULT_BASE_URL` is `https://hub.localize.io/api/public/v1` (the spec's
relative server URL resolved against the production host). Pass a different
`base_url` to `AuthenticatedClient` to target staging or a self-hosted
instance.

## Async

```python
import asyncio
from localize_io_client import AuthenticatedClient, DEFAULT_BASE_URL
from localize_io_client.api.projects import list_projects_projects_get

async def main():
    client = AuthenticatedClient(base_url=DEFAULT_BASE_URL, token="lh_your_api_key")
    async with client as client:
        response = await list_projects_projects_get.asyncio(client=client)
        for project in response.data:
            print(project.id, project.name)

asyncio.run(main())
```

## Error handling

Use the `_detailed` variants to inspect the raw response, or set
`raise_on_unexpected_status=True` on the client to raise
`localize_io_client.errors.UnexpectedStatus` for any status code not
documented in the OpenAPI spec:

```python
from localize_io_client import AuthenticatedClient, DEFAULT_BASE_URL
from localize_io_client.api.projects import get_project_projects_project_id_get

client = AuthenticatedClient(
    base_url=DEFAULT_BASE_URL,
    token="lh_your_api_key",
    raise_on_unexpected_status=True,
)

with client as client:
    response = get_project_projects_project_id_get.sync_detailed(
        client=client, project_id="00000000-0000-0000-0000-000000000000"
    )
    if response.status_code == 404:
        print("project gone or no access")
    else:
        project = response.parsed
```

Validation errors (HTTP 422) parse into the `HTTPValidationError` model,
available from `localize_io_client.models`.

## Layout

- `localize_io_client/client.py` — `Client` (unauthenticated) and
  `AuthenticatedClient` (sends `Authorization: Bearer <token>`).
- `localize_io_client/api/<group>/<operation>.py` — one module per operation,
  grouped by OpenAPI tag (`projects`, `translation_jobs`,
  `translation_memories`, `glossaries`, `prompts`, `pipelines`,
  `post_editing_sessions`, `agent_sessions`, `agent_approvals`, `workspace`,
  `tms_connections`, `style_guides`, `storages`, `analytics`, `operations`,
  `ai_llm`, `webhooks`, `languages`).
- `localize_io_client/models/` — typed `attrs` model for every request/response
  schema in the spec.
- `localize_io_client/errors.py` — `UnexpectedStatus` exception.
- `localize_io_client/types.py` — `UNSET` sentinel + `Response`/`File` helpers.

## Regenerating

The client is generated, not hand-written. To regenerate after the API
changes:

```bash
curl -s https://hub.localize.io/api/public/v1/openapi.json -o sdks/python/openapi.json
pip install openapi-python-client==0.29.0
openapi-python-client generate \
  --path sdks/python/openapi.json \
  --meta none \
  --overwrite \
  --output-path sdks/python/localize_io_client_regen
# then diff/merge sdks/python/localize_io_client_regen/ into sdks/python/localize_io_client/
```

Do not hand-edit files under `localize_io_client/api/` or
`localize_io_client/models/` — those are fully regenerated. `__init__.py`
carries one hand-added constant (`DEFAULT_BASE_URL`) that must be re-applied
after regeneration.

## Development

```bash
pip install -e ".[dev]"
pytest
```

## License

MIT.
