uplink


Nameuplink JSON
Version 0.9.7 PyPI version JSON
download
home_pagehttps://uplink.readthedocs.io/
SummaryA Declarative HTTP Client for Python.
upload_time2022-03-12 04:14:48
maintainer
docs_urlNone
authorP. Raj Kumar
requires_python
licenseMIT
keywords http api rest client retrofit
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Uplink
******
|PyPI Version| |Build Status| |Coverage Status| |Code Climate| |Documentation Status|
|GitHub Discussions| |Gitter| |Code Style|

- Builds Reusable Objects for Consuming Web APIs.
- Works with **Requests**, **aiohttp**, and **Twisted**.
- Inspired by `Retrofit <http://square.github.io/retrofit/>`__.

A Quick Walkthrough, with GitHub API v3
=======================================
Uplink turns your HTTP API into a Python class.

.. code-block:: python

   from uplink import Consumer, get, Path, Query


   class GitHub(Consumer):
       """A Python Client for the GitHub API."""

       @get("users/{user}/repos")
       def get_repos(self, user: Path, sort_by: Query("sort")):
           """Retrieves the user's public repositories."""

Build an instance to interact with the webservice.

.. code-block:: python

   github = GitHub(base_url="https://api.github.com/")

Then, executing an HTTP request is as simply as invoking a method.

.. code-block:: python

   repos = github.get_repos(user="octocat", sort_by="created")

The returned object is a friendly |requests.Response|_:

.. |requests.Response| replace:: ``requests.Response``
.. _requests.Response: http://docs.python-requests.org/en/master/api/#requests.Response

.. code-block:: python

   print(repos.json())
   # Output: [{'id': 64778136, 'name': 'linguist', ...

For sending non-blocking requests, Uplink comes with support for
|aiohttp and twisted|_.

.. |aiohttp and twisted| replace:: ``aiohttp`` and ``twisted``
.. _`aiohttp and twisted`: https://github.com/prkumar/uplink/tree/master/examples/async-requests

Ready to launch your first API client with Uplink? Start with this `quick tutorial`_!

Features
========

- **Quickly Define Structured API Clients**

  - Use decorators and type hints to describe each HTTP request
  - JSON, URL-encoded, and multipart request body and file upload
  - URL parameter replacement, request headers, and query parameter support

- **Bring Your Own HTTP Library**

  - `Non-blocking I/O support`_ for Aiohttp and Twisted
  - `Supply your own session`_ (e.g., ``requests.Session``) for greater control

- **Easy and Transparent Deserialization/Serialization**

  - Define `custom converters`_ for your own objects
  - Support for |marshmallow|_ schemas, |pydantic|_ models, and `handling collections`_ (e.g., list of Users)

- **Extendable**

  - Install optional plugins for additional features (e.g., `protobuf support`_)
  - Compose `custom response and error handling`_ functions as middleware

- **Authentication**

  - Built-in support for `Basic Authentication`_
  - Use existing auth libraries for supported clients (e.g., |requests-oauthlib|_)

Uplink officially supports Python 2.7 and 3.5+.

**Note:** Python 2.7 suport will be removed in v0.10.0.

.. |marshmallow| replace:: ``marshmallow``
.. |pydantic| replace:: ``pydantic``
.. |requests-oauthlib| replace:: ``requests-oauthlib``
.. _`Non-blocking I/O support`: https://github.com/prkumar/uplink/tree/master/examples/async-requests
.. _`Supply your own session`: https://uplink.readthedocs.io/en/latest/user/clients.html#swapping-out-the-default-http-session
.. _`marshmallow`: https://github.com/prkumar/uplink/tree/master/examples/marshmallow
.. _`custom converters`: https://uplink.readthedocs.io/en/latest/user/serialization.html#custom-json-deserialization
.. _`handling collections`: https://uplink.readthedocs.io/en/latest/user/serialization.html#converting-collections
.. _`custom response and error handling`: https://uplink.readthedocs.io/en/latest/user/quickstart.html#response-and-error-handling
.. _`protobuf support`: https://github.com/prkumar/uplink-protobuf
.. _`requests-oauthlib`: https://github.com/requests/requests-oauthlib
.. _`Basic Authentication`: https://uplink.readthedocs.io/en/latest/user/auth.html#basic-authentication
.. _`pydantic`: https://pydantic-docs.helpmanual.io/

