linnworks-api-python
This is a python version of the Linnworks API https://apidocs.linnworks.net/reference/overview
We use the openapi generator https://openapi-generator.tech/ to convert the linnworks api swagger api models https://github.com/LinnSystems/PublicApiSpecs into a python package.
This creates a requests based API with pydantic types. Awesome!
This project consists of tweaks I had to make to aws auth schemes to get things working with the openapi generator client, the generator script that creates the models and a little bit of documentation. Nothing fancy.
Prerequisites
- python 3.9+
- linnworks api credentials. See the docs https://apidocs.linnworks.net/reference/setting-up
Installation
pip install linnworks-api-python
Usage
import os
from linnworks_api.generated.auth.api import AuthApi
from linnworks_api.generated.auth.models.authorize_by_application_request import AuthorizeByApplicationRequest
from linnworks_api.generated.inventory.api import InventoryApi
from linnworks_api.generated.inventory.base_client import LinnworksConfig, LinnworksClient as InventoryClient
# Mock responses
from dotenv import load_dotenv
load_dotenv()
def test_auth():
"""This is an example of how to get an auth token"""
props = AuthorizeByApplicationRequest(
ApplicationId=os.getenv("LW_CLIENT_ID"),
ApplicationSecret=os.getenv("LW_CLIENT_SECRET"),
Token=os.getenv("LW_TOKEN"),
)
auth_api = AuthApi()
response = auth_api.authorize_by_application(props)
assert isinstance(response.token, str)
def test_inventory():
"""This is an example of how to create a client and make an API call"""
inventory_client = InventoryClient(
linnworks_config=LinnworksConfig(
client_id=os.getenv("LW_CLIENT_ID"),
client_secret=os.getenv("LW_CLIENT_SECRET"),
token=os.getenv("LW_TOKEN"),
)
)
inventory_api = InventoryApi(inventory_client)
response = inventory_api.get_inventory_items_count()
assert response == 1
Development
This is a poetry project so do the normal poetry install type things to set up your environment.
We use a Makefile for build automation.
make cleanremoves the generated codemake generategenerates the schemasmake testruns unit testsmake lint-fixfixes linting issues and checks compliance with linting standards
Project Structure
.
├── Makefile - make scripts
├── README.md - this file
├── notebooks
│ └── api_test.ipynb - example usage
├── poetry.lock
├── pyproject.toml
├── PublicApiSpecs - the linnworks swagger models. A git submodule
├── scripts
│ └── generate_schemas.py - script to generate api
├── tests - unit tests. (just enough to make sure things generated without error)
└── src
└── linnworks_api
|── base_client.py - client that gets copied into each package in generated/
└── generated - the generated api files created when generate_schemas.py is run
Metadata
Release files for linnworks-api-python 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| linnworks_api_python-0.1.0.tar.gz | 1.5 MB | Without provenance | Details for linnworks_api_python-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| linnworks_api_python-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for linnworks_api_python-0.1.0-py3-none-any.whl |
Total release size: 6.2 MB
Release files / linnworks_api_python-0.1.0.tar.gz
| Download URL | linnworks_api_python-0.1.0.tar.gz |
|---|---|
| Size | 1.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b743aabc584e970e9fbc7ef3a2dafa2899ad3e2e108f2c794ca03f992e1b6cc2
|
|
BLAKE2b-256 checksum How to use checksums |
a1c0c2a7d0c683093a126a9dc4787c8d85a5f58f2b5f41115650d78b923a867c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.11 Linux/6.8.0-1017-azure
|
Release files / linnworks_api_python-0.1.0-py3-none-any.whl
| Download URL | linnworks_api_python-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.6 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a1195360defdc56af30327a295974a270ca0dea347da54462bbcfe0b081b5d47
|
|
BLAKE2b-256 checksum How to use checksums |
8edf6c5739f4913afef203ed2fa311b265a3efac86a5af93ce3f3f8af72b4601
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.11 Linux/6.8.0-1017-azure
|
Security for linnworks-api-python 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.