vladkens
vladkens

Reputation: 353

Python RESTful client like Guzzle from PHP

What Python library provides RESTful client interface like:

client = Client(
    base_url="http://example.com/api/1/", auth=("user", "password"),
    cookie=cookielib.FileCookieJar('cookie-file'))
result = client.get('group', params={"groupname": "some_group", "expand": "users"})
result.json()

Upvotes: 6

Views: 3640

Answers (1)

L3viathan
L3viathan

Reputation: 27333

Not exactly like that, but you likely want requests

edit: since you want to ommit your base URL, try something like this:

base_url = "http://example.com/"
def requests_get(url, *args, **kwargs):
    return requests.get(base_url + url,*args,**kwargs)

An alternative solution is to subclass requests.Session as shown in this answer.

Upvotes: 8

Related Questions