• 天气服务API文档 第1版


    HTTP接口设计文档

    此文档为开发HTTP接口的设计文档,目前用于提供天气查询的相关接口。

    测试的时候使用
    URL=http://www.dennisthink.com/test/api/weather/v1/

    正式使用的时候
    URL=http://www.dennisthink.com/api/weather/v1/

    1 获取服务版本接口

    GET
    http://www.dennisthink.com/api/weather/v1/get_version 
    

    请求的json(无)

    返回的json

    {
        "code": 0,
        "message": "SUCCEED",
        "body": {
            "version": "0.1.0"
        }
    }
    

    2 根据编号查询天气

    GET 
    URL: http://www.dennisthink.com/api/weather/v1/get_weather_by_city_code?token=1234567890ABCDEF&&city_code=10029111810&&date=2018-03-01
    
    

    请求参数

    token:向我申请
    city_code:城市编号
    date:日期
    

    返回的json:

    {
        "code": 0,
        "message": "SUCCEED",
        "body": {
            "city_code": "10029111810",
            "city_name": "番禺",
            "weather": "小雨",
            "high_temperature": "26℃",
            "low_temperature": "17℃",
            "air_quality": "小雨",
            "sun_up": "06:37",
            "sun_down": "18:35"
        }
    }
    
    

    3 根据名称查询天气

    GET 
    URL: http://www.dennisthink.com/api/weather/v1/get_weather_by_city_name?token=1234567890ABCDEF&&city_name=海淀&&date=2018-03-01
    
    

    请求的json

    token:向我申请
    city_name:城市名称,目前仅支持中文
    date:日期
    

    返回的json:

    {
        "code": 0,
        "message": "SUCCEED",
        "body": {
            "city_code": "10011111410",
            "city_name": "海淀",
            "weather": "晴转多云转多云转晴",
            "high_temperature": "10℃",
            "low_temperature": "1℃",
            "air_quality": "晴转多云转多云转晴",
            "sun_up": "06:33",
            "sun_down": "18:17"
        }
    }
    
    

    4 获取城市编号

    GET 
    URL: http://www.dennisthink.com/api/weather/v1/get_city_code?token=1234567890ABCDEF&&city_name=朝阳
    

    请求的json

    token:向我申请
    city_name:城市名称,目前仅支持中文
    

    返回的json:

    {
        "code": 0,
        "message": "SUCCEED",
        "body": [
            {
                "city_code": "10011111110",
                "city_name": "",
                "country": "中国",
                "province": "北京市",
                "city": "市辖区",
                "county": "朝阳区",
                "addr": "朝阳"
            },
            {
                "city_code": "10016201417",
                "city_name": "",
                "country": "中国",
                "province": "辽宁省",
                "city": "辽阳市",
                "county": "朝阳市",
                "addr": "朝阳县"
            },
            {
                "city_code": "10017111410",
                "city_name": "",
                "country": "中国",
                "province": "吉林省",
                "city": "长春市",
                "county": "朝阳区",
                "addr": "朝阳"
            }
        ]
    }
    
    

    5 获取天气建议

    GET 
    URL: http://www.dennisthink.com/api/weather/v1/get_weather_suggestion_by_city_code?token=1234567890ABCDEF&&city_code=10028201517&&date=2018-03-01
    

    请求的json

    token:向我申请
    city_code:城市编号
    date:日期
    

    返回的json:

    {
        "code": 0,
        "message": "SUCCEED",
        "body": {
            "city_code": "10028201517",
            "city_name": "",
            "ultra_degree": "最弱",
            "ultra_detail": "辐射弱,涂擦SPF8-12防晒护肤品。",
            "cold_degree": "较易发",
            "cold_detail": "天凉,湿度大,较易感冒。",
            "clothes_degree": "较舒适",
            "clothes_detail": "建议穿薄外套或牛仔裤等服装。",
            "car_wash_degree": "不宜",
            "car_wash_detail": "有雨,雨水和泥水会弄脏爱车。",
            "air_fouling_degree": "良",
            "air_fouling_detail": "气象条件有利于空气污染物扩散。"
        }
    }
    
    

    6 获取小时的详细天气

    GET 
    URL: http://www.dennisthink.com/api/weather/v1/get_hour_detail_by_city_code?token=1234567890ABCDEF&&city_code=10028201512&&date=2018-03-01&&hour=1
    

    请求的json

    token:向我申请
    city_code:城市编号
    date:日期
    hour:小时(24小时制)
    

    返回的json:

    {
        "code": 0,
        "message": "SUCCEED",
        "body": {
            "hour": "1",
            "weather": "",
            "air_quality": "",
            "temperature": "12",
            "relative_humidity": "96",
            "precipitation": "0.0",
            "wind_direction": "西北风",
            "wind_power": "0"
        }
    }
    

    7 获取某天的小时天气详情

    GET 
    URL: http://www.dennisthink.com/api/weather/v1/get_today_detail_by_city_code?token=1234567890ABCDEF&&city_code=10010101010&&date=2018-01-01
    

    请求的json

    token:向我申请
    city_code:城市编号
    date:日期
    

    返回的json:

    {
        "code": 0,
        "message": "Succeed",
        "body": 
        	{
        	    "city_code": "1010101100",
                "city_name": "朝阳",
                "date":"",
                "detail":[
                    {
                    "hour":"01",
                    "weather":"天气",
                    "air_quality":"空气质量",
                    "temperature":"温度",
                    "relative_humidity":"相对湿度",
                    "precipitation":"降水",
                    "wind_direction":"风向",
                    "wind_power":"风力"
                    },
                    {
                    "hour":"02",
                    "weather":"天气",
                    "air_quality":"空气质量",
                    "temperature":"温度",
                    "relative_humidity":"相对湿度",
                    "precipitation":"降水",
                    "wind_direction":"风向",
                    "wind_power":"风力"
                    }
                ]
            }
    }
    

    下一个阶段的API

    8.邮件订阅

    POST 
    URL: http://www.dennisthink.com/api/weather/v1/create_daily_weather_email_subscription
    

    提交的json

    {
        "email": "xxx@yyy.com",
        "city_code": ""
    }
    

    返回的json

    {
        "code": 0,
        "message": "succeed"
    }
    

    9.取消订阅

    POST 
    URL: http://www.dennisthink.com/api/weather/v1/remove_daily_weather_email_subscription
    

    提交的json

    {
        "email": "xxx@yyy.com",
        "city_code": ""
    }
    

    返回的json

    {
        "code": 0,
        "message": "succeed"
    }
    

    10.获取订阅列表

    POST 
    URL: http://www.dennisthink.com/api/weather/v1/get_daily_weather_email_subscription_list
    

    提交的json

    {
        "email": "xxx@yyy.com",http://www.dennisthink.com/api/weather/v1/get_weather_by_city_code?token=1243234234&&city_code=100000000&&date=2018-01-01
    }
    

    返回的json

    {
        "code": 0,
        "message": "succeed",
        "body": {
            "city_code_list": [
                {
                    "city_code": "",
                    "city_name": ""
                },
                {
                    "city_code": "",
                    "city_name": ""
                }
            ]
        }
    }
    
  • 相关阅读:
    ActiveSync合作关系对话框的配置
    WINCE对象存储区(object store)
    Wince 隐藏TASKBAR的方法
    Wince输入法换肤换语言机制
    poj 3080 Blue Jeans 解题报告
    codeforces A. Vasily the Bear and Triangle 解题报告
    hdu 1050 Moving Tables 解题报告
    hdu 1113 Word Amalgamation 解题报告
    codeforces A. IQ Test 解题报告
    poj 1007 DNA Sorting 解题报告
  • 原文地址:https://www.cnblogs.com/Dennis-mi/p/8149025.html
Copyright © 2020-2023  润新知