Installation
============

To install the latest stable release, you can use ``pip`` (or ``pipenv``):

::

    $ pip install -U uplink

If you are interested in the cutting-edge, preview the upcoming release with:

::

   $ pip install https://github.com/prkumar/uplink/archive/master.zip

Extra! Extra!
-------------

Further, uplink has optional integrations and features. You can view a full list
of available extras `here <https://uplink.readthedocs.io/en/latest/user/install.html#extras>`_.

When installing Uplink with ``pip``, you can select extras using the format:

::

   $ pip install -U uplink[extra1, extra2, ..., extraN]


For instance, to install ``aiohttp`` and ``marshmallow`` support:

::

   $ pip install -U uplink[aiohttp, marshmallow]


User Testimonials
=================

**Michael Kennedy** (`@mkennedy`_), host of `Talk Python`_ and `Python Bytes`_ podcasts-

    Of course our first reaction when consuming HTTP resources in Python is to
    reach for Requests. But for *structured* APIs, we often want more than ad-hoc
    calls to Requests. We want a client-side API for our apps. Uplink is
    the quickest and simplest way to build just that client-side API.
    Highly recommended.

.. _@mkennedy: https://twitter.com/mkennedy
.. _`Talk Python`: https://twitter.com/TalkPython
.. _`Python Bytes`: https://twitter.com/pythonbytes

**Or Carmi** (`@liiight`_), notifiers_ maintainer-

    Uplink's intelligent usage of decorators and typing leverages the most
    pythonic features in an elegant and dynamic way. If you need to create an
    API abstraction layer, there is really no reason to look elsewhere.

.. _@liiight: https://github.com/liiight
.. _notifiers: https://github.com/notifiers/notifiers


Documentation
=============

Check out the library's documentation at https://uplink.readthedocs.io/.

For new users, a good place to start is this `quick tutorial`_.


Community
=========

Use the `Discussions`_ tab on GitHub to join the conversation! Ask questions, provide feedback,
and meet other users!

We're migrating our community from `Gitter`_ to GitHub `Discussions`_. Feel free to search our
Gitter lobby for past questions and answers. However, to help us transition, please start new
threads/posts in GitHub Discussions instead of Gitter.

.. _Discussions: https://github.com/prkumar/uplink/discussions
.. _Gitter: https://gitter.im/python-uplink/Lobby


Contributing
============

Want to report a bug, request a feature, or contribute code to Uplink?
Checkout the `Contribution Guide`_ for where to start.
Thank you for taking the time to improve an open source project :purple_heart:

.. |GitHub Discussions| image:: https://img.shields.io/github/discussions/prkumar/uplink.png
   :target: https://github.com/prkumar/uplink/discussions
.. |Build Status| image:: https://travis-ci.com/prkumar/uplink.svg?branch=master
   :target: https://travis-ci.com/prkumar/uplink
.. |Code Climate| image:: https://api.codeclimate.com/v1/badges/d5c5666134763ff1d6c0/maintainability
   :target: https://codeclimate.com/github/prkumar/uplink/maintainability
   :alt: Maintainability
.. |Code Style| image:: https://img.shields.io/badge/code%20style-black-000000.svg
   :target: https://github.com/ambv/black
   :alt: Code style: black
.. |Coverage Status| image:: https://img.shields.io/codecov/c/github/prkumar/uplink.svg
   :alt: Codecov
   :target: https://codecov.io/gh/prkumar/uplink
.. |Documentation Status| image:: https://readthedocs.org/projects/uplink/badge/?version=latest
   :target: http://uplink.readthedocs.io/en/latest/?badge=latest
   :alt: Documentation Status
.. |Gitter| image:: https://badges.gitter.im/python-uplink/Lobby.svg
   :target: https://gitter.im/python-uplink/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
   :alt: Join the chat at https://gitter.im/python-uplink/Lobby
