Skip to content
A Declarative HTTP Client for Python
Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Update issue templates Oct 16, 2018
docs Clarify section titles in quickstart Aug 10, 2019
examples Add description for `handler_callbacks` to TOC Oct 9, 2018
tests
uplink Add Python 3.7 and 3.8 Travis builds (#186) Jan 1, 2020
.coveragerc Do not include io interfaces in coverage Dec 26, 2018
.flake8 Fix flake8 failures Jun 13, 2018
.gitignore
.pre-commit-config.yaml
.travis.yml Add Python 3.7 and 3.8 Travis builds (#186) Jan 1, 2020
AUTHORS.rst
CHANGELOG.rst
CODE_OF_CONDUCT.md Merge `hotfix/v0.1.1` into `develop` (#7) Oct 23, 2017
CONTRIBUTING.rst Update link to Google Python Style Guide Oct 27, 2018
LICENSE
MANIFEST.in Remove requirements.d from MANIFEST Jun 23, 2018
Pipfile Add Python 3.7 and 3.8 Travis builds (#186) Jan 1, 2020
README.rst Migrate repo to travis-ci.com Jan 2, 2020
pyproject.toml
rtd_requirements.txt Update requirements file for building docs Dec 29, 2018
setup.cfg Make aiohttp a conditional dependency based on Python version. Nov 4, 2017
setup.py Exclude tests subpackages from Python package Jan 10, 2020
tox.ini Add Python 3.7 and 3.8 Travis builds (#186) Jan 1, 2020
verify_tag.py

README.rst

Uplink

PyPI Version Build Status Codecov Maintainability Documentation Status Join the chat at https://gitter.im/python-uplink/Lobby Code style: black

  • Builds Reusable Objects for Consuming Web APIs.
  • Works with Requests, aiohttp, and Twisted.
  • Inspired by Retrofit.

A Quick Walkthrough, with GitHub API v3

Uplink turns your HTTP API into a Python class.

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.

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

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

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

The returned object is a friendly requests.Response:

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

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

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

Features

Uplink officially supports Python 2.7 & 3.3-3.7.

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.

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.

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.

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

Join the conversation on Gitter to ask questions, provide feedback, and meet other users!

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 💜

You can’t perform that action at this time.