| Name | SlyAPI JSON |
| Version |
0.6.1
JSON |
| download |
| home_page | None |
| Summary | No-boilerplate, async and typed web api access with oauth1/2. |
| upload_time | 2024-08-05 20:35:29 |
| maintainer | None |
| docs_url | None |
| author | Dunkyl 🔣🔣 |
| requires_python | >=3.10 |
| license | The MIT License Copyright © 2021 Maroue Reus Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| keywords |
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
#  SlyAPI for Python
<!-- elevator begin -->
> 🐍 For Python 3.10+
No-boilerplate, async and typed web api access with oauth1/2. 😋
```sh
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](https://github.com/dunkyl/SlyYTDAPI-Python) and [SlyYTAAPI](https://github.com/dunkyl/SlyYTAAPI-Python): for the YouTube APIs
- [SlyTwitter](https://github.com/dunkyl/SlyTwitter-Python)
- [SlySheets](https://github.com/dunkyl/SlySheets-Python): for Google Sheets
- [SlyGmail](https://github.com/dunkyl/SlyGmail-Python)
There is also a version of this library available for F#/C#:
- [SlyAPI for F#](https://github.com/dunkyl/SlyAPI-FSharp)
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.
<!-- elevator end -->
---
Example CLI usage:
`py` may need to be replaced with `python3` on Linux or MacOS.
```sh
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:
```py
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))
# ...
```
Raw data
{
"_id": null,
"home_page": null,
"name": "SlyAPI",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": null,
"author": "Dunkyl \ud83d\udd23\ud83d\udd23",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/9d/0e/7689fdedd4cf6fe576efc6d4d320cf1911cf55d136949909d47792e8dcd6/slyapi-0.6.1.tar.gz",
"platform": null,
"description": "#  SlyAPI for Python\r\n\r\n<!-- elevator begin -->\r\n\r\n> \ud83d\udc0d For Python 3.10+\r\n\r\nNo-boilerplate, async and typed web api access with oauth1/2. \ud83d\ude0b\r\n\r\n```sh\r\npip install slyapi\r\n```\r\n\r\nMeant 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:\r\n\r\n- [SlyYTDAPI](https://github.com/dunkyl/SlyYTDAPI-Python) and [SlyYTAAPI](https://github.com/dunkyl/SlyYTAAPI-Python): for the YouTube APIs\r\n- [SlyTwitter](https://github.com/dunkyl/SlyTwitter-Python)\r\n- [SlySheets](https://github.com/dunkyl/SlySheets-Python): for Google Sheets\r\n- [SlyGmail](https://github.com/dunkyl/SlyGmail-Python)\r\n\r\nThere is also a version of this library available for F#/C#:\r\n\r\n- [SlyAPI for F#](https://github.com/dunkyl/SlyAPI-FSharp)\r\n\r\nThis 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.\r\n\r\n<!-- elevator end -->\r\n\r\n---\r\n\r\nExample CLI usage:\r\n\r\n`py` may need to be replaced with `python3` on Linux or MacOS.\r\n```sh\r\nls\r\n# ./my_cool_dev_app.py\r\n\r\npy -m SlyAPI scaffold\r\n# ... (wizard run)\r\n# ./my_google_app.json\r\n\r\n# ... (credentials filled)\r\n\r\npy -m SlyAPI grant\r\n# ... (wizard run)\r\n# ./oauth2_grant.json\r\n```\r\n\r\nNote that the libraries listed above implement a more specific wizard to each API.\r\n\r\n---\r\n\r\nExample library usage:\r\n\r\n```py\r\nfrom SlyAPI import *\r\n\r\nclass Mode(Enum):\r\n XML = 'xml'\r\n HTML = 'html'\r\n JSON = None\r\n\r\nclass Units(Enum):\r\n STANDARD = 'standard' # Kelvin\r\n METRIC = 'metric'\r\n IMPERIAL = 'imperial'\r\n\r\nclass City:\r\n def __init__(self, src: dict[str, Any]):\r\n self.name = src['name']\r\n self.description = src['weather'][0]['description']\r\n self.temperature = src['main']['temp']\r\n # ...\r\n\r\nclass OpenWeather(WebAPI):\r\n base_url = 'https://api.openweathermap.org/data/2.5'\r\n\r\n def __init__(self, api_key: str):\r\n super().__init__(UrlApiKey('appid', api_key))\r\n\r\n async def city(self, location: str, mode: Mode=Mode.JSON,\r\n units: Units=Units.STANDARD,\r\n lang: str|None = None) -> City:\r\n '''Get the current weather of a city.\r\n Location format: `City,State,Country`\r\n where State and Country are ISO3166 codes. '''\r\n params = {\r\n 'q': location,\r\n 'lang': lang,\r\n 'units': units,\r\n 'mode': mode,\r\n }\r\n return City(await self.get_json('/weather', params))\r\n # ...\r\n```\r\n",
"bugtrack_url": null,
"license": "The MIT License Copyright \u00a9 2021 Maroue Reus Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \u201cSoftware\u201d), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \u201cAS IS\u201d, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "No-boilerplate, async and typed web api access with oauth1/2.",
"version": "0.6.1",
"project_urls": {
"Bug Tracker": "https://github.com/dunkyl/SlyAPI-Python/issues",
"Documentation": "https://docs.dunkyl.net/SlyAPI-Python/",
"Homepage": "https://docs.dunkyl.net/SlyAPI-Python/",
"Repository": "https://github.com/dunkyl/SlyAPI-Python"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e2ba7e780f34815203def4ac73ab9a5017cfb448610d22a95aa5986c9047bd31",
"md5": "6c8404247e9ed4f957685b704d198843",
"sha256": "cbb89493022124ca6fb0aa9b54a1ab72de6fe247c2a0f55aaf1f67889a86afb2"
},
"downloads": -1,
"filename": "SlyAPI-0.6.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6c8404247e9ed4f957685b704d198843",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 20795,
"upload_time": "2024-08-05T20:35:25",
"upload_time_iso_8601": "2024-08-05T20:35:25.259449Z",
"url": "https://files.pythonhosted.org/packages/e2/ba/7e780f34815203def4ac73ab9a5017cfb448610d22a95aa5986c9047bd31/SlyAPI-0.6.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9d0e7689fdedd4cf6fe576efc6d4d320cf1911cf55d136949909d47792e8dcd6",
"md5": "bd5a700966e0665ba5f7e2657f2a884d",
"sha256": "b60b9d7aac2f21f6d22edcd3fb29afaa79dd943d93a7815fcd3429e5797e5116"
},
"downloads": -1,
"filename": "slyapi-0.6.1.tar.gz",
"has_sig": false,
"md5_digest": "bd5a700966e0665ba5f7e2657f2a884d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 20292,
"upload_time": "2024-08-05T20:35:29",
"upload_time_iso_8601": "2024-08-05T20:35:29.520256Z",
"url": "https://files.pythonhosted.org/packages/9d/0e/7689fdedd4cf6fe576efc6d4d320cf1911cf55d136949909d47792e8dcd6/slyapi-0.6.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-05 20:35:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "dunkyl",
"github_project": "SlyAPI-Python",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "slyapi"
}