make wrapper for RESTful API
Project description
apywrapper
Library that can wrap only RESTful API
install
pip install apywrapper
Example (Chatwork API Wrapper)
from apywrapper import Apy
from dataclasses import dataclass
api = Apy(
"https://api.chatwork.com/v2",
headers={"X-ChatWorkToken": "xxxxxxxxx"},
)
@dataclass
class Room:
room_id: int
name: str
type: str
role: str
sticky: bool
unread_num: int
mention_num: int
mytask_num: int
message_num: int
file_num: int
task_num: int
icon_path: str
last_update_time: int
@api.get("/rooms/{room_id}")
def get_room(room_id: int):
return (
Room,
{"room_id": room_id},
) # Return Object, Request Params(Path Args, Query or JsonData(Dict))
@api.get("/rooms")
def get_rooms():
return Room, {}
print(get_room(183377745)) # return Room
print(get_rooms()) # return List[Room]
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.0.tar.gz
(14.8 kB
view hashes)
Built Distribution
apywrapper-0.1.0-py3-none-any.whl
(16.1 kB
view hashes)
Close
Hashes for apywrapper-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2116916fe934b62ef324b8aed8c7a4b8cf6ae47660814e44eefbd66bf91a209b |
|
MD5 | 117b5edebbd8db0fbb97ca2123e1f0f1 |
|
BLAKE2b-256 | ce5326e82a00c391a52f382e3cbcb047ccbc0838cdf9f03c8e923d73ee1cb57b |