RESTful is a simple API library for Humans, inspired by Python Requests
Project description
Python RESTful Client 2
RESTful Clients2 is a simple high level library for Humans, inspired by Python Requests
>>> import restful_client2
>>> cf = restful_client2.CRUD(host="https://catfact.ninja/")
>>> data = cf.read("fact")
Focus on using Python data types instead of worrying about serialisation. Authentication, Timeouts, Retries, Backoff are all built in and can be adjusted.
Installation
You can install the client using PIP like so.
pip install RESTful-Client2
Logging
If you want to see logging set the level using the standard logging interface. DEBUG will show you URLLib3, but INFO will give you general information from the RESTful-Client2.
>>> import logging
>>> import restful_client2
>>> logging.basicConfig(level=logging.INFO)
Extending
The library has been created with extensability in mind. You can Sub Class CRUD for example and add the logic requirements needed to make the requests.
from restful_client2 import CRUD
class CatFactNinja(CRUD):
"""Cat Fact Ninja Interface"""
_fact_uri = "fact"
def __init__(self, **kwargs):
host = "http://catfact.ninja/"
super().__init__(host=host, **kwargs)
@property
def fact(self):
""" Get a Fact about Cats"""
return self.read(self._fact_uri)
cat = CatFactNinja()
print(cat.fact)
Todo List
- OAuth Client for Authentication
License
RESTful-Client is released under the MIT License. See the bundled LICENSE file for details.
Credits
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for RESTful_Client2-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 555a8e383a42893f5cc810a2b16267618f306c57b8f6a4c619fc93db74509e04 |
|
MD5 | d8d92e0823169ba8eff2bbedaf5b5d19 |
|
BLAKE2b-256 | d2c6f36847f44811b1423c1cafa1c42ef124e12751db29dd088f6a3010843385 |