Skip to main content

PyPI - Version GitHub

PySonataWebAPI

Unofficial Symfonia WebAPI asynchronous client for python3.10+

Client is object oriented with model validation.

Why?

Proof of concept, lack of such client and attempt to utilise my current knowledge and experience of working with Symfonia WebAPI server. Incoming python integration to MS Excel is also an answer. Also, the project has grown so much that I had to start versioning it.

Please keep in mind that this project is still in work in progress stage.

Installation

Install using pip install -U PySonataWebAPI

Disclaimers

This client hugely depends on typehints in official documentation of WebAPI server. It tries to reflect models and methods from documentation for easier method use and easier to perform data manipulation but there are some limitations due to documentation inaccuracies and C# / Python environment differences. Known documentation inaccuracies are fixed on this client side. Especially this refers to undocumented enum values (f.e. for reservation types) and for nullable property of models fields.

Every enumeration has undocumented value handling to prevent annoying validation errors. Example:

from PySonataWebAPI import WebAPI

unknown_reservation_type = WebAPI.Interface.Enums.enumReservationType(3)
print(unknown_reservation_type)

Output:

enumReservationType.Undocumented

Please keep in mind that this code is 99.9% generated by using script and with very little developer involvement. Script has ability to patch known issues on model and method sides.

But they must be known before that...

Server bugs

I have caught many errors using WebAPI server. I tried to fix some of them with patching mechanism I have designed.

Patched models

  • WebAPI.Interface.Products.ViewModels.ProductListElement property VatRate can be None
  • WebAPI.Interface.Common.ViewModels.Dimension property DictionaryValue can be None
  • WebAPI.Interface.Products.ViewModels.Product property SetElements can be None
  • WebAPI.Interface.Products.ViewModels.ProductBarcode property Barcode can be None

Known models bugs (not patched)

to be written

Patched methods

none

Known method bugs (not patched)

to be written

Example usage (simple exaple)

import asyncio
from PySonataWebAPI import WebAPI


async def main():
    api = WebAPI.Client.AsyncAPI(
        domain='<< your api server ip >>',  # f.e. 192.168.1.100:9000
        https=False,
        device_name='dev',
        key='<< your guid access key >>'
    )

    error = None

    async with api:
        try:
            # Perform an example GET request
            response = await WebAPI.Interface.Interfaces.IPingController.Get(api)
            response = response.get_response()
            # Do something with the response
            if response.ok:
                text = await response.text()
                print("Received Response:", text)
            else:
                print(f"Received an error from the server: {response.status}")

            products_data = await WebAPI.Interface.Products.Interfaces.IProductsController.Get(api=api)
            response = products_data.get_response()
            # Do something with the response
            if response.ok:
                text = await response.text()
                print("Received Response:", text)
                models = products_data.model
                print(models)
            else:
                raise Exception(f"Received an error from the server: {response.status}")
        except Exception as e:
            error = e
    if error:
        raise error

if __name__ == '__main__':
    asyncio.run(main())

Models usage

to be explained...

TODOs

  • support not settable model properties
  • support SSL certs
  • support for selective method return type based on input parameter value
  • code autobuild and auto-versioning for past, current and upcoming WebAPI server versions

Licence

Project Licence

  • This project is licensed under the Apache License 2.0 licence. A copy of the license is included in this repository.

Third-Party Libraries

  • This project uses Pydantic, which is licensed under the MIT License. A copy of the license is included in this repository.
  • This project uses aiohttp, which is licensed under the Apache License 2.0. A copy of the license is included in this repository.

Metadata

Release files for PySonataWebAPI 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PySonataWebAPI 1.0.1
File Size Uploaded
pysonatawebapi-1.0.1.tar.gz 267.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PySonataWebAPI 1.0.1
File Interpreter ABI Platform
pysonatawebapi-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 412.7 kB

Release files / pysonatawebapi-1.0.1.tar.gz

Download URL pysonatawebapi-1.0.1.tar.gz
Size 267.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0c24be8bc9dc514ee53d0ec48c72ce55a0d209a1b1f989512d501d1c92b4bfce
BLAKE2b-256 checksum
How to use checksums
e060ef2bc15c7a5bfe19bbfb045a817a72ea8cbe8d507cf724ecd5d01f7583d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.11.4 Windows/10

Release files / pysonatawebapi-1.0.1-py3-none-any.whl

Download URL pysonatawebapi-1.0.1-py3-none-any.whl
Size 145.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de8fc800d66181ceb9f4b261bbc2cf12032bcb98510b67da4acc21b1d2ad8596
BLAKE2b-256 checksum
How to use checksums
cba77448fb885cba9a0f0b67c6150441f6c95a81ea74a8bf934d87063178ef96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.11.4 Windows/10

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page