Uplink

A Declarative HTTP Client for Python, inspired by Retrofit.

https://secure.travis-ci.org/prkumar/uplink.svg?branch=master

Navigation

  • Installation
  • Introduction
  • Quickstart
  • Authentication
  • Tips & Tricks
  • Decorators
  • Function Annotations
  • HTTP Clients
  • Converters
  • Changelog

Related Topics

  • Documentation overview
    • Next: Installation

Quick search

Uplink 📡¶

A Declarative HTTP Client for Python. Inspired by Retrofit.

Release Python Version License Codecov Join the chat at https://gitter.im/python-uplink/Lobby

Note

Uplink is currently in initial development. Until the official release (v1.0.0), the public API should be considered provisional. Although we don’t expect any considerable changes to the API at this point, please avoid using the code in production, for now.

However, while Uplink is under construction, we invite eager users to install early and provide open feedback, which can be as simple as opening a GitHub issue when you notice a missing feature, latent defect, documentation oversight, etc.

Moreover, for those interested in contributing, checkout the Contribution Guide on GitHub!

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 list_repos(self, user: Path, sort_by: Query("sort")):
      """Get 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.list_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 (example).

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 define custom response and error handling

The User Manual¶

Follow this guide to get up and running with Uplink.

  • Installation
    • Using pip
    • Download the Source Code
    • Extras
  • Introduction
    • Static Request Handling
    • Dynamic Request Handling
  • Quickstart
    • Request Method
    • URL Manipulation
    • Request Body
    • Form Encoded, Multipart, and JSON
    • Header Manipulation
    • Synchronous vs. Asynchronous
    • Deserializing the Response Body
    • Custom Response and Error Handling
    • Annotating __init__() Arguments
    • _inject() Request Properties
  • Authentication
    • Basic Authentication
    • Other Authentication
    • Using Auth Support for Requests and aiohttp
  • Tips & Tricks
    • Decorating All Request Methods in a Class
    • Adopting the Argument’s Name
    • Annotating Your Arguments For Python 2.7

The Public API¶

This guide details the classes and methods in Uplink’s public API.

  • Decorators
    • headers
    • json
    • form_url_encoded
    • multipart
    • timeout
    • args
    • response_handler
    • error_handler
    • inject
    • returns.*
  • Function Annotations
    • Path
    • Query
    • QueryMap
    • Header
    • HeaderMap
    • Field
    • FieldMap
    • Part
    • PartMap
    • Body
    • Url
  • HTTP Clients
    • Requests
    • Aiohttp
    • Twisted
  • Converters
    • Marshmallow
    • Converting Collections
    • Writing a Custom Converter
  • Changelog
    • 0.5.5 - 2018-8-01
    • 0.5.4 - 2018-6-26
    • 0.5.3 - 2018-5-31
    • 0.5.2 - 2018-5-30
    • 0.5.1 - 2018-4-10
    • 0.5.0 - 2018-4-06
    • 0.4.1 - 2018-3-10
    • 0.4.0 - 2018-2-10
    • 0.3.0 - 2018-1-09
    • 0.2.2 - 2017-11-23
    • 0.2.0 - 2017-11-03
    • 0.1.1 - 2017-10-21
    • 0.1.0 - 2017-10-19
©2017, Raj Kumar. | Page source
Fork me on GitHub