GithubHelp home page GithubHelp logo

tecnoterabyte / uplink Goto Github PK

View Code? Open in Web Editor NEW

This project forked from prkumar/uplink

0.0 2.0 0.0 728 KB

A Declarative HTTP Client for Python

Home Page: https://uplink.readthedocs.io/

License: MIT License

Python 100.00%

uplink's Introduction

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, 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.

Features

  • Quickly Define Structured API Clients
    • Use decorators and function annotations to describe the HTTP request.
    • URL parameter replacement, request headers, and query parameter support.
    • JSON, URL-encoded, and multipart request body and file upload.
  • Bring Your Own HTTP Library
    • Use Requests by default.
    • Send non-blocking HTTP requests with Aiohttp or Twisted.
    • Supply your own requests.Session or aiohttp.ClientSession object for greater control.
  • Directly Convert Response Bodies into Python Objects
  • Extendable
  • Authentication
    • Built-in support for Basic Authentication.
    • Works with external auth support for Requests or Aiohttp.

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

Ready to create an API client with Uplink? Get started with this quickstart guide! 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 💜

uplink's People

Contributors

prkumar avatar fabiorosado avatar itstehkman avatar brandonio21 avatar kadrach avatar

Watchers

James Cloos avatar Wilmer Arambula avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.