Caiyun Weather API Python SDK
Project description
Caiyun Weather API Python SDK
Install
Python 3.6+ is required.
pip install cy-weather-api
Usage
Request Caiyun API
from cy_weather_api import CyWeatherAPIClient
client = CyWeatherAPIClient(token="TAkhjf8d1nlSlspN")
apiResult = client.fetch(lng=101.8551, lat=26.6832, lang="zh_CN", alert=True)
print(apiResult.result.hourly.description)
apiResult = client.fetch(lng=-0.2008, lat=51.5024, lang="en_GB")
print(apiResult.result.hourly.description)
apiResult = client.fetch(lng=73.9808, lat=40.7648, lang="en_US")
print(apiResult.result.hourly.description)
Output sample:
晴,今天晚间20点钟后转小雨,其后多云
clear weather over the next 24 hours
clear weather, overcast after 20 o'clock this afternoon, followed by cloudy
Use our dataclass models
The default HTTP client is requests, you can other HTTP cient to request API,
and pass the response dict to our models (based on dataclasss
):
from cy_weather_api import initFromDict
data = {
"status": "ok",
"api_version": "v2.5",
"api_status": "active",
"lang": "en_US",
"unit": "metric",
"tzshift": 28800,
"timezone": "Asia/Shanghai",
"server_time": 1589125757,
"location": [39.888888, 116.674501],
"result": {"forecast_keypoint": "test forecast_keypoint", "primary": 0},
}
apiResult = initFromDict(data)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cy-weather-api-0.1.1.tar.gz
(5.8 kB
view hashes)
Built Distribution
Close
Hashes for cy_weather_api-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e92d4e3f0d166b2630b2f5700a0d8f45fa23a4052dcb987cbefc6968a3350105 |
|
MD5 | a1ceae50bd169284cd79b10bd0f09bc0 |
|
BLAKE2b-256 | c96599c6e6ccba063af6d7e7d21c2cdde792b4e66ddf304fe9a8325c35206cef |