Skip to content

adnam/resources

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

resources

Interact with HTTP resources

Examples:

Create an API resource object

from resources import JsonResource
my_api = JsonResource('http://example.com/api')

Alternatively with a configuration, parameters same as requests.request()

my_api = JsonResource('http://example.com/api', \
        options={"auth": ('username', 'password')})

Create a shortcut to a specific resource within the API

users = my_api.users

The variable "users" now points to 'http://example.com/api/users'. Now POSTing data to that resource returns a (status_code, result) tuple:

status, new_user = users.post(data={"name": "Steve", "email"="[email protected]"})

The json response is automatically decoded

name = new_user["data"]["name"]

Fetch a specific resource

status, rabbit = my_api.rabbits[6385].get()

And delete it

status, _ = my_api.rabbits[6385].delete()

About

Resources: Interact with HTTP resources

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages