# pyfeign **Repository Path**: irvinren/pyfeign ## Basic Information - **Project Name**: pyfeign - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-08-05 - **Last Updated**: 2026-08-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # PyFeign - Declarative REST Client Python implementation of Feign. ## Installation ```bash pip install pyfeign # or poetry install pyfeign ``` ## Usage Decorate function with appropriate `pyfeign.$method` decorator: ```python @pyfeign.get(url='http://localhost/{id}') def get_by_id(id: str = Path()) -> Dict[str, Any]: """ Get by ID """ obj_dict = get_by_id('id123') ``` ### Parameters * Path - Argument should be used as a path template variable. Reserved variable names can be used using the `name` parameter: ```python @pyfeign.get(url='http://localhost/{id}') def get_by_id(id_val: str = Path(name='id')) -> Dict[str, Any]: """ Get by ID """ ``` * Query - Argument should be used as a query parameter, and can be optionally set with a default value if not provided ```python @pyfeign.get(url='http://localhost/{id}') def get_by_id(id_val: str = Path, summary: bool = Query(default=False, name='summary_details')) -> Dict[str, Any]: """ Get by ID get_byt_id('id1', False) == http://localhost/id1?summary_details=False """ ``` * Header - Argument will be used as an HTTP Header * Cookie - Argument will be used as an HTTP Cookie * Body - Argument will be sent as the request body (JSON serialized) ### Classes ```python @pyfeign.Pyfeign(config=Config(base_url='https://postman-echo.com')) class PostmanEcho: @pyfeign.get('/get') def get(self, foo1: str = Query(), foo2: str = Query(default='bar2')) -> Dict[str, Any]: pass ``` ### Responses If the response function / method is typed with `Dict` or `List`, then the response json will be parsed and returned. If return type is `str` then the response text will be returned For either of these responses, the return code is asserted via `Response.raise_for_status()`, and so an HTTPError will be raised accordingly Otherwise the full `requests.Response` object is returned.