Uplink

A Declarative HTTP Client for Python, inspired by Retrofit.

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

Navigation

  • Installation
  • Introduction
  • Quickstart
  • 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 Coverage Status 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

@headers({"Accept": "application/vnd.github.v3.full+json"})
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 responses into Python objects (e.g., using marshmallow)
  • JSON, URL-encoded, and multipart request body and file upload

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
  • 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
  • Function Annotations
    • Path
    • Query
    • QueryMap
    • Header
    • HeaderMap
    • Field
    • FieldMap
    • Part
    • PartMap
    • Body
    • Url
  • HTTP Clients
    • Requests
    • Aiohttp
    • Twisted
  • Converters
    • Marshmallow
  • Changelog
    • 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