qweather
Qweather’s official quick start guide: https://dev.qweather.com/docs/start/
Qweather’s official terms explaination:https://dev.qweather.com/docs/start/glossary/
Qweather’s official API doc: https://dev.qweather.com/docs/api/
1 Usage Example
1.1 Setup Qweather API key
> (current-qweather-key "your-qweather-app-key")
1.2 Get the location id of a city
> (http-response-body (city/lookup "新郑")) '#hasheq((code . "200") (location . (#hasheq((adm1 . "Henan") (adm2 . "Zhengzhou") (country . "China") (fxLink . "http://hfx.link/2qp1") (id . "101180106") (isDst . "0") (lat . "34.39421") (lon . "113.73966") (name . "Xinzheng") (rank . "33") (type . "city") (tz . "Asia/Shanghai") (utcOffset . "+08:00")))) (refer . #hasheq((license . ("commercial license")) (sources . ("qweather.com")))))
1.3 Get the weather forecasting of a city
> (http-response-body (weather/now "101180106")) '#hasheq((code . "200") (fxLink . "http://hfx.link/2qp1") (now . #hasheq( (dew . "3"). #<forced-pair> . (feelsLike . "6") (humidity . "66") (icon . "154") (obsTime . "2021-02-27T17:53+08:00") (precip . "0.0") (pressure . "1018") (temp . "9") (text . "Overcast") (vis . "7") (wind360 . "135") (windDir . "SE") (windScale . "3") (windSpeed . "12"))) (refer . #hasheq((license . ("no commercial use")) (sources . ("Weather China")))) (updateTime . "2021-02-27T18:26+08:00"))
2 API
2.1 Parameters
parameter
(current-qweather-key v) → void? v : string?
= ""
parameter
(current-qweather-domain v) → void? v : string?
= "devapi.qweather.com"
parameter
(current-qweather-range v) → void? v : string?
= "world"
parameter
(current-qweather-number v) → void? v : number?
= 10
parameter
(current-qweather-gzip v) → void? v : string?
= "y"
parameter
(current-qweather-lang v) → void? v : string?
= "en"
Those parameters are used to controller the default values of procedures arguments described from Wrapped APIs.
The valid values of those parameters are very much dictated by the correspondingly available values of procedure arguments that specified at Wrapped APIs.
(city/lookup "xinzheng") is same as
(city/lookup "xinzheng" #:range "cn") if I set parameter
(current-qweather-range "cn").And for this case,
the valid values of current-qweather-range should be
world and cn because
the valid values of range argument of city/lookup is
world and cn.
2.2 Wrapped APIs
2.2.1 Searching cities
(require qweather/city) | package: qweather |
procedure
(city/lookup location [ #:adm adm #:range range #:number number #:gzip gzip #:lang lang]) → http-response location : string? adm : string? = "" range : (or/c "world" "cn") = (current-qweather-range) number : number? = (current-qweather-number) gzip : (or/c "y" "n") = (current-qweather-gzip) lang : string? = (current-qweather-lang)
procedure
(city/top [ #:range range #:number number #:gzip gzip #:lang lang]) → http-response range : (or/c "world" "cn") = (current-qweather-range) number : number? = (current-qweather-number) gzip : (or/c "y" "n") = (current-qweather-gzip) lang : string? = (current-qweather-lang)
procedure
(poi/lookup location [ #:type type #:city city #:number number #:gzip gzip #:lang lang]) → http-response location : string? type : string? = "scenic" city : string? = "" number : number? = (current-qweather-number) gzip : (or/c "y" "n") = (current-qweather-gzip) lang : string? = (current-qweather-lang)
procedure
(poi/range location [ #:type type #:radius radius #:number number #:gzip gzip #:lang lang]) → http-response location : string? type : string? = "scenic" radius : number? = 10 number : number? = (current-qweather-number) gzip : (or/c "y" "n") = (current-qweather-gzip) lang : string? = (current-qweather-lang)
2.2.2 Weather forecasting
(require qweather/forecast) | package: qweather |
procedure
(weather/now location [ #:gzip gzip #:lang lang #:unit unit]) → http-response location : string? gzip : (or/c "y" "n") = (current-qweather-gzip) lang : string? = (current-qweather-lang) unit : (or/c "m" "i") = "m"
procedure
(weather/3d location [ #:gzip gzip #:lang lang #:unit unit]) → http-response location : string? gzip : (or/c "y" "n") = (current-qweather-gzip) lang : string? = (current-qweather-lang) unit : (or/c "m" "i") = "m"
procedure
(weather/7d location [ #:gzip gzip #:lang lang #:unit unit]) → http-response location : string? gzip : (or/c "y" "n") = (current-qweather-gzip) lang : string? = (current-qweather-lang) unit : (or/c "m" "i") = "m"
procedure
(weather/10d location [ #:gzip gzip #:lang lang #:unit unit]) → http-response location : string? gzip : (or/c "y" "n") = (current-qweather-gzip) lang : string? = (current-qweather-lang) unit : (or/c "m" "i") = "m"
procedure
(weather/15d location [ #:gzip gzip #:lang lang #:unit unit]) → http-response location : string? gzip : (or/c "y" "n") = (current-qweather-gzip) lang : string? = (current-qweather-lang) unit : (or/c "m" "i") = "m"
procedure
(weather/24h location [ #:gzip gzip #:lang lang #:unit unit]) → http-response location : string? gzip : (or/c "y" "n") = (current-qweather-gzip) lang : string? = (current-qweather-lang) unit : (or/c "m" "i") = "m"
procedure
(weather/72h location [ #:gzip gzip #:lang lang #:unit unit]) → http-response location : string? gzip : (or/c "y" "n") = (current-qweather-gzip) lang : string? = (current-qweather-lang) unit : (or/c "m" "i") = "m"
procedure
(weather/168h location [ #:gzip gzip #:lang lang #:unit unit]) → http-response location : string? gzip : (or/c "y" "n") = (current-qweather-gzip) lang : string? = (current-qweather-lang) unit : (or/c "m" "i") = "m"
2.2.3 Disaster warning
(require qweather/warning) | package: qweather |
procedure
(warning/now location [ #:gzip gzip #:lang lang]) → http-response location : string? gzip : (or/c "y" "n") = (current-qweather-gzip) lang : string? = (current-qweather-lang)
procedure
(warning/list [#:range range #:gzip gzip]) → http-response
range : (or/c "cn") = (current-qweather-range) gzip : (or/c "y" "n") = (current-qweather-gzip)
2.2.4 AI
(require qweather/extend) | package: qweather |
procedure
(weather/24h/severe-weather-ai location [ #:lang lang]) → string? location : string? lang : string? = (current-qweather-lang)