apple / app-store-server-library-python

MIT License
135 stars 30 forks source link

[Feature] Asynchronous Implementation and Pydantic Support #91

Open bahadiraraz opened 2 months ago

bahadiraraz commented 2 months ago

Due to the use of synchronous requests in the library, functions such as get_transaction_history can take a long time to execute, posing significant challenges for developers looking to build async APIs. Additionally, many Python developers utilize Pydantic for data validation, so incorporating Pydantic into the library can greatly simplify its usage.

For those interested in an asynchronous implementation, I have created a library, app-store-server-library-python-async, which uses httpx for async operations. The library also includes guidance on how to incorporate Pydantic for data validation. You can review the code and see how to implement these features.

If you have any questions or suggestions, feel free to reach out!

woosal1337 commented 2 months ago

This is a crucial case for the async mobile application architecture. Most applications, if not all, utilize async client-side functions. Consequently, the current version of the library would significantly lock down and slow the system, making it non-scalable as the user base grows.

As mentioned in issue #35, Pydantic would be a more suitable implementation. Pydantic is constantly updated and widely adopted by professional libraries used in hundreds of thousands of projects, making it a de facto standard. Additionally, Pydantic's built-in validation support, exceptions, and error handling improve developer understanding and ease of implementation, distinguishing it from the attrs library.

Reskov commented 1 month ago

@bahadiraraz There is also another httpx library fork with slightly different approach, it has official library as dependency for a data classes import. Probably you can cooperate with @ipfans, and work together? https://github.com/ipfans/aio-appstoreserverlibrary