make wrapper for RESTful API
Project description
apywrapper
Easy development of RESTful API wrapper
Feature
- Get response as dataclass object you defined
- Return type can be specified by type annotation of api function
- All parameters (query, path variable, or json data) can be specified at once
install
pip install apywrapper
Example
from apywrapper import Apy, delete, get, patch, post, put
from typing import List, no_type_check
from dataclasses import dataclass
@dataclass
class User:
name: str
id: str
@no_type_check
class ApiClient(Apy):
def __init__(self, token, host="https://example.com/api":
super().__init__(host, headers={"api-token": token})
@get("/users/")
def get_users(self) -> List[User]:
return {}
@get("/users/{user_id}")
def get_user(self, user_id) -> User:
return {"user_id": user_id}
api = ApiClient(token="xxxxxxxxxxxxxxxxxx")
sh1ma = api.get_user("sh1ma") # return User object
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
apywrapper-0.1.12.tar.gz
(16.5 kB
view details)
Built Distribution
File details
Details for the file apywrapper-0.1.12.tar.gz
.
File metadata
- Download URL: apywrapper-0.1.12.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.10 CPython/3.8.5 Linux/5.4.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfb8a112d6b5de8a993bb4bd23e0348f71221ac82c24f5c3de880ebbb938ec5d |
|
MD5 | 9dcc8e31e995062615af1906203ad76f |
|
BLAKE2b-256 | dae03b5d8aa98c7fa4d1c182eb8e99adfca335130f650f27733279c96a4473c0 |
File details
Details for the file apywrapper-0.1.12-py3-none-any.whl
.
File metadata
- Download URL: apywrapper-0.1.12-py3-none-any.whl
- Upload date:
- Size: 17.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.10 CPython/3.8.5 Linux/5.4.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d1d60d6d34e73dddcb87779dc136cf1df387940db9c6961543c1a1d9a11b65c |
|
MD5 | 39fab3ddc9306951116decc48d9914c9 |
|
BLAKE2b-256 | e8cc0e09052d9a44747290c38dda1363bb326fc5dfb41f93346bb96e88686464 |