A client for the fastapi environment
Project description
FastAPIClient
An easy to use, integrated client for FastApi,
- Uses the same decorators as FastApi
- Dose not require one to "recreate" clients and works out of the box.
- Allows defining the client "host" via the
with
command. - Works with async as well.
BETA
This repo is in beta mode, some bugs may still exist and test coverage is not complete. PR's welcome.
TL;DR
To use the client you must call define the api,
from typing import Annotated
from fastapi import FastAPI, Cookie, Body
from fastapi_client import FastAPIClient
api = FastAPI()
# This is required in order to allow the fast api
# client to wrap around any function calls.
# NOTE: It DOSE NOT AFFECT the operation of the API, and it dose not slow it down
# in any way.
FastAPIClient.enable(api)
@api.get("/echo")
def echo(a: int, b: int):
rslt = a + b
print(rslt)
return rslt
We then can (async methods, just add async),
from test_module import echo
from fastapi_client import FastAPIClient
# Call the function locally
echo(1,2)
# Call the function on the server running in localhost
with FastAPIClient("localhost:8080"):
print(echo(1, 2))
Install
pip install fastapi_client
Contribution
Feel free to ping me in issues or directly on LinkedIn to contribute.
Future implementation
We plan to support multiple python version per environment.
Looking for help on this subject.
License
Copyright ©
Zav Shotan
and other contributors.
It is free software, released under the MIT licence, and may be redistributed under the terms specified in LICENSE.
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for fastapi_client-0.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82fedce80ad99031fa152b25ba936d2486a7b8c5cdce17cee63518819471aeea |
|
MD5 | 2cbc088b72beaf1327bc4e6641a4f43f |
|
BLAKE2b-256 | a98ff2964f751d1fe934662bf4d34907ba9bba137a5fbfcb71e4b53f308f366a |