requests-openapi
A lightweight but powerful and easy-to-use Python client library for OpenAPI v3.
Key Features
- Lightweight Design: Experience a minimalistic interface.
- Focus on Essentials: Helps you simplify the handling of Paths, Parameters, Headers, Cookies, etc., while inheriting all the capabilities of Requests.
- Testing and Integration Made Easy: Whether you're running tests or integrating with other systems, the client simplifies these tasks.
Usage
import requests_openapi
# load spec from url
c = requests_openapi.Client().load_spec_from_url("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml")
# or load from file
c = requests_openapi.Client().load_spec_from_file("openapi.json")
# set server
c.set_server(requests_openapi.Server(url="https://fake.com/api"))
# custom session for auth or others
c.requestor # a instance of requests.Session, see https://requests.readthedocs.io/en/latest/user/advanced/#session-objects
# set update token
c.requestor.headers.update({"Authorization": "token"})
# call api by operation id
resp = c.listPets() # resp: requests.Response
resp.json()
# get by path id
resp = c.showPetById(petId=1)
resp.json()
# post
resp = c.createPets(json={})
resp.json()
#
# Advanced Usage
#
# set req options, 'req_opts' param to custom request options
requests_openapi.Client(req_opts={"timeout": 60}).load_spec_from_file("xx")
# parameters starts with '_' or not found in openapi spec, will be passed through to the requesting
c.createPets(json={}, _headers={}, _params={}, _cookies={})
# parameters
# in: cookie, name: csrftoken
c.createPets(csrftoken="***")
# in: header, name: x-foo
c.createPets(**{"x-foo": "***"})
# in: path, name: userId
c.getUser(userId=1)
# in: query, name: offset
c.listUsers(offset=1)
# http body, just like requests.Session
c.createPets(json={}) or c.createPets(data={})
Installation
pip install requests-openapi
License
MIT
Metadata
Release files for requests-openapi 1.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| requests_openapi-1.0.6.tar.gz | 9.9 kB | Without provenance | Details for requests_openapi-1.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| requests_openapi-1.0.6-py3-none-any.whl | Python 3 | none | any | Details for requests_openapi-1.0.6-py3-none-any.whl |
Total release size: 16.2 kB
Release files / requests_openapi-1.0.6.tar.gz
| Download URL | requests_openapi-1.0.6.tar.gz |
|---|---|
| Size | 9.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
408973df01bab7ce59d048e054e00d80a828a0ef05197236be4ba6a47ff14294
|
|
BLAKE2b-256 checksum How to use checksums |
f250cda313694e7de46033a750e9b3018b7dff00aab1de9c25ebe576f89e909e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Release files / requests_openapi-1.0.6-py3-none-any.whl
| Download URL | requests_openapi-1.0.6-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2ddb75d17b3a737c6f7d2aa61e6e2f9c99476ca6022c703f2f419495854f9dda
|
|
BLAKE2b-256 checksum How to use checksums |
0acff939cde6c4246928faa031dbd658c619b5e0b8f282c39a19e2eb6d66df8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Security for requests-openapi 1.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.