{"id":25334122,"url":"https://github.com/birddevelper/dequest","last_synced_at":"2025-04-08T08:44:12.070Z","repository":{"id":276696493,"uuid":"929919994","full_name":"birddevelper/dequest","owner":"birddevelper","description":"Full featured declarative HTTP client 🚀","archived":false,"fork":false,"pushed_at":"2025-03-31T21:21:17.000Z","size":79,"stargazers_count":2,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T22:23:58.219Z","etag":null,"topics":["api","http-requests","python","rest-","rest-cli"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/birddevelper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-09T17:49:29.000Z","updated_at":"2025-03-31T21:14:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"872dd8f9-1bee-4ab0-9922-eeb6a7af9dba","html_url":"https://github.com/birddevelper/dequest","commit_stats":null,"previous_names":["birddevelper/dequest"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/birddevelper%2Fdequest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/birddevelper%2Fdequest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/birddevelper%2Fdequest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/birddevelper%2Fdequest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/birddevelper","download_url":"https://codeload.github.com/birddevelper/dequest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247807757,"owners_count":20999585,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","http-requests","python","rest-","rest-cli"],"created_at":"2025-02-14T05:35:11.920Z","updated_at":"2025-04-08T08:44:12.064Z","avatar_url":"https://github.com/birddevelper.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dequest\nDequest is a full featured declarative rest client for Python that streamlines the creation of HTTP requests and retrieves the results as DTO. Here is the package's features:\n\n✅ Supports GET, POST, PUT, PATCH and DELETE requests\n\n✅ Sync \u0026 Async Client\n\n✅ Optional Caching for GET Requests\n\n✅ Authentication (Static \u0026 Dynamic)\n\n✅ Maps API Json/XML response to DTO object and list (Supports unlimited nested DTOs)\n\n✅ Support query parameters, JSON body and Form-data\n\n✅ Implements Retry \u0026 Timeout Handling\n\n✅ Allows Custom Headers per Request (Static \u0026 Dynamic)\n\n✅ Circuit Breaker with Custom Fallback Function\n\n✅ API parameter mapping and type checking\n\n✅ Logging\n\n\n\n\n## Installation\nRun following command to install **dequest** :\n\n```bash\npip install dequest\n```\n\n## Usage\n\nDeclare a function with `@sync_client` decorator and pass the `dto_class` parameter to map the response to a DTO. You can also pass the `method`, `timeout`, `retries`, `retry_delay`, `auth_token`, `api_key`, `default_headers`, and `enable_cache` parameters.\n\n```python\nfrom dequest.clients import sync_client\nfrom dequest.parameter_types import PathParameter\n\nclass UserDto:\n    name: str\n    address: AddressDto\n    friends: list[str]\n\n    def __init__(self, name, address, friends):\n        self.name = name\n        self.address = address\n        self.friends = friends\n\n\n@sync_client(url=\"https://jsonplaceholder.typicode.com/users/{user_id}\", dto_class=UserDto)\ndef get_user(user_id: PathParameter) -\u003e UserDto:\n    pass\n\nuser = get_user(1)\n```\n\nRetrieving a list of users by city name using query parameters, you also can map the parameter name to the API's actuall query parameter name:\n\n```python\n@sync_client(url=\"https://jsonplaceholder.typicode.com/users\", dto_class=UserDto)\ndef get_users(city_name:QueryParameter[str, \"cityName\"]) -\u003e List[UserDto]:\n    pass\n\nusers = get_users(\"Paris\")\n```\nThe request will be sent to API as `https://jsonplaceholder.typicode.com/users?cityName=Paris`.\n\n### Cache\n\nTo enable caching, set the `enable_cache` parameter to `True` in the `sync_client` decorator. You can also pass the `cache_ttl` parameter to set the cache expiration time in seconds, the default value is None which means no expiration. Dequest supports `redis` and `in_memory` cache drivers, wich can be configured in `dequest.config.DequestConfig` which is a static class. The default cache provider is `in_memory`.\n\n```python\nfrom dequest.clients import sync_client\nfrom dequest.config import DequestConfig\n\nDequestConfig.cache_driver = \"redis\"\n\n@sync_client(\n    url=\"https://jsonplaceholder.typicode.com/users/{user_id}\",\n    dto_class=UserDto,\n    enable_cache=True,\n    cache_ttl=300\n)\ndef get_user(user_id: PathParameter[int]) -\u003e UserDto:\n    pass\n\nuser = get_user(1)\n```\n\n### Authentication\n\nTo add authentication, pass the `auth_token` parameter to the `sync_client` decorator. You can also pass the `api_key` parameter to add an API key to the request headers.\n\nStatic authentication:\n\n```python\nfrom dequest.clients import sync_client\n\n@sync_client(\n    url=\"https://jsonplaceholder.typicode.com/users/{user_id}\",\n    dto_class=UserDto,\n    auth_token=\"my_auth_token\"\n)\ndef get_user(user_id: PathParameter[int]) -\u003e UserDto:\n    pass\n\nuser = get_user(1)\n```\n\nDynamic authentication token generation:\n\n```python\nfrom dequest.clients import sync_client\n\ndef get_auth_token():\n    return \"my_auth_token\"\n\n@sync_client(url=\"https://jsonplaceholder.typicode.com/users/{user_id}\", dto_class=UserDto, auth_token=get_auth_token)\ndef get_user(user_id: PathParameter[int]):\n    pass\n\nuser = get_user(1)\n```\n\nPost Method:\n\n```python\nfrom dequest.clients import sync_client\n\n@sync_client(\n    url=\"https://example.com/users\",\n    dto_class=UserDto,\n    method=\"POST\",\n)\ndef create_user(name: JsonBody[str], address: JsonBody[str]) -\u003e UserDto:\n    pass\n\npost = create_post(\"title\", \"body\")\n```\nThe reqest will be equal to:\n\n```bash\ncurl -X POST -H \"Content-Type: application/json\" -d '{\"name\": \"title\", \"address\": \"body\"}' https://example.com/users\n```\n\n\n## License\n\nDequest is released under the [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbirddevelper%2Fdequest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbirddevelper%2Fdequest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbirddevelper%2Fdequest/lists"}