Skip to main content

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

  • Builds Reusable Objects for Consuming Web APIs.

  • Works with Requests, asyncio, 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, headers, Path, Query

class GitHub(Consumer):

   @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("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.

Use decorators and function annotations to describe the HTTP request:

  • URL parameter replacement and query parameter support

  • Convert response bodies into Python objects (e.g., using marshmallow or a custom converter)

  • JSON, URL-encoded, and multipart request body and file upload

  • Inject functions as middleware to apply custom response and error handling

Installation

uplink supports Python 2.7 & 3.3-3.7.

To install the latest stable release, you can use pip:

$ 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]

Documentation

For more details, check out the documentation at https://uplink.readthedocs.io/.

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 💜

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uplink-0.5.5.tar.gz (31.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uplink-0.5.5-py2.py3-none-any.whl (40.4 kB view details)

Uploaded Python 2Python 3

Release history Release notifications | RSS feed

0.10.0

2 files

0.9.7

2 files

0.9.6

2 files

0.9.5

2 files

0.9.4

2 files

0.9.3

2 files

0.9.2

2 files

0.9.1

2 files

0.9.0

2 files

0.8.0.post2

2 files

0.8.0.post1

1 file

0.8.0.post0

1 file

0.7.0

2 files

0.6.1

2 files

0.6.0

2 files

This release

0.5.5 This release

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.2.2

2 files

0.2.0.post3

2 files

0.2.0.post2

3 files

0.2.0.post1

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page