А library for a REST API client that works with any API that follows somewhat the REST standard.
Project description
Free software: MIT license
Documentation: https://universal-api-client.readthedocs.io/en/latest/.
Features
This library is a small REST API client with the following features:
Url builder - allows you to build a url by natively calling the client’s attributes
HTTP requests - a thin wrapper around the requests library that allows full control of the HTTP requests.
Installation
pip install universal-api-client
Usage
Initialising the client
from universal_api_client import Client
swapi_client = Client(base_url='https://swapi.co/api/')
Building a URL
The url builder is part of the request (APIRequest) attribute of the client.
swapi_client.request.people # <universal_api_client.request.APIRequest at 0x1093c3eb8>
swapi_client.request.people.url # 'https://swapi.co/api/people/'
swapi_client.request.people(identifier=1).url # 'https://swapi.co/api/people/1/'
swapi_client.request.people(identifier='1').url # 'https://swapi.co/api/people/1/'
Making a request
The requests are made by the already built APIRequest object. The method call returns the appropriate method call from the requests library.
response = swapi_client.request.people(identifier='1').get() # <Response [200]>
print(response.status_code) # 200
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
Project details
Release history Release notifications | RSS feed
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 universal-api-client-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d62082b438011bf6b89647e6a3461dc94e2afef747368bfbc77d75542ce25b49 |
|
MD5 | b4dce0c8ffd2e053a96757884bfc60e3 |
|
BLAKE2b-256 | ca71edfc2fd1859d3c49c338013680f3213d52d11ca50154cb774c4ae2eed10b |
Hashes for universal_api_client-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87f873461877ea8ca3e9ffb1ba7dee0cba95aa390b8ae5f8f3b5fa930331e7cd |
|
MD5 | 09e8b168f09e9a10eb1d2fd84ca233ce |
|
BLAKE2b-256 | 841c32e98ca5148535653794550b0b1ad14ccbd4a6158680efa4bb909a90566c |