python的声明性http客户端。

uplink的Python项目详细描述


PyPI VersionBuild StatusCodecovMaintainabilityDocumentation StatusJoin the chat at https://gitter.im/python-uplink/LobbyCode style: black

  • 为使用webapi构建可重用对象。
  • requestsaiohttptwisted一起使用。
  • 灵感来自Retrofit

使用Github API v3

上行链路将您的http api转换为python类。

fromuplinkimportConsumer,get,Path,QueryclassGitHub(Consumer):"""A Python Client for the GitHub API."""@get("users/{user}/repos")defget_repos(self,user:Path,sort_by:Query("sort")):"""Retrieves the user's public repositories."""

构建一个与webservice交互的实例。

github=GitHub(base_url="https://api.github.com/")

然后,执行http请求就像调用方法一样简单。

repos=github.get_repos(user="octocat",sort_by="created")

返回的对象是友好的^{tt1}$

print(repos.json())# Output: [{'id': 64778136, 'name': 'linguist', ...

对于发送非阻塞请求,上行链路支持 ^{tt2}$ and ^{tt3}$

准备好用上行链路启动第一个api客户端了吗?从这个开始quick tutorial

特点

Uplink正式支持Python2.7&3.3-3.7。

安装

要安装最新的稳定版本,可以使用pip(或pipenv):

$ pip install -U uplink

如果您对最新版本感兴趣,请使用以下工具预览即将发布的版本:

$ pip install https://github.com/prkumar/uplink/archive/master.zip

额外的额外的!

此外,上行链路具有可选的集成和功能。您可以查看完整的列表 可获得的额外费用的here

使用pip安装上行链路时,可以使用以下格式选择附加功能:

$ pip install -U uplink[extra1, extra2, ..., extraN]

例如,要安装aiohttpmarshmallow支持:

$ pip install -U uplink[aiohttp, marshmallow]

用户证明

Michael Kennedy@mkennedy),播客Talk PythonPython Bytes的主持人-

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.

或Carmi@liiight),notifiers维护者-

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.

文件

https://uplink.readthedocs.io/查看库的文档。

对于新用户来说,一个好的起点是quick tutorial

社区

加入Gitter上的对话,提出问题,提供反馈, 与其他用户见面!

贡献

想报告一个错误,请求一个特性,或贡献代码上行链路? 在Contribution Guide中查找起始位置。 感谢您花时间改进一个开源项目:purple_heart:

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
javajaxb在嵌套节点中生成xmlns:xsi声明   java重定向到youtube以上传jsp上可用的视频   java提高了JVM和ANT的性能   java如何将返回的JSON数据放在HTML表单中   java如何发送XWWWFORMURLENCODE在重新授权   java为什么jvm XX:+EliminateAllocations失败   堆移除和重建方法?(爪哇)   Stanford NPL in Spark(Scala)应用程序运行到Java堆空间(Java.lang.OutOfMemoryError)   调试java中打开/关闭println的任何方式(详细模式)   java IntelliJ在鼠标悬停时显示JavaDocs工具提示   Olingo Odata Java中的自动扩展选项   json将postgres文本arry转换为java列表?   oop需要帮助推断Java代码   复选框的java添加操作侦听器AbstractTableModel   java如何从公共静态void main(String[]args)传递值   java从数据库中获取大值   java Processing 2.0电影从jar运行时无法打开电影文件   java如何在不使用应用程序的情况下刷新活动?   尝试将JSON解析为ListView时的Android:JSON parse:null对象引用