SlyAPI for Python
🐍 For Python 3.10+
No-boilerplate, async and typed web api access with oauth1/2. 😋
pip install slyapi
Meant as a foundation for other libraries more than being used directly. SlyAPI handles authorization and managing requests. It is used by my more specific libraries:
- SlyYTDAPI and SlyYTAAPI: for the YouTube APIs
- SlyTwitter
- SlySheets: for Google Sheets
- SlyGmail
There is also a version of this library available for F#/C#:
This library does not provide full coverage of OAuth1 or OAuth2, particularly it does not support the device code flow, nor the legacy implicit flow. Since it is intended to interface with 3rd party APIs, it does not implement the password flow.
Example CLI usage:
py may need to be replaced with python3 on Linux or MacOS.
ls
# ./my_cool_dev_app.py
py -m SlyAPI scaffold
# ... (wizard run)
# ./my_google_app.json
# ... (credentials filled)
py -m SlyAPI grant
# ... (wizard run)
# ./oauth2_grant.json
Note that the libraries listed above implement a more specific wizard to each API.
Example library usage:
from SlyAPI import *
class Mode(Enum):
XML = 'xml'
HTML = 'html'
JSON = None
class Units(Enum):
STANDARD = 'standard' # Kelvin
METRIC = 'metric'
IMPERIAL = 'imperial'
class City:
def __init__(self, src: dict[str, Any]):
self.name = src['name']
self.description = src['weather'][0]['description']
self.temperature = src['main']['temp']
# ...
class OpenWeather(WebAPI):
base_url = 'https://api.openweathermap.org/data/2.5'
def __init__(self, api_key: str):
super().__init__(UrlApiKey('appid', api_key))
async def city(self, location: str, mode: Mode=Mode.JSON,
units: Units=Units.STANDARD,
lang: str|None = None) -> City:
'''Get the current weather of a city.
Location format: `City,State,Country`
where State and Country are ISO3166 codes. '''
params = {
'q': location,
'lang': lang,
'units': units,
'mode': mode,
}
return City(await self.get_json('/weather', params))
# ...
Metadata
Release files for SlyAPI 0.6.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| slyapi-0.6.1.tar.gz | 20.3 kB | Without provenance | Details for slyapi-0.6.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| SlyAPI-0.6.1-py3-none-any.whl | Python 3 | none | any | Details for SlyAPI-0.6.1-py3-none-any.whl |
Total release size: 41.1 kB
Release files / slyapi-0.6.1.tar.gz
| Download URL | slyapi-0.6.1.tar.gz |
|---|---|
| Size | 20.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b60b9d7aac2f21f6d22edcd3fb29afaa79dd943d93a7815fcd3429e5797e5116
|
|
BLAKE2b-256 checksum How to use checksums |
9d0e7689fdedd4cf6fe576efc6d4d320cf1911cf55d136949909d47792e8dcd6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.0
|
Release files / SlyAPI-0.6.1-py3-none-any.whl
| Download URL | SlyAPI-0.6.1-py3-none-any.whl |
|---|---|
| Size | 20.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cbb89493022124ca6fb0aa9b54a1ab72de6fe247c2a0f55aaf1f67889a86afb2
|
|
BLAKE2b-256 checksum How to use checksums |
e2ba7e780f34815203def4ac73ab9a5017cfb448610d22a95aa5986c9047bd31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.0
|
Security for SlyAPI 0.6.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.