{"id":19810400,"url":"https://github.com/songzhi/apix","last_synced_at":"2025-05-01T08:31:57.620Z","repository":{"id":38962023,"uuid":"256524304","full_name":"songzhi/apix","owner":"songzhi","description":"Declarative HTTP client based on pydantic and typical.","archived":false,"fork":false,"pushed_at":"2023-07-23T12:18:38.000Z","size":55,"stargazers_count":14,"open_issues_count":4,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T11:46:26.732Z","etag":null,"topics":["httpx","typical"],"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/songzhi.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}},"created_at":"2020-04-17T14:23:41.000Z","updated_at":"2024-08-19T09:09:51.000Z","dependencies_parsed_at":"2022-09-19T15:04:56.608Z","dependency_job_id":null,"html_url":"https://github.com/songzhi/apix","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/songzhi%2Fapix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/songzhi%2Fapix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/songzhi%2Fapix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/songzhi%2Fapix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/songzhi","download_url":"https://codeload.github.com/songzhi/apix/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251847809,"owners_count":21653582,"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":["httpx","typical"],"created_at":"2024-11-12T09:21:22.126Z","updated_at":"2025-05-01T08:31:57.322Z","avatar_url":"https://github.com/songzhi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## [WIP] Typed HTTP Client for Humans\nIt's inspired by [FastAPI](https://fastapi.tiangolo.com/) and \nbased on [pydantic](https://pydantic-docs.helpmanual.io/) and \n[httpx](https://www.python-httpx.org/).\n\n**It's currently a very rough demo for experiment.**\nPydantic will be replaced by [typical](https://github.com/seandstewart/typical).\nthis project is currently waiting for new type Union operator in Python3.10.\n \n## Example\n```python\nfrom typing import List\n\nfrom pydantic import BaseModel\n\nfrom apix import get, Service, Query\n\n\nclass User(BaseModel):\n    id: str\n    email: str\n    first_name: str\n    last_name: str\n    avatar: str\n\n\nclass UsersResponse(BaseModel):\n    page: int\n    per_page: int\n    total: int\n    total_pages: int\n    data: List['User']\n\n\nclass Paging(BaseModel):\n    page: int\n\n\nclass UserService(Service):\n    # `@staticmethod` or `@classmethod` for specified-level client\n    @get('/api/users')\n    def get_users(self, paging: Paging = Query(...)) -\u003e UsersResponse:\n        ...\n# or \n\n@get('https://reqres.in/api/users')\ndef get_users(self, paging: Paging = Query(...)) -\u003e UsersResponse:\n    ...\n\n\ndef main():\n    paging = Paging(page=1)\n    print(UserService(base_url='https://reqres.in').get_users(paging))\n    print(UserService.get_users(paging))\n    print(UserService.get_users(UserService(base_url='https://reqres.in'),paging))\n    print(get_users(paging))\n\nif __name__ == '__main__':\n    main()\n```\n\n## Features\n### Multi-level 'client'\nif using single decorator like `get`, all endpoints sharing one client.\nif defined in a class, there will be a class-level client and instance-level\nclient.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsongzhi%2Fapix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsongzhi%2Fapix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsongzhi%2Fapix/lists"}