make wrapper for RESTful API
Project description
apywrapper
Easy development of RESTful API wrapper
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(113377551)) # return Room
print(get_rooms()) # return List[Room]
Example (POST data)
@api.post("/users")
def create_user(username: str, user_id: str):
return User, {"user_name": username, "user_id": user_id}
created_user = create_user("sh1ma", "sh1ma")
Example (GET with is_hello
query)
@api.get("/users/{user_id}")
def get_user(user_id: str, is_hello: bool):
return User, {"user_id": user_id, "is_hello": True}
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.5.tar.gz
(16.1 kB
view hashes)
Built Distribution
apywrapper-0.1.5-py3-none-any.whl
(16.8 kB
view hashes)
Close
Hashes for apywrapper-0.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49b77915dbe1db748baad6738fab05969a6e381844d56f4564fc7625e40e063f |
|
MD5 | e9368c92e6ddf71b4381538a6a1f10a0 |
|
BLAKE2b-256 | 0297123df74bed07ba4159ae6b795938a12c46c445deaa25a2a5682b91285cbd |