.. |License| image:: https://img.shields.io/github/license/prkumar/uplink.svg
   :target: https://github.com/prkumar/uplink/blob/master/LICENSE
.. |PyPI Version| image:: https://img.shields.io/pypi/v/uplink.svg
   :target: https://pypi.python.org/pypi/uplink

.. _`Contribution Guide`: https://github.com/prkumar/uplink/blob/master/CONTRIBUTING.rst
.. _`quick tutorial`: https://uplink.readthedocs.io/en/latest/user/quickstart.html



            

Raw data

            {
    "_id": null,
    "home_page": "https://uplink.readthedocs.io/",
    "name": "uplink",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "http api rest client retrofit",
    "author": "P. Raj Kumar",
    "author_email": "raj.pritvi.kumar@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e6/10/f93f050e6528346c78a4d96d7f92c2af0e25b98f108e4a36a96074fbd7e1/uplink-0.9.7.tar.gz",
    "platform": null,
    "description": "Uplink\n******\n|PyPI Version| |Build Status| |Coverage Status| |Code Climate| |Documentation Status|\n|GitHub Discussions| |Gitter| |Code Style|\n\n- Builds Reusable Objects for Consuming Web APIs.\n- Works with **Requests**, **aiohttp**, and **Twisted**.\n- Inspired by `Retrofit <http://square.github.io/retrofit/>`__.\n\nA Quick Walkthrough, with GitHub API v3\n=======================================\nUplink turns your HTTP API into a Python class.\n\n.. code-block:: python\n\n   from uplink import Consumer, get, Path, Query\n\n\n   class GitHub(Consumer):\n       \"\"\"A Python Client for the GitHub API.\"\"\"\n\n       @get(\"users/{user}/repos\")\n       def get_repos(self, user: Path, sort_by: Query(\"sort\")):\n           \"\"\"Retrieves the user's public repositories.\"\"\"\n\nBuild an instance to interact with the webservice.\n\n.. code-block:: python\n\n   github = GitHub(base_url=\"https://api.github.com/\")\n\nThen, executing an HTTP request is as simply as invoking a method.\n\n.. code-block:: python\n\n   repos = github.get_repos(user=\"octocat\", sort_by=\"created\")\n\nThe returned object is a friendly |requests.Response|_:\n\n.. |requests.Response| replace:: ``requests.Response``\n.. _requests.Response: http://docs.python-requests.org/en/master/api/#requests.Response\n\n.. code-block:: python\n\n   print(repos.json())\n   # Output: [{'id': 64778136, 'name': 'linguist', ...\n\nFor sending non-blocking requests, Uplink comes with support for\n|aiohttp and twisted|_.\n\n.. |aiohttp and twisted| replace:: ``aiohttp`` and ``twisted``\n.. _`aiohttp and twisted`: https://github.com/prkumar/uplink/tree/master/examples/async-requests\n\nReady to launch your first API client with Uplink? Start with this `quick tutorial`_!\n\nFeatures\n========\n\n- **Quickly Define Structured API Clients**\n\n  - Use decorators and type hints to describe each HTTP request\n  - JSON, URL-encoded, and multipart request body and file upload\n  - URL parameter replacement, request headers, and query parameter support\n\n- **Bring Your Own HTTP Library**\n\n  - `Non-blocking I/O support`_ for Aiohttp and Twisted\n  - `Supply your own session`_ (e.g., ``requests.Session``) for greater control\n\n- **Easy and Transparent Deserialization/Serialization**\n\n  - Define `custom converters`_ for your own objects\n  - Support for |marshmallow|_ schemas, |pydantic|_ models, and `handling collections`_ (e.g., list of Users)\n\n- **Extendable**\n\n  - Install optional plugins for additional features (e.g., `protobuf support`_)\n  - Compose `custom response and error handling`_ functions as middleware\n\n- **Authentication**\n\n  - Built-in support for `Basic Authentication`_\n  - Use existing auth libraries for supported clients (e.g., |requests-oauthlib|_)\n\nUplink officially supports Python 2.7 and 3.5+.\n\n**Note:** Python 2.7 suport will be removed in v0.10.0.\n\n.. |marshmallow| replace:: ``marshmallow``\n.. |pydantic| replace:: ``pydantic``\n.. |requests-oauthlib| replace:: ``requests-oauthlib``\n.. _`Non-blocking I/O support`: https://github.com/prkumar/uplink/tree/master/examples/async-requests\n.. _`Supply your own session`: https://uplink.readthedocs.io/en/latest/user/clients.html#swapping-out-the-default-http-session\n.. _`marshmallow`: https://github.com/prkumar/uplink/tree/master/examples/marshmallow\n.. _`custom converters`: https://uplink.readthedocs.io/en/latest/user/serialization.html#custom-json-deserialization\n.. _`handling collections`: https://uplink.readthedocs.io/en/latest/user/serialization.html#converting-collections\n.. _`custom response and error handling`: https://uplink.readthedocs.io/en/latest/user/quickstart.html#response-and-error-handling\n.. _`protobuf support`: https://github.com/prkumar/uplink-protobuf\n.. _`requests-oauthlib`: https://github.com/requests/requests-oauthlib\n.. _`Basic Authentication`: https://uplink.readthedocs.io/en/latest/user/auth.html#basic-authentication\n.. _`pydantic`: https://pydantic-docs.helpmanual.io/\n\nInstallation\n============\n\nTo install the latest stable release, you can use ``pip`` (or ``pipenv``):\n\n::\n\n    $ pip install -U uplink\n\nIf you are interested in the cutting-edge, preview the upcoming release with:\n\n::\n\n   $ pip install https://github.com/prkumar/uplink/archive/master.zip\n\nExtra! Extra!\n-------------\n\nFurther, uplink has optional integrations and features. You can view a full list\nof available extras `here <https://uplink.readthedocs.io/en/latest/user/install.html#extras>`_.\n\nWhen installing Uplink with ``pip``, you can select extras using the format:\n\n::\n\n   $ pip install -U uplink[extra1, extra2, ..., extraN]\n\n\nFor instance, to install ``aiohttp`` and ``marshmallow`` support:\n\n::\n\n   $ pip install -U uplink[aiohttp, marshmallow]\n\n\nUser Testimonials\n=================\n\n**Michael Kennedy** (`@mkennedy`_), host of `Talk Python`_ and `Python Bytes`_ podcasts-\n\n    Of course our first reaction when consuming HTTP resources in Python is to\n    reach for Requests. But for *structured* APIs, we often want more than ad-hoc\n    calls to Requests. We want a client-side API for our apps. Uplink is\n    the quickest and simplest way to build just that client-side API.\n    Highly recommended.\n\n.. _@mkennedy: https://twitter.com/mkennedy\n.. _`Talk Python`: https://twitter.com/TalkPython\n.. _`Python Bytes`: https://twitter.com/pythonbytes\n\n**Or Carmi** (`@liiight`_), notifiers_ maintainer-\n\n    Uplink's intelligent usage of decorators and typing leverages the most\n    pythonic features in an elegant and dynamic way. If you need to create an\n    API abstraction layer, there is really no reason to look elsewhere.\n\n.. _@liiight: https://github.com/liiight\n.. _notifiers: https://github.com/notifiers/notifiers\n\n\nDocumentation\n=============\n\nCheck out the library's documentation at https://uplink.readthedocs.io/.\n\nFor new users, a good place to start is this `quick tutorial`_.\n\n\nCommunity\n=========\n\nUse the `Discussions`_ tab on GitHub to join the conversation! Ask questions, provide feedback,\nand meet other users!\n\nWe're migrating our community from `Gitter`_ to GitHub `Discussions`_. Feel free to search our\nGitter lobby for past questions and answers. However, to help us transition, please start new\nthreads/posts in GitHub Discussions instead of Gitter.\n\n.. _Discussions: https://github.com/prkumar/uplink/discussions\n.. _Gitter: https://gitter.im/python-uplink/Lobby\n\n\nContributing\n============\n\nWant to report a bug, request a feature, or contribute code to Uplink?\nCheckout the `Contribution Guide`_ for where to start.\nThank you for taking the time to improve an open source project :purple_heart:\n\n.. |GitHub Discussions| image:: https://img.shields.io/github/discussions/prkumar/uplink.png\n   :target: https://github.com/prkumar/uplink/discussions\n.. |Build Status| image:: https://travis-ci.com/prkumar/uplink.svg?branch=master\n   :target: https://travis-ci.com/prkumar/uplink\n.. |Code Climate| image:: https://api.codeclimate.com/v1/badges/d5c5666134763ff1d6c0/maintainability\n   :target: https://codeclimate.com/github/prkumar/uplink/maintainability\n   :alt: Maintainability\n.. |Code Style| image:: https://img.shields.io/badge/code%20style-black-000000.svg\n   :target: https://github.com/ambv/black\n   :alt: Code style: black\n.. |Coverage Status| image:: https://img.shields.io/codecov/c/github/prkumar/uplink.svg\n   :alt: Codecov\n   :target: https://codecov.io/gh/prkumar/uplink\n.. |Documentation Status| image:: https://readthedocs.org/projects/uplink/badge/?version=latest\n   :target: http://uplink.readthedocs.io/en/latest/?badge=latest\n   :alt: Documentation Status\n.. |Gitter| image:: https://badges.gitter.im/python-uplink/Lobby.svg\n   :target: https://gitter.im/python-uplink/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge\n   :alt: Join the chat at https://gitter.im/python-uplink/Lobby\n.. |License| image:: https://img.shields.io/github/license/prkumar/uplink.svg\n   :target: https://github.com/prkumar/uplink/blob/master/LICENSE\n.. |PyPI Version| image:: https://img.shields.io/pypi/v/uplink.svg\n   :target: https://pypi.python.org/pypi/uplink\n\n.. _`Contribution Guide`: https://github.com/prkumar/uplink/blob/master/CONTRIBUTING.rst\n.. _`quick tutorial`: https://uplink.readthedocs.io/en/latest/user/quickstart.html\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Declarative HTTP Client for Python.",
    "version": "0.9.7",
    "split_keywords": [
        "http",
        "api",
        "rest",
        "client",
        "retrofit"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "66ae8b06ac29d05fa896792dd2485b236265c381a1f6c3e3fcc6fdd989b44953",
                "md5": "1062821d31372d33a45d30da774f5936",
                "sha256": "4b50be0bb657ffd1c48e2c20bdf8538d512fe4b9f0520247d46249912ed19d15"
            },
            "downloads": -1,
            "filename": "uplink-0.9.7-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1062821d31372d33a45d30da774f5936",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 69536,
            "upload_time": "2022-03-12T04:14:46",
            "upload_time_iso_8601": "2022-03-12T04:14:46.015054Z",
            "url": "https://files.pythonhosted.org/packages/66/ae/8b06ac29d05fa896792dd2485b236265c381a1f6c3e3fcc6fdd989b44953/uplink-0.9.7-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e610f93f050e6528346c78a4d96d7f92c2af0e25b98f108e4a36a96074fbd7e1",
                "md5": "608b45b5ac92267f5947b4419281a501",
                "sha256": "8d5bff42fedfc1bec1c2959b7a15fc1354e1a32ead33facaeadfa76f7c5d68a2"
            },
            "downloads": -1,
            "filename": "uplink-0.9.7.tar.gz",
            "has_sig": false,
            "md5_digest": "608b45b5ac92267f5947b4419281a501",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 82122,
            "upload_time": "2022-03-12T04:14:48",
            "upload_time_iso_8601": "2022-03-12T04:14:48.072565Z",
            "url": "https://files.pythonhosted.org/packages/e6/10/f93f050e6528346c78a4d96d7f92c2af0e25b98f108e4a36a96074fbd7e1/uplink-0.9.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-03-12 04:14:48",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "uplink"
}
        
Elapsed time: 0.05899s