Skip to main content

No project description provided

Project description

api-lib Format and tests cov

A lightweight Python library for building and consuming APIs with ease.

Features

  • Simple API client utilities
  • Built-in request/response handling
  • Extensible and easy to integrate

Installation

It's recommended to use uv to install the package:

uv add api-lib

Usage

Example: Consuming an API

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()

Documentation

See the full documentation for more details and advanced usage.

Contributing

Contributions are welcome! Please open issues or submit pull requests.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

api_lib-0.0.4.tar.gz (64.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

api_lib-0.0.4-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file api_lib-0.0.4.tar.gz.

File metadata

  • Download URL: api_lib-0.0.4.tar.gz
  • Upload date:
  • Size: 64.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for api_lib-0.0.4.tar.gz
Algorithm Hash digest
SHA256 682eb86a1478353d151c20f21bb7cadec040724f17615918be7e2039b7494593
MD5 098d622adaea38571181a9e8267498d3
BLAKE2b-256 47f390662d6f0b8299b3374f9ea4134ada69f88b4eaf490e54163d5030cc7845

See more details on using hashes here.

Provenance

The following attestation bundles were made for api_lib-0.0.4.tar.gz:

Publisher: publish.yaml on jeandemeusy/api-lib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file api_lib-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: api_lib-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for api_lib-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 233c770019cea3bfdc4ee8fc4db99ef7ddadbba9861bd2eaa8c8468afe6a9a39
MD5 4064b706e31c1f8b9268dde1cd60c15b
BLAKE2b-256 22f9f5526ea4946ebe888c090b6691ead9145c96109ff1e0036bc076a2dddf49

See more details on using hashes here.

Provenance

The following attestation bundles were made for api_lib-0.0.4-py3-none-any.whl:

Publisher: publish.yaml on jeandemeusy/api-lib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page