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.8.tar.gz
(16.2 kB
view hashes)
Built Distribution
apywrapper-0.1.8-py3-none-any.whl
(17.4 kB
view hashes)
Close
Hashes for apywrapper-0.1.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9afd6b7e0919fa476b8de9a4f9d776142df2c2439b9c84b5c248587c292b23e5 |
|
MD5 | c5d7e24f4f0bc37636e89acb2a9b540e |
|
BLAKE2b-256 | 3471703ebe96303026f709dbfa98fbda387bb385b461127546520a6cb0b27ada |