Metadata-Version: 2.4
Name: inventree-sdk
Version: 0.1.1
Summary: Python SDK for the InvenTree API
Project-URL: Homepage, https://gitlab.s4l.link/matt/inventree-sdk
Project-URL: Documentation, https://gitlab.s4l.link/matt/inventree-sdk#readme
Project-URL: Repository, https://gitlab.s4l.link/matt/inventree-sdk.git
Project-URL: Issues, https://gitlab.s4l.link/matt/inventree-sdk/issues
Author-email: Generated by OpenCode <nocode@example.com>
License: MIT
Keywords: api,inventory,inventree,rest,sdk
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Requires-Dist: httpx>=0.27.0
Requires-Dist: pydantic-settings>=2.0.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: python-dotenv>=1.0.0
Provides-Extra: dev
Requires-Dist: mypy>=1.8.0; extra == 'dev'
Requires-Dist: pre-commit>=3.6.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Description-Content-Type: text/markdown

# inventree-sdk

Python SDK for the InvenTree API.

It is designed to support shared integrations across projects like `stocktake`,
`inventree-importer`, and `picklist`.

## Installation

```bash
pip install inventree-sdk
```

## Configuration

Environment variables:

```bash
INVENTREE_URL=https://inventree.example.com
INVENTREE_TOKEN=your-api-token
```

Compatible aliases are also supported:

- `INVENTREE_API_URL`
- `INVENTREE_API_TOKEN`

## Usage

```python
from inventree_sdk import AuthManager, InvenTreeClient, get_config

config = get_config()
auth = AuthManager(config)
client = InvenTreeClient(config, auth)

part = client.parts.find_by_name("FRAME-001")
stock = client.stock.list_for_part(part.pk, in_stock=True)
```

## Included services

- `parts`
- `companies`
- `barcodes`
- `bom`
- `pricing`
- `stock`
- `builds`

## Full schema coverage

The SDK now ships with a generated OpenAPI surface for the full InvenTree schema.

- Existing hand-written services remain for the most common workflows.
- Every schema operation is also attached as a generated method on the matching service.
- Missing service groups are created automatically on the client.

Examples:

```python
stock_page = client.stock.stock_list(part=123, limit=25)
attachment_page = client.attachment.attachment_list(limit=10)
build = client.builds.build_retrieve(id=42)
```

Generated component models are also available:

```python
from inventree_sdk import get_openapi_model

StockItemModel = get_openapi_model("StockItem")
```

## GitLab CI

The repository includes a `.gitlab-ci.yml` pipeline that:

- runs `ruff` and `pytest`
- builds the package with `python -m build`
- publishes to PyPI on tagged releases

To enable publishing, add a masked GitLab CI/CD variable named `PYPI_API_TOKEN`
with a PyPI API token value.

The publish job uploads with `twine` using PyPI's token-based auth on tag pipelines.

## Current focus

This first version covers the endpoints already used by the local codebase:

- parts and categories
- companies and supplier parts
- barcode scan/link/unlink
- BOM items
- internal and sale prices
- stock listing, stock removal, stock count
- builds
