Browse Source

add api.md

maguohua 8 years ago
parent
commit
d23063c1d6
1 changed files with 110 additions and 0 deletions
  1. 110 0
      API.md

+ 110 - 0
API.md

@@ -0,0 +1,110 @@
+域名: http://cangdu.org
+
+端口:8001
+
+
+## 1.获取城市列表
+
+### 请求URL:  
+>**/v1/cities**
+
+### 示例:
+ [http://cangdu.org:8001/v1/cities?type=guess](http://cangdu.org:8001/v1/cities?type=guess)
+
+### 请求方式: 
+>**GET**
+
+### 请求参数
+
+|参数|是否必选|类型|说明|
+|:-----|:-------:|:-----|:-----|
+|type      |Y       |string  |类型  guess:定位城市,  hot:热门城市, group:所有城市 |
+
+### 返回示例
+
+```javascript
+{
+  id: 1,
+  name: "上海",
+  abbr: "SH",
+  area_code: "021",
+  sort: 1,
+  latitude: 31.23037,
+  longitude: 121.473701,
+  is_map: true,
+  pinyin: "shanghai"
+}
+```
+
+## 2.获取所选城市信息
+
+### 请求URL
+> **/v1/cities/:id**
+
+### 示例:
+>  [http://cangdu.org:8001/v1/cities/1](http://cangdu.org:8001/v1/cities/1)
+
+### 请求方式
+>**GET**
+
+### 请求参数
+
+|参数|是否必选|类型|说明|
+|:-----|:-------:|:-----|:-----|
+|id      |Y       |int   |城市id |
+
+### 返回示例
+```javascript
+{
+  id: 1,
+  name: "上海",
+  abbr: "SH",
+  area_code: "021",
+  sort: 1,
+  latitude: 31.23037,
+  longitude: 121.473701,
+  is_map: true,
+  pinyin: "shanghai"
+}
+```
+
+## 3.搜索地址
+
+### 请求URL
+>  **/v1/pois**
+
+### 示例:
+>  [http://cangdu.org:8001/v1/pois?city_id=1&keyword=迪士尼&type=search](http://cangdu.org:8001/v1/pois?city_id=1&keyword=%E8%BF%AA%E5%A3%AB%E5%B0%BC&type=search)
+
+### 请求方式
+> **GET**
+
+### 请求参数
+
+|参数|是否必选|类型|说明|
+|:-----|:-------:|:-----|:-----|
+|city_id      |Y       |int   |城市id |
+|keyword      |Y       |string   |搜索关键词 |
+|type      |N       |string   |搜索类型,默认为search |
+
+**返回示例**
+
+```javascript
+[
+    {
+        name: "上海迪士尼乐园",
+        address: "上海市浦东新区申迪西路753号",
+        latitude: 31.14419,
+        longitude: 121.66034,
+        geohash: "31.14419,121.66034"
+    },
+    {
+        name: "迪士尼",
+        address: "上海市浦东新区妙境路1118号家乐福川沙店1层",
+        latitude: 31.18183,
+        longitude: 121.69279,
+        geohash: "31.18183,121.69279"
+    },
+    ...  //共10个数据
+]
+```