qweather
1 Usage Example
1.1 Setup Qweather API key
1.2 Get the location id of a city
1.3 Get the weather forecasting of a city
2 API
2.1 Parameters
current-qweather-key
current-qweather-domain
current-qweather-range
current-qweather-number
current-qweather-gzip
current-qweather-lang
2.2 Wrapped APIs
2.2.1 Searching cities
city/  lookup
city/  top
poi/  lookup
poi/  range
2.2.2 Weather forecasting
weather/  now
weather/  3d
weather/  7d
weather/  10d
weather/  15d
weather/  24h
weather/  72h
weather/  168h
2.2.3 Disaster warning
warning/  now
warning/  list
2.2.4 AI
weather/  24h/  severe-weather-ai
8.4

qweather

Yanying Wang <yanyingwang1@gmail.com>

 (require qweather) package: qweather
Racket wrapper of Qweather(和风天气) API.

    1 Usage Example

      1.1 Setup Qweather API key

      1.2 Get the location id of a city

      1.3 Get the weather forecasting of a city

    2 API

      2.1 Parameters

      2.2 Wrapped APIs

        2.2.1 Searching cities

        2.2.2 Weather forecasting

        2.2.3 Disaster warning

        2.2.4 AI

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)  string?

(current-qweather-key v)  void?
  v : string?
 = ""
This key will be automatically included in the requesting of Qweather’s APIs, you can get the key through signuping Qweather website and creating an app for your account.

parameter

(current-qweather-domain)  string?

(current-qweather-domain v)  void?
  v : string?
 = "devapi.qweather.com"
For using a business version of Qweather account, you need to set this parameter to api.qweather.com.

parameter

(current-qweather-range)  string?

(current-qweather-range v)  void?
  v : string?
 = "world"

parameter

(current-qweather-number)  number?

(current-qweather-number v)  void?
  v : number?
 = 10

parameter

(current-qweather-gzip)  string?

(current-qweather-gzip v)  void?
  v : string?
 = "y"

parameter

(current-qweather-lang)  string?

(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.

For example,

2.2 Wrapped APIs

2.2.1 Searching cities

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

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

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

This section extended Qweather API to AI functions, which will directly tell you if there is severe weathers in the next. This only support to put out the chinese currently.

procedure

(weather/24h/severe-weather-ai location    
  [#:lang lang])  string?
  location : string?
  lang : string? = (current-qweather-lang)