博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
天气服务API文档 第1版
阅读量:6310 次
发布时间:2019-06-22

本文共 5474 字,大约阅读时间需要 18 分钟。

HTTP接口设计文档

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

测试的时候使用

URL=http://www.dennisthink.com/test/api/weather/v1/

正式使用的时候

URL=http://www.dennisthink.com/api/weather/v1/

1 获取服务版本接口

GEThttp://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": ""            }        ]    }}

转载于:https://www.cnblogs.com/Dennis-mi/p/8149025.html

你可能感兴趣的文章
在Linux上高效开发的7个建议
查看>>
java数据结构 - 数组使用的代码
查看>>
个人简历-项目经验
查看>>
swoole异步任务task处理慢请求简单实例
查看>>
oracle数据泵导入分区表统计信息报错(四)
查看>>
spring技术内幕读书笔记之IoC容器的学习
查看>>
细说多线程(五) —— CLR线程池的I/O线程
查看>>
JavaScript instanceof和typeof的区别
查看>>
Hadoop文件系统详解-----(一)
查看>>
《面向模式的软件体系结构2-用于并发和网络化对象模式》读书笔记(8)--- 主动器...
查看>>
状态码
查看>>
我的友情链接
查看>>
用sqlplus远程连接oracle命令
查看>>
多年一直想完善的自由行政审批流程组件【2002年PHP,2008年.NET,2010年完善数据设计、代码实现】...
查看>>
自动生成四则运算题目
查看>>
【翻译】使用新的Sencha Cmd 4命令app watch
查看>>
【前台】【单页跳转】整个项目实现单页面跳转,抛弃iframe
查看>>
因为你是前端程序员!
查看>>
数据库设计中的14个技巧
查看>>
Android学习系列(5)--App布局初探之简单模型
查看>>