Releases: martinn/quickapiclient
Releases · martinn/quickapiclient
v0.5.1
v0.5.0
Introducing first class support for API client definitions
Each client definition can support multiple API endpoints and optionally share state (auth, session, etc).
Example:
from dataclasses import dataclass
import quickapi
# An example type that will be part of the API response
@dataclass
class Fact:
fact: str
length: int
# What the API response should look like
@dataclass
class ResponseBody:
current_page: int
data: list[Fact]
# We define an API endpoint
class GetFactsApi(quickapi.BaseApi[ResponseBody]):
url = "/facts"
response_body = ResponseBody
# And now our API client
class ExampleClient(quickapi.BaseClient):
base_url = "https://example.com"
get_facts = quickapi.ApiEndpoint(GetFactsApi)
# Other endpoints would follow here:
# submit_fact = quickapi.ApiEndpoint(SubmitFactApi)
And you can use it like this:
client = ExampleClient()
response = client.get_facts()
# `response` is fully typed and conforms to our `ResponseBody` definition
assert isinstance(response.body, ResponseBody)
assert isinstance(response.body.data[0], Fact)
# `reveal_type(response.body)` returns `Revealed type is 'ResponseBody'` too,
# which means full typing and IDE support.
What's changed
- Improve API client definition and usage by @martinn in #17
- Ensure we support
kwargs
for API client endpoints by @martinn in #20 - Documentation improvements by @martinn in #19
Full Changelog: v0.0.15...v0.5.0
v0.0.15
v0.0.14
v0.0.13
What's Changed
- build(deps): Bump urllib3 from 2.2.1 to 2.2.2 in the pip group across 1 directory by @dependabot in #8
- build(deps): Bump certifi from 2024.2.2 to 2024.7.4 in the pip group across 1 directory by @dependabot in #9
- build(deps-dev): Bump setuptools from 69.5.1 to 70.0.0 in the pip group across 1 directory by @dependabot in #10
Full Changelog: v0.0.12...v0.0.13
v0.0.12
What's Changed
- build(deps): Bump idna from 3.6 to 3.7 by @dependabot in #1
- Update mkdocs documentation dependency by @martinn in #6
- build(deps): Bump requests from 2.31.0 to 2.32.0 in the pip group across 1 directory by @dependabot in #7
Full Changelog: v0.0.11...v0.0.12
v0.0.11
- Internal refactors (no visible or breaking changes)
- Documentation improvements
Full Changelog: v0.0.10...v0.0.11
v0.0.10
- Remove hard dependency on
attrs
/cattrs
- Also fixes an error when using the library with no extras selected
Full Changelog: v0.0.9...v0.0.10
v0.0.9
- feat: Add first class support for
pydantic
anddataclasses
(alongsideattrs
) - docs: Improve main README (including future goals)
- docs: Small updates to contributing guidelines
- Refactors and behind the scene improvements
Full Changelog: v0.0.8...v0.0.9
v0.0.8
- Add support for using
requests
library overhttpx
, as an optional dependency
Full Changelog: v0.0.7...v0.0.8