是否有通用 python 库来使用基于 REST 的服务?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4355997/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a Generic python library to consume REST based services?
提问by chiggsy
Ok. I want to consume REST based services.
好的。我想使用基于 REST 的服务。
I'd like to use python. In fact, I am going to use python.
我想使用python。事实上,我将使用python。
The way I'd like to use it is from the command line/ipython, to try out different REST services, with intention of formally coding it later. ( my usage of the REST service notthe generic api thing )
我想使用它的方式是从命令行/ipython 尝试不同的 REST 服务,并打算稍后对其进行正式编码。(我对 REST 服务的使用不是通用的 api 东西)
I'm looking for a pretty generic, fully featured REST client/API in python. Not bare bones, but plush, nice to use. There are tons of them out there, but I'd kind of like to settle on one and master it.
我正在寻找一个非常通用、功能齐全的 Python REST 客户端/API。不是裸露的骨头,而是毛绒的,很好用。那里有很多,但我有点想选择一个并掌握它。
Any suggestions?
有什么建议?
EDIT: This is one:
编辑:这是一个:
https://github.com/benoitc/restkit
https://github.com/benoitc/restkit
EDIT: http://pypi.python.org/pypi/requestsis exactly it.
编辑:http: //pypi.python.org/pypi/requests就是这样。
EDIT: http://pypi.python.org/pypi/siestais just as perfect!
编辑:http: //pypi.python.org/pypi/siesta同样完美!
采纳答案by Ken Kinder
The problem with having a "plush" REST client library is that REST itself isn't that well-defined. REST, in and of itself, just means that you want to use HTTP standards whenever possible, but other than that, the field is wide open.
拥有“豪华” REST 客户端库的问题在于 REST 本身并没有那么明确。REST 本身只是意味着您希望尽可能使用 HTTP 标准,但除此之外,该领域是开放的。
Is the data encoded with JSON? What are the URL schemes and what do they mean?
数据是否使用 JSON 编码?什么是 URL 方案,它们是什么意思?
Since REST basically just means HTTP, your best bet is httplib, but I wouldn't describe it as plush.
由于 REST 基本上只是意味着 HTTP,因此您最好的选择是 httplib,但我不会将其描述为长毛绒。
回答by Casey
回答by h0b0
Something like a generic REST library is hardly possible since each REST interface is different. Whith WADLthere has been an attempt to establish a WSDL-lik interface description language for RESTful services. Using such a description a generic client would be possible but no one seems to care about WADL. And everyone seems fine with that.
像通用 REST 库这样的东西几乎是不可能的,因为每个 REST 接口都是不同的。对于WADL,已经尝试为 RESTful 服务建立类似 WSDL 的接口描述语言。使用这样的描述,通用客户端是可能的,但似乎没有人关心 WADL。每个人似乎都很好。

