Skip to content
picasso250 edited this page Jan 13, 2013 · 10 revisions

Root Url

/api

General Rules for Client Request

Client reuqest root url with a JSON object(which is also called Key-Value pairs).

key value
action optional, not giving action key will make server auto assign "get" to action
kind / target the object kind(Class) you want to get
... other keys you want to specify, varied as different kinds

Available kinds:

  1. BigCategory
  2. Category
  3. Province
  4. City
  5. District
  6. ShopList
  7. Shop
  8. CouponList
  9. Coupon
  10. GroupBuyList
  11. GroupBuy

All keys are camelCases, just as a var in Java.

All values are

  • CamelCases if they are noun, just as a Class in Java.
  • lower cases if they are verb, just as a function in Java.

General Rules for Server Response

Sever will always return a JSON object.

On the top level of JSON object, there will be a key named apiVersion, whose value will be always 1.0.

Top level also has a data key or an error key.

JSON example for data

{
    "apiVersion": "1.0",
    "data": {
        // ...
    }
}

JSON example for Error HTTP status code changes along with this error code.

{
    "apiVersion": "1.0",
    "error": {
        "code": 404,
        "message": "can't find"
    }
}

On top level, data and error will never show up together.

BigCategory

Request

key value
kind BigCategory

Response

{
    "apiVersion": "1.0",
    "data":{
        "kind":"BigCategory",
        "totalItems":2,
        "itemCount":2,
        "items":[
            {
                "id":"1",
                "name":"\u9910\u996e\u7f8e\u98df"
            },
            {
                "id":"2",
                "name":"\u4f11\u95f2\u5a31\u4e50"
            }
        ]
    }
}

Category

Request

key value
kind Category
bigCategoryId numeric

ShopList

Request

key value
kind ShopList
distance unit: m
latilongi +0.0+0.0 or 0.0,0.0
districtId numeric
cityId numeric
bigCategoryId numeric
categoryId numeric
startIndex unsigned int
itemsPerPage unsigned int
keyword string

If you give keyword, you can search shops by name.

If you give bigCategoryId(only), you will get all shops in this big category.

Response

{
    "data": {
        "kind": "shoplist",
        "totalItems": 6741,
        "startIndex": 1,
        "itemsPerPage": 10,
        "itemCount": 10,
        "items": [
            {
                "name": "xxx",
                "type": "专营门店",
                "latilongi": "+40.6894-074.0447",
                "average": 35,
                "distance": 710,
                "image": "data/shop/thumb/a.jpg"
                // ...
            },
            // ...
        ]
    }
}

CouponList

Request

key value
kind CouponList
keyword string

If you give keyword, you can search coupon by name.

Response

{
    "data": {
        "kind": "CouponList",
        "totalItems": 6741,
        "startIndex": 1,
        "itemsPerPage": 10,
        "itemCount": 10,
        "items": [
            {
                "msg": "xxx",
                "price": "现价",
                "imageUrl": "图片",
                "telenum": "电话",
                "pagevalue": "面值",
                "lifetime": "有效期",
                "id": "id"
                // ...
            },
            // ...
        ]
    }
}

GroupBuyList

Request

key value
kind GroupBuyList
keyword string

If you give keyword, you can search groupbuy by name.

Response

{
    "data": {
        "kind": "GroupBuyList",
        "totalItems": 6741,
        "startIndex": 1,
        "itemsPerPage": 10,
        "itemCount": 10,
        "items": [
            {
                "msg": "xxx",
                "nowPrice": "现价",
                "imageUrl": "图片",
                "phone": "电话",
                "oldPrice": "原价",
                "discount": "折扣",
                "savePrice": "节省",
                "id": "id"
                // ...
            },
            // ...
        ]
    }
}

Shop

Request

key value
kind Shop
id numeric

Response

{
    "data": {
        "kind": "shop",
        "name": "xxx",
        "description": "xxx",
        "imageCount": 2,
        "images": [
            "/data/shop/image/a.jpg",
            "/data/shop/image/b.jpg"
        ]
    }
}

Logcat

Request

key value
kind Logcat
text

Response

If code is 200, than ok. If 400, error.

Login

Digest Scheme.

Request

Response

Comment

comment something Request

key value
action comment
kind Shop/...
id
content ...

Comment Something Response

If success, status code will be 200.

get something's Comment Request

key value
action get
kind ShopComment/...
id

Get Something's Comment Response

{
    "data": {
        "kind": "ShopComment",
        "totalItems": 6741,
        "itemCount": 10,
        "items": [
            {
                "content": "xxx",
                "user": "\d",
                "created": "\time"
            },
            // ...
        ]
    }
}

Clone this wiki locally