Generic API wrapper
Project description
Generic API wrapper
version=0.2.0
generic-api-wrapper is a generic REST API python wrapper. It comes with an AWS IAM authenticator out of the box.
Getting started
Install
pip install generic-api-wrapper
Usage
Basic usage
from generic_api_wrapper import Api
# To create an API wrapper object provide base url
# Let's take Github for example
api = Api("https://api.github.com")
# Get repos of a user
# This is equivalent to sending a GET request to
# https://api.github.com/users/grishasergii/repos
repos = api.users.grishasergii.repos()
# If a resource name violates Python attributes syntax then use __getitem__
# This is equivalent to sending a GET request to
# https://api.i-do-not-exist.com/resources/imaginary-resource
imaginary_api = Api("https://api.i-do-not-exist.com")
resource = api.resources["imaginary-resource"]()
# provide data for POST request
imaginary_api.resources.post(data={"name": "resource-name"})
Authentication
- AWS IAM authnetication
from generic_api_wrapper import Api, AwsIamAuth
api_url = "https://api.aws-powered-api.com"
# AWS IAM authentication. Credentials and AWS region are inferred by boto3 from the app environment
auth = AwsIamAuth(api_url).auth
# Create an API wrapper object that is authenticated to call an API configured with an AWS IAM authorizer
api = Api(api_url, auth)
- custom authenticator: create a custom authenticator that fits your requirements
and provide it to the
Apiconstructor, it will be passed to thesessionobject when sending a request.
License
Free software: MIT license
Credits
This package was created with Cookiecutter_ and the audreyr/cookiecutter-pypackage_ project template.
- Cookiecutter: https://github.com/audreyr/cookiecutter
audreyr/cookiecutter-pypackage: https://github.com/audreyr/cookiecutter-pypackage
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file generic-api-wrapper-0.2.0.tar.gz.
File metadata
- Download URL: generic-api-wrapper-0.2.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc92fe7f49ba08f8daa742296686a017dfd0f5bfa3f35e3fd800f74da707d56e
|
|
| MD5 |
fac61c80128264f12e2b7d2cc54176e4
|
|
| BLAKE2b-256 |
c6b746d0753d341f2c662cfb7f3a10611f6fa71ec3de7b6679b445afcc46c811
|
File details
Details for the file generic_api_wrapper-0.2.0-py3-none-any.whl.
File metadata
- Download URL: generic_api_wrapper-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41112369a54c8268a5a0b2311c8085c89576d292c6cee17413398e036949dc2b
|
|
| MD5 |
4ac7be512bd47cd526510bde33807197
|
|
| BLAKE2b-256 |
6fa2523003125d595dd76cd054d62840a946cccb759c7cae018d523ab1053479
|