https://github.com/leyts/reqspec
A declarative HTTP client.
https://github.com/leyts/reqspec
http niquests pydantic python
Last synced: 1 day ago
JSON representation
A declarative HTTP client.
- Host: GitHub
- URL: https://github.com/leyts/reqspec
- Owner: leyts
- License: mit
- Created: 2026-06-11T16:49:43.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2026-06-25T18:20:48.000Z (18 days ago)
- Last Synced: 2026-06-25T19:18:01.873Z (18 days ago)
- Topics: http, niquests, pydantic, python
- Language: Python
- Homepage:
- Size: 107 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# reqspec
> [!WARNING]
> This package is under development. The API is subject to breaking changes.
A declarative HTTP client for Python, built on
[Niquests](https://niquests.readthedocs.io/en/latest) and [Pydantic](https://docs.pydantic.dev/).
## Usage
Describe an API as a class of typed method stubs. reqspec compiles each stub
into a real request at class creation; type hints drive both the request and
the response.
```python
from pydantic import BaseModel
from reqspec import Client, get
class Repo(BaseModel):
full_name: str
stargazers_count: int
class GitHub(Client, base_url="https://api.github.com"):
@get("/users/{user}/repos")
def repos(self, user: str, per_page: int = 30) -> list[Repo]: ...
gh = GitHub()
repos = gh.repos("astral-sh") # list[Repo]
```
A parameter matching a `{placeholder}` becomes a path parameter; everything
else becomes a query parameter. The return annotation drives parsing.
## Licence
[MIT](LICENCE)