# 获取-天气预报

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /api/weather:
    get:
      summary: 获取-天气预报
      deprecated: false
      description: |
        获取-天气预报
      tags:
        - 天气预报
        - AJAX编程/天气预报
      parameters:
        - name: city
          in: query
          description: 城市code，北京市：110100
          required: true
          example: '110100'
          schema:
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                    title: 响应编码
                  message:
                    type: string
                    title: 响应消息
                  data:
                    type: object
                    properties:
                      date:
                        type: string
                        title: 日期
                      area:
                        type: string
                        title: 地区
                      dateShort:
                        type: string
                        title: 阳历日期
                      dateLunar:
                        type: string
                        title: 农历日期
                      temperature:
                        type: string
                        title: 温度
                        description: 当日温度
                      weather:
                        type: string
                        title: 天气
                      weatherImg:
                        type: string
                        title: 天气图片
                      windPower:
                        type: string
                        title: 风力等级
                      windDirection:
                        type: string
                        title: 风向
                      psPm25Level:
                        type: string
                        title: PM等级
                      psPm25:
                        type: string
                        title: PM指数
                      todayWeather:
                        type: object
                        properties:
                          humidity:
                            type: string
                            title: 湿度
                          sunriseTime:
                            type: string
                            title: 日出时间
                          sunsetTime:
                            type: string
                            title: 日落时间
                          ultraviolet:
                            type: string
                            title: 紫外线
                          weather:
                            type: string
                            title: 天气
                          temDay:
                            type: string
                            title: 日间温度
                            description: 最高温度
                          temNight:
                            type: string
                            title: 夜间温度
                            description: 最低温度
                        required:
                          - humidity
                          - sunriseTime
                          - sunsetTime
                          - ultraviolet
                          - weather
                          - temDay
                          - temNight
                        x-apifox-orders:
                          - humidity
                          - sunriseTime
                          - sunsetTime
                          - temDay
                          - temNight
                          - ultraviolet
                          - weather
                        title: 今日天气
                      dayForecast:
                        type: array
                        items:
                          type: object
                          properties:
                            date:
                              type: string
                              title: 日期
                            weather:
                              type: string
                              title: 天气
                            windPower:
                              type: string
                              title: 风力
                            dateFormat:
                              type: string
                              title: 日期格式
                              description: 今天，明天。。。
                            weatherImg:
                              type: string
                              title: 天气图片
                            windDirection:
                              type: string
                              title: 风向
                            temDay:
                              type: string
                              title: 日间温度
                              description: 最高温度
                            temNight:
                              type: string
                              title: 夜间温度
                              description: 最低温度
                          required:
                            - date
                            - weather
                            - windPower
                            - dateFormat
                            - weatherImg
                            - windDirection
                            - temDay
                            - temNight
                          x-apifox-orders:
                            - date
                            - dateFormat
                            - temDay
                            - temNight
                            - weather
                            - weatherImg
                            - windDirection
                            - windPower
                        title: 一周天气
                    required:
                      - date
                      - area
                      - dateShort
                      - dateLunar
                      - temperature
                      - weather
                      - weatherImg
                      - windPower
                      - windDirection
                      - psPm25Level
                      - psPm25
                      - todayWeather
                      - dayForecast
                    x-apifox-orders:
                      - date
                      - area
                      - dateShort
                      - dateLunar
                      - dayForecast
                      - psPm25
                      - psPm25Level
                      - temperature
                      - todayWeather
                      - weather
                      - weatherImg
                      - windDirection
                      - windPower
                    title: 响应数据
                required:
                  - code
                  - message
                  - data
                x-apifox-orders:
                  - code
                  - message
                  - data
              example:
                code: 10000
                message: 查询天气成功
                data:
                  date: '2023-02-12'
                  area: 北京市
                  dateShort: 02月12日
                  dateLunar: 正月廿二
                  temperature: '3'
                  weather: 霾
                  weatherImg: https://hmajax.itheima.net/weather/mailine.png
                  windPower: 1级
                  windDirection: 东风
                  psPm25Level: 中度
                  psPm25: '172'
                  todayWeather:
                    humidity: '69.0'
                    sunriseTime: '07:12'
                    sunsetTime: '17:46'
                    ultraviolet: 最弱
                    weather: 雨夹雪
                    temDay: '3'
                    temNight: '-5'
                  dayForecast:
                    - date: 02月12日
                      temDay: '3'
                      weather: 雨夹雪
                      temNight: '-5'
                      windPower: <3级
                      dateFormat: 今天
                      weatherImg: https://hmajax.itheima.net/weather/yujiaxue.png
                      windDirection: 东北风
                    - date: 02月13日
                      temDay: '7'
                      weather: 晴
                      temNight: '-4'
                      windPower: <3级
                      dateFormat: 明天
                      weatherImg: https://hmajax.itheima.net/weather/qing.png
                      windDirection: 北风
                    - date: 02月14日
                      temDay: '6'
                      weather: 多云
                      temNight: '-5'
                      windPower: <3级
                      dateFormat: 后天
                      weatherImg: https://hmajax.itheima.net/weather/duoyun.png
                      windDirection: 南风
                    - date: 02月15日
                      temDay: '4'
                      weather: 多云
                      temNight: '-6'
                      windPower: <3级
                      dateFormat: 周三
                      weatherImg: https://hmajax.itheima.net/weather/duoyun.png
                      windDirection: 南风
                    - date: 02月16日
                      temDay: '6'
                      weather: 晴
                      temNight: '-5'
                      windPower: <3级
                      dateFormat: 周四
                      weatherImg: https://hmajax.itheima.net/weather/qing.png
                      windDirection: 南风
                    - date: 02月17日
                      temDay: '4'
                      weather: 多云
                      temNight: '0'
                      windPower: <3级
                      dateFormat: 周五
                      weatherImg: https://hmajax.itheima.net/weather/duoyun.png
                      windDirection: 北风
                    - date: 02月18日
                      temDay: '6'
                      weather: 多云
                      temNight: '-1'
                      windPower: <3级
                      dateFormat: 周六
                      weatherImg: https://hmajax.itheima.net/weather/duoyun.png
                      windDirection: 东南风
          headers: {}
          x-apifox-name: 成功
        '400':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    title: 响应消息
                    description: 请检查network和文档要求的参数名和值是否携带
                  data:
                    type: object
                    properties: {}
                    x-apifox-orders: []
                    title: 响应结果
                required:
                  - message
                  - data
                x-apifox-orders:
                  - message
                  - data
              example:
                code: 400001
                message: 入参城市code:错误
                data: {}
          headers: {}
          x-apifox-name: 请求参数缺失_AJAX
        x-400:没有查询到数据:
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  message:
                    type: string
                  data:
                    type: 'null'
                required:
                  - code
                  - message
                  - data
                x-apifox-orders:
                  - code
                  - message
                  - data
              example:
                code: 40001
                message: 暂未开通此城市查询
                data: null
          headers: {}
          x-apifox-name: 没有查询到数据
      security: []
      x-apifox-folder: 天气预报
      x-apifox-status: released
      x-run-in-apifox: https://app.apifox.com/web/project/1937884/apis/api-49760220-run
components:
  schemas: {}
  securitySchemes: {}
servers: []
security: []

```
