I want to build a Python wrapper for an API, how should I approach it?

I am planning to build a python wrapper around a rest API.

I want to support friendly functions, with autocompletion in the editor.
I want 100% test coverage
I want the package to be modular, so that, any changes to API, can be easily reflected
I wan…


This content originally appeared on DEV Community and was authored by Aahnik Daw

I am planning to build a python wrapper around a rest API.

  • I want to support friendly functions, with autocompletion in the editor.
  • I want 100% test coverage
  • I want the package to be modular, so that, any changes to API, can be easily reflected
  • I want to support both async and normal methods (the core will be implemented thru async, but there will be a wrapper for those who don't want to use async)

example:

import asyncio
from library import Api

api = Api()

async def do_job():
    thing = await api.get_thing()
    print(thing)

asyncio.run(do_job())

or

from library.sync import Api

thing = api.get_thing()

print(thing)

the data that will be passed to the functions should be validated. planning to use pydantic.

planning to create a sub-package library.models to contain all the modules defining the models.

how should I design the entire thing? how should I structure the project?

best practices? guides?


This content originally appeared on DEV Community and was authored by Aahnik Daw


Print Share Comment Cite Upload Translate Updates
APA

Aahnik Daw | Sciencx (2021-04-12T02:01:45+00:00) I want to build a Python wrapper for an API, how should I approach it?. Retrieved from https://www.scien.cx/2021/04/12/i-want-to-build-a-python-wrapper-for-an-api-how-should-i-approach-it/

MLA
" » I want to build a Python wrapper for an API, how should I approach it?." Aahnik Daw | Sciencx - Monday April 12, 2021, https://www.scien.cx/2021/04/12/i-want-to-build-a-python-wrapper-for-an-api-how-should-i-approach-it/
HARVARD
Aahnik Daw | Sciencx Monday April 12, 2021 » I want to build a Python wrapper for an API, how should I approach it?., viewed ,<https://www.scien.cx/2021/04/12/i-want-to-build-a-python-wrapper-for-an-api-how-should-i-approach-it/>
VANCOUVER
Aahnik Daw | Sciencx - » I want to build a Python wrapper for an API, how should I approach it?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/04/12/i-want-to-build-a-python-wrapper-for-an-api-how-should-i-approach-it/
CHICAGO
" » I want to build a Python wrapper for an API, how should I approach it?." Aahnik Daw | Sciencx - Accessed . https://www.scien.cx/2021/04/12/i-want-to-build-a-python-wrapper-for-an-api-how-should-i-approach-it/
IEEE
" » I want to build a Python wrapper for an API, how should I approach it?." Aahnik Daw | Sciencx [Online]. Available: https://www.scien.cx/2021/04/12/i-want-to-build-a-python-wrapper-for-an-api-how-should-i-approach-it/. [Accessed: ]
rf:citation
» I want to build a Python wrapper for an API, how should I approach it? | Aahnik Daw | Sciencx | https://www.scien.cx/2021/04/12/i-want-to-build-a-python-wrapper-for-an-api-how-should-i-approach-it/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.