Python class that allow to create REST API client with dynamic code generation
Project description
FitRequest
FitRequest is a Python library designed to simplify the creation of REST API clients by automating code generation.
It enables developers to generate both synchronous and asynchronous methods for interacting with REST APIs,
handle response formatting, and manage authentication seamlessly.
Key Features
What This Module Does
- Easy Synchronous and Asynchronous Code Generation: Quickly create methods to interact with REST endpoints.
- Response Formatting: Automatically handle JSON and XML responses and support JSONPath exploration for JSON responses.
- Docstring Templating: Generate meaningful docstrings for each method.
- Basic Authentication: Support basic authentication using environment variables or AWS secrets.
- FitRequest Variable Management: Easily retrieve data from AWS, system environment variables, or set default values.
- Argument Generation: Automatically generate method arguments based on endpoint variables.
- Decorator handling: Easily enhance generated fitrequest methods with custom decorators.
- Retry Behavior: A
@retrydecorator is provided to allow user to implement basic retry logic. - Rich syntax options: Several syntax options provided that can be tailored to your needs and preferences.
- Auto-generated CLI: An out-of-the-box CLI is provided with fitrequest classes to easily test methods from a terminal.
What This Module Doesn’t Do
- Handle OpenApi: Generate python clients from OpenAPI documents. This may be a future feature.
- Complex Authentication: For complex authentication, use a custom HTTPX Authentication method or directly provide the
authargument to the generated method. - Multiple Request Methods: Generates only one method per endpoint.
- XML/HTML Parsing: Limited support for extracting data from XML and HTML.
- Streaming Handling: Does not handle streaming requests/responses. This may be a future feature.
Installation
pip install fitrequest
A Simple Example
from fitrequest.client import FitRequest
class RestApiClient(FitRequest):
"""Awesome class generated with FitRequest."""
client_name = 'rest_api'
base_url = 'https://test.skillcorner.fr'
method_docstring = 'Calling endpoint: {endpoint}'
method_config_list = [
{
'base_name': 'items',
'endpoint': '/items/',
'add_async_method': True,
},
{
'name': 'get_item',
'endpoint': '/items/{item_id}',
},
{
'name': 'get_item_details',
'endpoint': '/items/{item_id}/details/{detail_id}',
},
]
client = RestApiClient()
With the above class, you can perform the following actions:
# Synchronous calls
response = client.get_item(item_id=3)
response = client.get_item_details(item_id=3, detail_id=7)
response = client.get_items()
# Asynchronous calls
response = await client.get_items()
Help
See documentation for more details.
Contact
For support, contact the Skillcorner Team: support@skillcorner.com.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fitrequest-1.5.3.tar.gz.
File metadata
- Download URL: fitrequest-1.5.3.tar.gz
- Upload date:
- Size: 465.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f45ba6704017a570ad5d0a343f86f3d2bd0d352247fbd8bb580958c2b2a71f40
|
|
| MD5 |
9be1607ccfa37a6d5af587766eb99678
|
|
| BLAKE2b-256 |
c5e9cb7ef6088e90848146f6552ed16ac0b6d3ea25601ecc911043c25543210d
|
File details
Details for the file fitrequest-1.5.3-py3-none-any.whl.
File metadata
- Download URL: fitrequest-1.5.3-py3-none-any.whl
- Upload date:
- Size: 40.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92735b27cdf461d358a29976a945fd5b9ecd60337e8a55042ce91936ac1e262a
|
|
| MD5 |
e5532f50f66fe472b74aff7662200a90
|
|
| BLAKE2b-256 |
8c96be74f7275a60aa6d54367ef31957f9cfe3ca7f1f7e0e1619ee511356c3f9
|