Name | test-msklv-openweather-sdk JSON |
Version |
0.2.21
JSON |
| download |
home_page | |
Summary | SDK for accessing to OpenWeatherAPI |
upload_time | 2024-03-11 17:06:25 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.7 |
license | MIT License Copyright (c) 2024 Aleksandr Maskalev 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 |
weather
sdk
openweather
|
VCS |
|
bugtrack_url |
|
requirements |
requests
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# OpenWeatherSDK
## Introduction
SDK for accessing to [OpenWeatherAPI](https://openweathermap.org/api) and
retrieving information about current weather conditions in a specified city.
The SDK can operate in two modes: *on-demand* and *polling*. In *on-demand*
mode (the default mode), API requests are made on user demand, while in the
*polling* mode, there is regular polling of the API for weather updates in the
saved (previously requested) cities.
## Contents
[Installation](#installation)
[Prerequisites](#prerequisites)
[Client initialization](#client-initialization)
[Cache](#cache)
[Weather request](#weather-request)
[Description of response formats](#description-of-response-formats)
[Usage example](#usage-example)
[Errors](#errors)
## Installation
```python
pip install openweather_sdk
```
## Prerequisites
To work with the SDK, you need to obtain an access token for OpenWeatherAPI.
More information can be found on [FAQ page](https://openweathermap.org/faq)
("Get started" section -> "How to get an API key").
## Client initialization
The only required argument is [the access token](#prerequisites).
By default, the SDK operates in on-demand mode, returns information in English,
uses the metric system of measurements, has a cache size of 10 locations, and
the information remains valid for 10 minutes. You can modify this mode by
passing additional arguments during client initialization.
Additionally, if you need to modify the behavior of the SDK, you can pass
[additional arguments](#additional-arguments).
### Additional arguments
`mode` - determines the operating mode of the SDK. In on-demand mode, the SDK
makes requests to the API only upon client requests. In polling mode, the SDK
regularly polls the API. Defaults: on-demand. Available options: on-demand, polling.
`language` - determines the language for the output. Defaults: en. Available
options and more info see [here](https://openweathermap.org/current#multi).
`units` - determines the units of measurements for the output. Defaults:
metric. Available options and more info see
[here](https://openweathermap.org/current#data).
`cache_size` - determines the number of stored locations in cache. Defaults: 10.
`ttl` - determines the Time-To-Live of information in cache (in secs). Defaults:
600.
## Cache
Each client has its own cache, defined by the number of stored locations and
the Time-To-Live (TTL) of the information. In polling mode, the TTL determines
the API polling interval.
## Weather request
Currently, handling requests for current weather by location name is
implemented. By default, the response is returned in a compact format. You can
change this behavior by passing an [additional argument](#additional-arguments-1).
### Additional arguments
`compact_mode` - determines whether to return the response in a compact format.
Defaults: True.
## Description of response formats
### Compact format (used by default)
```json
{
"weather": {
"main": "Clear",
"description": "clear sky"
},
"temperature": {
"temp": 8.19,
"feels_like": 7.03
},
"visibility": 10000,
"wind": {
"speed": 2.06
},
"datatime": 1710099501,
"sys": {
"sunrise": 1710051241,
"sunset": 1710092882
},
"timezone": 3600,
"name": "Palais-Royal"
}
```
`weather.main` - group of weather parameters (Rain, Snow, Clouds etc.).
`weather.description` - weather condition within the group. More info see
[here](https://openweathermap.org/weather-conditions).
`temperature.temp` - temperature. Unit Standart: Kelvin, Metric: Celsius,
Imperial: Fahrenheit.
`temperature.feels_like` - temperature. This temperature parameter accounts for
the human perception of weather. Unit Standart: Kelvin, Metric: Celsius,
Imperial: Fahrenheit.
`visibility` - visibility, meter. The maximum value of the visibility is 10 km.
`wind.speed` - wind speed. Unit Standart: meter/sec, Metric: meter/sec,
Imperial: miles/hour.
`datatime` - time of data calculation, unix, UTC.
`sys.sunrise` - sunrise time, unix, UTC.
`sys.sunset` - sunset time, unix, UTC.
`timezone` - shift in seconds from UTC.
`name` - city name.
### Full format
```json
{
"coord": {
"lon": 2.32,
"lat": 48.858
},
"weather": [
{
"id": 800,
"main": "Clear",
"description": "clear sky",
"icon": "01n"
}
],
"base": "stations",
"main": {
"temp": 8.19,
"feels_like": 7.03,
"temp_min": 6.07,
"temp_max": 9.42,
"pressure": 998,
"humidity": 86
},
"visibility": 10000,
"wind": {
"speed": 2.06,
"deg": 220
},
"clouds": {
"all": 0
},
"dt": 1710099501,
"sys": {
"type": 2,
"id": 2012208,
"country": "FR",
"sunrise": 1710051241,
"sunset": 1710092882
},
"timezone": 3600,
"id": 6545270,
"name": "Palais-Royal",
"cod": 200
}
```
Description of full format see
[here](https://openweathermap.org/current#fields_json)
## Usage example
```python
>>> from openweather_sdk import Client
>>> c = Client(token=<YOUR_TOKEN>)
>>> c.health_check()
200
>>> c.get_location_weather("Paris")
{
"weather": {
"main": "Clear",
"description": "clear sky"
},
"temperature": {
"temp": 8.19,
"feels_like": 7.03
},
"visibility": 10000,
"wind": {
"speed": 2.06
},
"datatime": 1710099501,
"sys": {
"sunrise": 1710051241,
"sunset": 1710092882
},
"timezone": 3600,
"name": "Palais-Royal"
}
>>> c.get_location_weather("Paris", compact_mode=False)
{
"coord": {
"lon": 2.32,
"lat": 48.858
},
"weather": [
{
"id": 800,
"main": "Clear",
"description": "clear sky",
"icon": "01n"
}
],
"base": "stations",
"main": {
"temp": 8.19,
"feels_like": 7.03,
"temp_min": 6.07,
"temp_max": 9.42,
"pressure": 998,
"humidity": 86
},
"visibility": 10000,
"wind": {
"speed": 2.06,
"deg": 220
},
"clouds": {
"all": 0
},
"dt": 1710099501,
"sys": {
"type": 2,
"id": 2012208,
"country": "FR",
"sunrise": 1710051241,
"sunset": 1710092882},
"timezone": 3600,
"id": 6545270,
"name": "Palais-Royal",
"cod": 200
}
>>> c.remove()
```
## Errors
Description of possible errors can be found on
[FAQ page](https://openweathermap.org/faq) ("API errors" section).
Raw data
{
"_id": null,
"home_page": "",
"name": "test-msklv-openweather-sdk",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "weather,sdk,openweather",
"author": "",
"author_email": "Aleksandr Maskalev <avmaskalev@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/48/29/9f418c1cb0654b33be1895321386409b3aa015983b1a3ff96e052b883d73/test_msklv_openweather_sdk-0.2.21.tar.gz",
"platform": null,
"description": "# OpenWeatherSDK\n\n## Introduction\n\nSDK for accessing to [OpenWeatherAPI](https://openweathermap.org/api) and\nretrieving information about current weather conditions in a specified city.\nThe SDK can operate in two modes: *on-demand* and *polling*. In *on-demand*\nmode (the default mode), API requests are made on user demand, while in the\n*polling* mode, there is regular polling of the API for weather updates in the\nsaved (previously requested) cities.\n\n## Contents\n\n[Installation](#installation)\n\n[Prerequisites](#prerequisites)\n\n[Client initialization](#client-initialization)\n\n[Cache](#cache)\n\n[Weather request](#weather-request)\n\n[Description of response formats](#description-of-response-formats)\n\n[Usage example](#usage-example)\n\n[Errors](#errors)\n\n## Installation\n\n```python\npip install openweather_sdk\n```\n\n## Prerequisites\n\nTo work with the SDK, you need to obtain an access token for OpenWeatherAPI.\nMore information can be found on [FAQ page](https://openweathermap.org/faq)\n(\"Get started\" section -> \"How to get an API key\").\n\n## Client initialization\n\nThe only required argument is [the access token](#prerequisites).\n\nBy default, the SDK operates in on-demand mode, returns information in English,\nuses the metric system of measurements, has a cache size of 10 locations, and\nthe information remains valid for 10 minutes. You can modify this mode by\npassing additional arguments during client initialization.\n\nAdditionally, if you need to modify the behavior of the SDK, you can pass\n[additional arguments](#additional-arguments).\n\n### Additional arguments\n\n`mode` - determines the operating mode of the SDK. In on-demand mode, the SDK\nmakes requests to the API only upon client requests. In polling mode, the SDK\nregularly polls the API. Defaults: on-demand. Available options: on-demand, polling.\n\n`language` - determines the language for the output. Defaults: en. Available\noptions and more info see [here](https://openweathermap.org/current#multi).\n\n`units` - determines the units of measurements for the output. Defaults:\nmetric. Available options and more info see\n[here](https://openweathermap.org/current#data).\n\n`cache_size` - determines the number of stored locations in cache. Defaults: 10.\n\n`ttl` - determines the Time-To-Live of information in cache (in secs). Defaults:\n600. \n\n## Cache\n\nEach client has its own cache, defined by the number of stored locations and\nthe Time-To-Live (TTL) of the information. In polling mode, the TTL determines\nthe API polling interval.\n\n## Weather request\n\nCurrently, handling requests for current weather by location name is\nimplemented. By default, the response is returned in a compact format. You can\nchange this behavior by passing an [additional argument](#additional-arguments-1).\n\n### Additional arguments\n\n`compact_mode` - determines whether to return the response in a compact format.\nDefaults: True.\n\n## Description of response formats\n\n### Compact format (used by default)\n\n```json\n{\n \"weather\": {\n \"main\": \"Clear\",\n \"description\": \"clear sky\"\n }, \n \"temperature\": {\n \"temp\": 8.19,\n \"feels_like\": 7.03\n }, \n \"visibility\": 10000, \n \"wind\": {\n \"speed\": 2.06\n }, \n \"datatime\": 1710099501, \n \"sys\": {\n \"sunrise\": 1710051241,\n \"sunset\": 1710092882\n }, \n \"timezone\": 3600, \n \"name\": \"Palais-Royal\"\n}\n```\n\n`weather.main` - group of weather parameters (Rain, Snow, Clouds etc.).\n\n`weather.description` - weather condition within the group. More info see\n[here](https://openweathermap.org/weather-conditions).\n\n`temperature.temp` - temperature. Unit Standart: Kelvin, Metric: Celsius,\nImperial: Fahrenheit.\n\n`temperature.feels_like` - temperature. This temperature parameter accounts for\nthe human perception of weather. Unit Standart: Kelvin, Metric: Celsius,\nImperial: Fahrenheit.\n\n`visibility` - visibility, meter. The maximum value of the visibility is 10 km.\n\n`wind.speed` - wind speed. Unit Standart: meter/sec, Metric: meter/sec,\nImperial: miles/hour.\n\n`datatime` - time of data calculation, unix, UTC.\n\n`sys.sunrise` - sunrise time, unix, UTC.\n\n`sys.sunset` - sunset time, unix, UTC.\n\n`timezone` - shift in seconds from UTC.\n\n`name` - city name.\n\n### Full format\n\n```json\n{\n \"coord\": {\n \"lon\": 2.32,\n \"lat\": 48.858\n },\n \"weather\": [\n {\n \"id\": 800,\n \"main\": \"Clear\",\n \"description\": \"clear sky\",\n \"icon\": \"01n\"\n }\n ],\n \"base\": \"stations\",\n \"main\": {\n \"temp\": 8.19,\n \"feels_like\": 7.03,\n \"temp_min\": 6.07,\n \"temp_max\": 9.42,\n \"pressure\": 998,\n \"humidity\": 86\n },\n \"visibility\": 10000,\n \"wind\": {\n \"speed\": 2.06,\n \"deg\": 220\n },\n \"clouds\": {\n \"all\": 0\n },\n \"dt\": 1710099501,\n \"sys\": {\n \"type\": 2,\n \"id\": 2012208,\n \"country\": \"FR\",\n \"sunrise\": 1710051241,\n \"sunset\": 1710092882\n },\n \"timezone\": 3600,\n \"id\": 6545270,\n \"name\": \"Palais-Royal\",\n \"cod\": 200\n}\n```\n\nDescription of full format see\n[here](https://openweathermap.org/current#fields_json)\n\n\n## Usage example\n\n```python\n>>> from openweather_sdk import Client\n>>> c = Client(token=<YOUR_TOKEN>)\n>>> c.health_check()\n200\n>>> c.get_location_weather(\"Paris\")\n{\n \"weather\": {\n \"main\": \"Clear\",\n \"description\": \"clear sky\"\n }, \n \"temperature\": {\n \"temp\": 8.19,\n \"feels_like\": 7.03\n }, \n \"visibility\": 10000, \n \"wind\": {\n \"speed\": 2.06\n }, \n \"datatime\": 1710099501, \n \"sys\": {\n \"sunrise\": 1710051241,\n \"sunset\": 1710092882\n }, \n \"timezone\": 3600, \n \"name\": \"Palais-Royal\"\n}\n>>> c.get_location_weather(\"Paris\", compact_mode=False)\n{\n \"coord\": {\n \"lon\": 2.32,\n \"lat\": 48.858\n },\n \"weather\": [\n {\n \"id\": 800,\n \"main\": \"Clear\",\n \"description\": \"clear sky\",\n \"icon\": \"01n\"\n }\n ],\n \"base\": \"stations\",\n \"main\": {\n \"temp\": 8.19,\n \"feels_like\": 7.03,\n \"temp_min\": 6.07,\n \"temp_max\": 9.42,\n \"pressure\": 998,\n \"humidity\": 86\n },\n \"visibility\": 10000,\n \"wind\": {\n \"speed\": 2.06,\n \"deg\": 220\n },\n \"clouds\": {\n \"all\": 0\n },\n \"dt\": 1710099501,\n \"sys\": {\n \"type\": 2,\n \"id\": 2012208,\n \"country\": \"FR\",\n \"sunrise\": 1710051241,\n \"sunset\": 1710092882},\n \"timezone\": 3600,\n \"id\": 6545270,\n \"name\": \"Palais-Royal\",\n \"cod\": 200\n}\n>>> c.remove()\n```\n\n## Errors\n\nDescription of possible errors can be found on\n[FAQ page](https://openweathermap.org/faq) (\"API errors\" section).\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2024 Aleksandr Maskalev 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. ",
"summary": "SDK for accessing to OpenWeatherAPI",
"version": "0.2.21",
"project_urls": {
"Homepage": "https://github.com/maskalev/openweather_for_test_only-"
},
"split_keywords": [
"weather",
"sdk",
"openweather"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3f9aca7731dc1ff7bb3eaf56da53bf85dce13fa1fcd0b1a2cd511ee7d1804843",
"md5": "4438544f5bfda122a69778b6c9b21a48",
"sha256": "6e1bae47e983536dda5904a3f235250a687d2465178e1ca3b476edd1d9e6253b"
},
"downloads": -1,
"filename": "test_msklv_openweather_sdk-0.2.21-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4438544f5bfda122a69778b6c9b21a48",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 12492,
"upload_time": "2024-03-11T17:06:24",
"upload_time_iso_8601": "2024-03-11T17:06:24.490854Z",
"url": "https://files.pythonhosted.org/packages/3f/9a/ca7731dc1ff7bb3eaf56da53bf85dce13fa1fcd0b1a2cd511ee7d1804843/test_msklv_openweather_sdk-0.2.21-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "48299f418c1cb0654b33be1895321386409b3aa015983b1a3ff96e052b883d73",
"md5": "b11caf2d5db01e8204acefd20e9704e1",
"sha256": "52c600dc9df61d80ddf5d1acafd799f3f89bec4ecc135afd43680693044a07b1"
},
"downloads": -1,
"filename": "test_msklv_openweather_sdk-0.2.21.tar.gz",
"has_sig": false,
"md5_digest": "b11caf2d5db01e8204acefd20e9704e1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 12875,
"upload_time": "2024-03-11T17:06:25",
"upload_time_iso_8601": "2024-03-11T17:06:25.571902Z",
"url": "https://files.pythonhosted.org/packages/48/29/9f418c1cb0654b33be1895321386409b3aa015983b1a3ff96e052b883d73/test_msklv_openweather_sdk-0.2.21.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-11 17:06:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "maskalev",
"github_project": "openweather_for_test_only-",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "requests",
"specs": [
[
"~=",
"2.31.0"
]
]
}
],
"lcname": "test-msklv-openweather-sdk"
}