1

I remember seeing a REST API client module for Python that was way easier to use than Requests. Can't find it now. Before I write a wrapper of my own, would like to ask around first.

It was smth like this:

>>> r = rest.API("http://example.com/api")
>>> r.foo(arg1=["a","b","c"],arg2=2)
{
  'bar': 'baz'
}

1 Answer 1

0

DRest is the closest I currently see:

(From its tutorial)

import drest

# Create a generic client api object
api = drest.API('http://localhost:8000/api/v1/')

# Make calls openly via any HTTP Method, and any path
# GET http://localhost:8000/api/v1/users/1/
response = api.make_request('GET', '/users/1/')

# Or attach a resource
api.add_resource('users')

# Get available resources
api.resources
>>> ['users', 'projects', 'etc']

# Get all objects of a resource
# GET http://localhost:8000/api/v1/users/
response = api.users.get()

# Get a single resource with primary key '1'
# GET http://localhost:8000/api/v1/users/1/
response = api.users.get(1)

# Create a resource data dictionary
user_data = dict(
    username='john.doe',
    password='oober-secure-password',
    first_name='John',
    last_name='Doe',
    )

# POST http://localhost:8000/api/v1/users/
response = api.users.post(user_data)

(etc)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.