{"id":13574028,"url":"https://github.com/FKLC/AnyAPI","last_synced_at":"2025-04-04T13:30:48.317Z","repository":{"id":114025817,"uuid":"166031038","full_name":"FKLC/AnyAPI","owner":"FKLC","description":"AnyAPI is a library that helps you to write any API wrapper with ease and in pythonic way.","archived":true,"fork":false,"pushed_at":"2021-11-07T19:55:11.000Z","size":32,"stargazers_count":132,"open_issues_count":0,"forks_count":7,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-05T08:37:20.669Z","etag":null,"topics":["api","api-client","api-wrapper","apis","python","python-requests","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FKLC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-01-16T11:45:45.000Z","updated_at":"2024-01-04T16:29:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"95293a09-51fd-42eb-9b91-2ab2c12fee1a","html_url":"https://github.com/FKLC/AnyAPI","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FKLC%2FAnyAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FKLC%2FAnyAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FKLC%2FAnyAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FKLC%2FAnyAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FKLC","download_url":"https://codeload.github.com/FKLC/AnyAPI/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247184917,"owners_count":20897855,"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","api-client","api-wrapper","apis","python","python-requests","python3"],"created_at":"2024-08-01T15:00:45.313Z","updated_at":"2025-04-04T13:30:48.017Z","avatar_url":"https://github.com/FKLC.png","language":"Python","readme":"# AnyAPI\n\n![Travis (.org)](https://img.shields.io/travis/FKLC/AnyAPI.svg?style=flat-square)\n![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/FKLC/AnyAPI.svg?style=flat-square)\n![Code Climate coverage](https://img.shields.io/codeclimate/coverage/FKLC/AnyAPI.svg?style=flat-square)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/anyapi.svg?style=flat-square)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/AnyAPI.svg?style=flat-square)\n\nAnyAPI is a library that helps you to write any API wrappers with ease and in pythonic way.\n\n### Features\n\n- Have better looking code using dynamic method calls.\n- Filters to help you to modify request, raise errors or log requests instead of writing functions everywhere.\n- Scoped calls to raise errors and take action if necessary.\n- Automatic retrying if the condition met with what you passed.\n- Built-in rate limit proxy changer. (you can write your own proxy handler)\n- Since it is built on top of requests anything compatible with it is compatible with AnyAPI.\n\nBut most importantly in AnyAPI almost everything is modular!\n\n---\n\n### Examples\n\nMaking GET request to https://httpbin.org/anything/endpoint\n\n```python\nfrom anyapi import AnyAPI\n\n\nbase_url = 'https://httpbin.org'\napi = AnyAPI(base_url)\n\napi.anything.endpoint.GET()\n```\n\nAs you can see dots are pretended as slash and at the end you should put dot and HTTP method you want to use in capital letters.\n\n---\n\nSetting header before every request\n\n```python\nimport datetime\nfrom anyapi import AnyAPI\n\n\ndef set_date_as_header(kwargs):\n    now = datetime.datetime.now()\n    kwargs['headers'].update({'date': now.strftime('%B %d %Y')})\n\n    return kwargs\n\napi = AnyAPI('https://httpbin.org')\napi._filter_request.append(set_date_as_header)\n\nprint(api.anything.endpoint.GET().json())\n# output\n{\n   'args': {},\n   'data': '',\n   'files': {},\n   'form': {},\n   'headers': {\n      'Accept-Encoding': 'identity',\n      'Connection': 'close',\n      'Date': 'January 16 2019',\n      'Host': 'httpbin.org'\n   },\n   'json': None,\n   'method': 'GET',\n   'origin': 'XX.XX.XX.XX',\n   'url': 'https://httpbin.org/anything/endpoint'\n}\n```\n\nAs you can see filter worked as expected and set `Date` header.\n\n---\n\nChanging proxy automatically after they reach their rate limit\n\n```python\nfrom anyapi import AnyAPI\nfrom anyapi.proxy_handlers import RateLimitProxy\n\nproxy_configuration = {\n  'default': proxy0,\n  'proxies': [proxy0, proxy1, proxy2,....], # don't forget to add default proxy!\n  'paths': {\n    '/anything': rate_limit0,\n    '/anything/endpoint': rate_limit1\n  }\n}\n\napi = AnyAPI('https://httpbin.org', proxy_configuration=proxy_configuration, proxy_handler=RateLimitProxy)\n\nfor i in range(10):\n  print(api.anything.endpoint.GET().json())\n```\n\nIf you check output of the all them you can see proxy changes when it reaches limit.\n\n### This library is not a new thing\n\nThere is a lot of libraries you can find out there for example [Uplink](https://github.com/prkumar/uplink/), [Hammock](https://github.com/kadirpekel/hammock) and many more...\n\n---\n\n## Installation\n\nLibrary on PyPI so just run\n\n```console\npip install anyapi\n```\n\n# To learn more about AnyAPI check [wiki page](https://github.com/FKLC/AnyAPI/wiki/)\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFKLC%2FAnyAPI","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFKLC%2FAnyAPI","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFKLC%2FAnyAPI/lists"}