Caiyun Weather API Python SDK
Install
Python 3.12+ is required.
pip install cy-weather-api
Usage
Request Caiyun API
NOTE: TAkhjf8d1nlSlspN is test token, no one can ensure its availability.
from cy_weather_api import CyWeatherAPIClient
client = CyWeatherAPIClient(token="TAkhjf8d1nlSlspN")
api_result = client.fetch(lng=101.8551, lat=26.6832, lang="zh_CN", alert=True)
print(api_result.result.hourly.description)
api_result = client.fetch(lng=-0.2008, lat=51.5024, lang="en_GB")
print(api_result.result.hourly.description)
api_result = client.fetch(lng=73.9808, lat=40.7648, lang="en_US")
print(api_result.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 httpx, you can use other HTTP client to request API,
and pass the response dict to our models (based on dataclass):
from cy_weather_api import CyWeatherResponse
data = {
"status": "ok",
"api_version": "v2.6",
"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},
}
result = CyWeatherResponse.from_dict(data)
Metadata
Release files for cy_weather_api 0.2.2
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 |
|---|---|---|---|---|
| cy_weather_api-0.2.2.tar.gz | 22.8 kB | Without provenance | Details for cy_weather_api-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cy_weather_api-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for cy_weather_api-0.2.2-py3-none-any.whl |
Total release size: 31.9 kB
Release files / cy_weather_api-0.2.2.tar.gz
| Download URL | cy_weather_api-0.2.2.tar.gz |
|---|---|
| Size | 22.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c589d7c288e85ccdc961fc3de41e29dad77c15bddd8aa5163bbb9cf9963cecbe
|
|
BLAKE2b-256 checksum How to use checksums |
bc0967b542492d515b1cbe668f7c2edbe2f931bde8999bcebcbf7fd92d0fbf4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.4.30
|
Release files / cy_weather_api-0.2.2-py3-none-any.whl
| Download URL | cy_weather_api-0.2.2-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0b8b414f8899bd81ae67b08f067073a34c6853d19014c530882cd916e7002bbd
|
|
BLAKE2b-256 checksum How to use checksums |
5df352b6971b64e56b9555dc2478e6034f176b12fd4d3a09fa25c3b878c8842d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.4.30
|
Security for cy_weather_api 0.2.2
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.