No-boilerplate, async and typed web api access with oauth1/2.
Project description
SlyAPI for Python
🚧 This library is an early work in progress! Breaking changes may be frequent.
🐍 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. It is used by my more specific libraries:
- SlyYTDAPI and SlyYTAAPI: for the YouTube APIs
- SlyTwitter
- SlySheets: for Google Sheets
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 library usage:
from SlyAPI import *
class Mode(EnumParam):
XML = 'xml'
HTML = 'html'
JSON = None
class Units(EnumParam):
STANDARD = 'standard'
METRIC = 'metric'
IMPERIAL = 'imperial'
class City:
def __init__(self, src):
self.name = src['name']
self.description = src['weather']['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__(APIKey('appid', api_key))
async def city(self,
where: str,
mode: Mode=Mode.JSON,
units: Units=Units.METRIC,
lang: str = None) -> City:
'''
Get the current weather of a city.
Location format: `City,State,Country`
where State and Country are ISO3166 codes.
'''
params = {
**(mode+units).to_dict(),
'q': where,
'lang': lang
}
return City(await self.get_json('/weather', params))
# ...
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
SlyAPI-0.1.2.tar.gz
(11.1 kB
view hashes)
Built Distribution
SlyAPI-0.1.2-py3-none-any.whl
(11.7 kB
view hashes)