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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file uplink-0.5.2.tar.gz.
File metadata
- Download URL: uplink-0.5.2.tar.gz
- Upload date:
- Size: 31.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c726424cfe3f5a0c33639cf585934566ec8fcce79d5bd964a9bde3a43f96c8d
|
|
| MD5 |
53b065b0b919dc822690e04726e434d2
|
|
| BLAKE2b-256 |
614e012b9c795422e3f3a32223150321cbfd7e9125110c6ad2deb4c74aae42f2
|
File details
Details for the file uplink-0.5.2-py2.py3-none-any.whl.
File metadata
- Download URL: uplink-0.5.2-py2.py3-none-any.whl
- Upload date:
- Size: 39.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5eeaa62ecadc2fc88defaa51f451a0068d8516480fd0561a5ae055a167255b50
|
|
| MD5 |
58da0e7ae60eaab522462f23c4549bd9
|
|
| BLAKE2b-256 |
52ee493d256453a923f1e23daedd788eb4d75ee4ca40db7be2555e42c1c147f8
|