A lightweight Python library for building and consuming APIs with ease.
- Simple API client utilities
- Built-in request/response handling
- Extensible and easy to integrate
It's recommended to use uv
to install the package:
uv add api-lib
from api_lib import ApiLib
from api_lib.headers.accept import AcceptGithub
from api_lib.headers.authorization import Bearer
from api_lib.method import Method
from api_lib.objects.response import APIfield, APIobject, JsonResponse
@APIobject
class User(JsonResponse):
login: str = APIfield()
name: str = APIfield()
disk_usage: int = APIfield()
disk_space_limit: int = APIfield("plan/space")
class GithubAPI(ApiLib):
headers = [AcceptGithub()]
async def user(self) -> User:
return await self.req(Method.GET, "/user", User)
api = GithubAPI("https://api.github.com", Bearer(env_var="GITHUB_TOKEN"))
user = await gh_api.user()
See the full documentation for more details and advanced usage.
Contributions are welcome! Please open issues or submit pull requests.
This project is licensed under the MIT License.