Skip to main content

Requests-REST: A RESTful client based on requests

This library intends to provide an elegant RESTful client.

Installation

pip install requests-rest

Usage example

base_url = 'https://httpbin.org/'

new_name = 'aponder'
new_email = 'i@aponder.top'
new_user = {
    'name': new_name,
    'email': new_email,
}
update_user = new_user.copy()
update_user.update({'name': f'new {new_name}'})

# print(resource_user.list().json())
# print(resource_user.create(new_user).json())
# print(resource_user.update(1, new_user).json())
# print(resource_user.patch(1, new_name).json())
# print(resource_user.patch(1, new_email).json())
# print(resource_user.delete(1).json())

resource_client = Client(base_url, debug=True)
Users = resource_client('users')

users_creating = Users.create(new_user)
print(users_creating.response)

users_listing = Users.list(page=1, page_size=10)
print(users_listing.response)

users_detailing = Users.detail(1)
print(users_detailing.response)

users_updating = Users.update(2, update_user)
print(users_updating.response)

users_partial_updating = Users.partial_update(3, update_user)
print(users_partial_updating.response)

users_deleting = Users.delete(4)
print(users_deleting.response)

# extra actions
Users.login = Users.make_plural_action('login')
credentials = {'username': 'root', 'password': 'root'}
print(Users.login(credentials).response)

Users.disable = Users.make_single_action('disable')
print(Users.disable(2).response)

# resource combination
Blogs = resource_client('blogs')
UsersBlogs = users_detailing(Blogs)

new_blog = {'title': 'hello'}
print(UsersBlogs.create(new_blog).response)
print(UsersBlogs.list(page=2, page_size=20).response)
print(UsersBlogs.delete(10).response)
print(UsersBlogs.update(10, new_blog).response)
print(UsersBlogs.partial_update(10, new_blog).response)
print(UsersBlogs.delete(10).response)

Metadata

Release files for requests-rest 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for requests-rest 0.3.2
File Size Uploaded
requests-rest-0.3.2.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for requests-rest 0.3.2
File Interpreter ABI Platform
requests_rest-0.3.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 8.7 kB

Release files / requests-rest-0.3.2.tar.gz

Download URL requests-rest-0.3.2.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
558f8cbb54b02f2b1430b01ed5e5fe6b4cb733f6192fb489d67d61042d8e6fab
BLAKE2b-256 checksum
How to use checksums
4fa02385a3f2bc28f6bd18ab55c914544202145965a08e5bb2e32ba0a7380043
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.6

Release files / requests_rest-0.3.2-py2.py3-none-any.whl

Download URL requests_rest-0.3.2-py2.py3-none-any.whl
Size 4.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
649389c9c7e90ad116d6df83fc6b1d39c33237e5b618e155eefb8d93204933ec
BLAKE2b-256 checksum
How to use checksums
9b16fe051d53c8b6b70e22a26fb5d1d47807c53b2fb7bf8072527443e7d82d14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page