aiohttp-requests


Nameaiohttp-requests JSON
Version 0.2.4 PyPI version JSON
download
home_pagehttps://github.com/maxzheng/aiohttp-requests
SummaryA thin wrapper for aiohttp client with Requests simplicity
upload_time2024-05-11 19:48:53
maintainerNone
docs_urlNone
authorMax Zheng
requires_python>=3.6
licenseMIT
keywords aiohttp http client async requests
VCS
bugtrack_url
requirements aiohttp coworker
Travis-CI No Travis.
coveralls test coverage
            aiohttp-requests
============================================================

Behold, the power of aiohttp_ client with `Requests <http://docs.python-requests.org/>`_ simplicity:

.. code-block:: python

    import asyncio

    import aiohttp
    from aiohttp_requests import requests

    async def main():
        response = await requests.get('https://api.github.com', auth=aiohttp.BasicAuth('user', 'password'))
        text = await response.text()
        json = await response.json()
        return response, text, json

    r, text, json = asyncio.run(main())

    >>> r
    <ClientResponse(https://api.github.com/) [200 OK]>
    >>> r.status
    200
    >>> r.headers['Content-Type']
    'application/json; charset=utf-8'
    >>> r.get_encoding()
    'utf-8'
    >>> text
    '{"current_user_url":"https://api.github.com/user",...'
    >>> json
    {'current_user_url': 'https://api.github.com/user', ... }

Plus built-in concurrency control to do multiple requests safely:

.. code-block:: python

    async def main():
        # Pass in a list of urls instead of just one. Optionally pass in as_iterator=True to iterate the responses.
        responses = await requests.get(['https://api.github.com'] * 2, auth=aiohttp.BasicAuth('user', 'password'))
        print(responses)    # [<ClientResponse(https://...) [200 OK]>, , <ClientResponse(https://...) [200 OK]>]

        # It defaults to 10 concurrent requests maximum. If you can handle more, then set it higher:
        requests.max_concurrency = 100

    asyncio.run(main())

The `requests` object is just proxying `get` and other HTTP verb methods to `aiohttp.ClientSession`_, which returns `aiohttp.ClientResponse`_. To do anything else, read the aiohttp_ doc.

.. _`aiohttp.ClientSession`: https://docs.aiohttp.org/en/stable/client_reference.html?#aiohttp.ClientSession
.. _`aiohttp.ClientResponse`: https://docs.aiohttp.org/en/stable/client_reference.html?#aiohttp.ClientResponse
.. _aiohttp: https://docs.aiohttp.org/en/stable/

Links & Contact Info
====================

| PyPI Package: https://pypi.python.org/pypi/aiohttp-requests
| GitHub Source: https://github.com/maxzheng/aiohttp-requests
| Report Issues/Bugs: https://github.com/maxzheng/aiohttp-requests/issues
|
| Connect: https://www.linkedin.com/in/maxzheng
| Contact: maxzheng.os @t gmail.com

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/maxzheng/aiohttp-requests",
    "name": "aiohttp-requests",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "aiohttp HTTP client async requests",
    "author": "Max Zheng",
    "author_email": "maxzheng.os @t gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/53/2b/34ddd6fb516a8439ec5a860d7640050b49c94b64b7b134cbfbf5a21bbe17/aiohttp-requests-0.2.4.tar.gz",
    "platform": null,
    "description": "aiohttp-requests\n============================================================\n\nBehold, the power of aiohttp_ client with `Requests <http://docs.python-requests.org/>`_ simplicity:\n\n.. code-block:: python\n\n    import asyncio\n\n    import aiohttp\n    from aiohttp_requests import requests\n\n    async def main():\n        response = await requests.get('https://api.github.com', auth=aiohttp.BasicAuth('user', 'password'))\n        text = await response.text()\n        json = await response.json()\n        return response, text, json\n\n    r, text, json = asyncio.run(main())\n\n    >>> r\n    <ClientResponse(https://api.github.com/) [200 OK]>\n    >>> r.status\n    200\n    >>> r.headers['Content-Type']\n    'application/json; charset=utf-8'\n    >>> r.get_encoding()\n    'utf-8'\n    >>> text\n    '{\"current_user_url\":\"https://api.github.com/user\",...'\n    >>> json\n    {'current_user_url': 'https://api.github.com/user', ... }\n\nPlus built-in concurrency control to do multiple requests safely:\n\n.. code-block:: python\n\n    async def main():\n        # Pass in a list of urls instead of just one. Optionally pass in as_iterator=True to iterate the responses.\n        responses = await requests.get(['https://api.github.com'] * 2, auth=aiohttp.BasicAuth('user', 'password'))\n        print(responses)    # [<ClientResponse(https://...) [200 OK]>, , <ClientResponse(https://...) [200 OK]>]\n\n        # It defaults to 10 concurrent requests maximum. If you can handle more, then set it higher:\n        requests.max_concurrency = 100\n\n    asyncio.run(main())\n\nThe `requests` object is just proxying `get` and other HTTP verb methods to `aiohttp.ClientSession`_, which returns `aiohttp.ClientResponse`_. To do anything else, read the aiohttp_ doc.\n\n.. _`aiohttp.ClientSession`: https://docs.aiohttp.org/en/stable/client_reference.html?#aiohttp.ClientSession\n.. _`aiohttp.ClientResponse`: https://docs.aiohttp.org/en/stable/client_reference.html?#aiohttp.ClientResponse\n.. _aiohttp: https://docs.aiohttp.org/en/stable/\n\nLinks & Contact Info\n====================\n\n| PyPI Package: https://pypi.python.org/pypi/aiohttp-requests\n| GitHub Source: https://github.com/maxzheng/aiohttp-requests\n| Report Issues/Bugs: https://github.com/maxzheng/aiohttp-requests/issues\n|\n| Connect: https://www.linkedin.com/in/maxzheng\n| Contact: maxzheng.os @t gmail.com\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A thin wrapper for aiohttp client with Requests simplicity",
    "version": "0.2.4",
    "project_urls": {
        "Homepage": "https://github.com/maxzheng/aiohttp-requests"
    },
    "split_keywords": [
        "aiohttp",
        "http",
        "client",
        "async",
        "requests"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1b8f723efa0175d71272432566bd85739257add08bd1381799141f62596cc2c5",
                "md5": "bbc0e2bc17b9b63f20e767f33def69e7",
                "sha256": "d201d699748f2e1459a49e8b7e53be1d05a487f3827c201a05941139678199b8"
            },
            "downloads": -1,
            "filename": "aiohttp_requests-0.2.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bbc0e2bc17b9b63f20e767f33def69e7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 4336,
            "upload_time": "2024-05-11T19:48:52",
            "upload_time_iso_8601": "2024-05-11T19:48:52.234891Z",
            "url": "https://files.pythonhosted.org/packages/1b/8f/723efa0175d71272432566bd85739257add08bd1381799141f62596cc2c5/aiohttp_requests-0.2.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "532b34ddd6fb516a8439ec5a860d7640050b49c94b64b7b134cbfbf5a21bbe17",
                "md5": "3a24b6d3f93e373077ab3a68792628f8",
                "sha256": "63036b83fabcf359aee33f957f7d8d12532c7d465c1343ab03a53faf38ae9e0c"
            },
            "downloads": -1,
            "filename": "aiohttp-requests-0.2.4.tar.gz",
            "has_sig": false,
            "md5_digest": "3a24b6d3f93e373077ab3a68792628f8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 7070,
            "upload_time": "2024-05-11T19:48:53",
            "upload_time_iso_8601": "2024-05-11T19:48:53.898548Z",
            "url": "https://files.pythonhosted.org/packages/53/2b/34ddd6fb516a8439ec5a860d7640050b49c94b64b7b134cbfbf5a21bbe17/aiohttp-requests-0.2.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-11 19:48:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "maxzheng",
    "github_project": "aiohttp-requests",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [
        {
            "name": "aiohttp",
            "specs": []
        },
        {
            "name": "coworker",
            "specs": [
                [
                    "==",
                    "2.*"
                ]
            ]
        }
    ],
    "tox": true,
    "lcname": "aiohttp-requests"
}
        
Elapsed time: 0.26388s