开放 API
使用说明
获取授权
全部 API
- Shop
- Metafields
- Customer
- CustomerAddress
- Account
- Product
- ProductVariant
- ProductImage
- Theme
- Asset
- Country
- Province
- City
- District
- ScriptTag
- Order
- Shipment
- ShipmentSupplier
- Payment
- PaymentMethod
- Redirect
- Page
- Webhook
- Blog
- BlogAuthor
- CustomerLevel
- StoreFile
- Promotion
- Coupon
- Post
- AfterSale
Customer
Customer
Customer 是店铺中的顾客对象,可以通过 API 创建、获取顾客。
除了通过开放 API 来创建顾客外,还以通过用户数据接入来创建。
Customer 对象支持 Webhook 和 Metafields 。
Customer 属性
- addresses
Array 类型,地址数组,参考 CustomerAddress。{"addresses": [] }
- created_at
Datetime 类型,创建时间。{ "created_at" : "2014-09-01T00:00:01.987+08:0" }
- birthday
Datetime 类型,创建时间。{ "birthday" : "2014-09-01T00:00:01.987+08:0" }
- id
Number 类型,唯一整型标识。{ "id" : 2 }
- last_in
Datetime 类型,最后一次登录时间。{ "last_in" : "2014-09-01T00:00:01.987+08:0" }
- name
String 类型,昵称,根据{ "name" : "姓名" }
reg_type
的不同,有以下情况:reg_type=social
:社交账号昵称reg_type=email
:邮箱@
前半部分reg_type=mobile
:手机号码reg_type=uname
:用户名
- notify_email
String 类型,接收通知的邮箱。{ "notify_email" : "customer@sample.com" }
- notify_phone
String 类型,接收通知的手机号码。{ "notify_phone" : "13632269632" }
- real_name
String 类型,客户真实姓名。{ "real_name" : "张三" }
- identity_card
String 类型,真实18位身份证号码。{ "identity_card" : "3622**********2933" }
- reg_identity
String 类型,唯一字符串标识,根据{ "reg_identity" : "customer@sample.com" }
reg_type
的不同,有以下情况:reg_type=social
:社交账号IDreg_type=email
:邮箱reg_type=mobile
:手机号码reg_type=uname
:用户名
- reg_type
String 类型,账号类型,包括:{ "reg_type" : "email" }
- social:社交账号注册
- email:邮箱注册
- mobile:手机注册
- uname:用户名注册
- updated_at
Datetime 类型,最近一次修改时间。{ "updated_at": "2015-01-25T22:31:06.155+08:00" }
- customer_level_name
String 类型,账号的会员等级名。{ "customer_level_name" : "普通会员" }
- total_credit
Number 类型,账号的经验值。{ "total_credit" : 400 }
- trade_total_amount
Number 类型,账号的消费总额。{ "trade_total_amount" : 400 }
- trade_total_count
Number 类型,账号的订单数。{ "trade_total_count" : 1}
- reward_point
Number 类型,账号的积分。{ "reward_point" : 1}
- last_year_reward_point
Number 类型,账号前一年的积分。{ "last_year_reward_point" : 1}
- avatar
Hash 类型,账号的头像信息。{ "avatar" : { "id": 6485, "asset_id": "57e542e45096de2e51000002", "file_name": "001.jpg", "epoch": "1474642762", "src": "/image/57e542e45096de2e51000002/001.jpg?1474642762"} }
Customer 相关API
GET /customers
获取店铺中所有 Customer
- limit
- 可选,返回结果条数
默认10,最大50
- page
- 可选,显示的页码
默认1
- since_id
- 可选,返回大于指定ID的结果
- name
- 可选,顾客昵称
- reg_identity
- 可选,顾客唯一标识
- country_code
- 可选,国家编码
- country_name
- 可选,国家名称
- province_code
- 可选,省份编码
- province_name
- 可选,省份名称
- city_code
- 可选,城市编码
- city_name
- 可选,城市名称
- district_code
- 可选,行政区编码
- district_name
- 可选,行政区名称
- 获取店铺中所有 Customer 列表
- GET /customers
{ "customers": [ { "addresses": [ { "city": "市辖区", "city_code": "110100", "completed_address": "中国,北京市,市辖区,西城区,11111111111", "country": "中国", "country_code": "CN", "created_at": "2014-12-07T11:09:07.067+08:00", "detail": "11111111111", "district": "西城区", "district_code": "110102", "email": "", "id": 520, "is_default": false, "mobile": "13632269380", "name": "11", "province": "北京市", "province_code": "110000", "telephone": "", "updated_at": "2014-12-07T11:09:07.067+08:00", "zipcode": null } ], "avatar": null, "created_at": "2014-11-26T00:26:43.896+08:00", "id": 595, "identity_card": "3622**********2933", "last_in": "2014-11-26T00:26:43.896+08:00", "name": "圣经-阿门", "notify_email": "", "notify_phone": "", "real_name": "张三", "reg_identity": "422C8EA0D0FC2755E1001320D82DAAF0", "reg_type": "social", "trade_total_amount": 50000, //单位:分 "trade_total_count": 5, "updated_at": "2015-03-31T22:25:37.362+08:00", "customer_level_name": "普通会员", "total_credit": 400, "trade_total_amount": 400, "trade_total_count": 1, "birthday": null } ] }
- 获取指定 ID 的 Customer
- GET /customers?ids=595,596
{ "customers": [ { "addresses": [ { "city": "市辖区", "city_code": "110100", "completed_address": "中国,北京市,市辖区,西城区,11111111111", "country": "中国", "country_code": "CN", "created_at": "2014-12-07T11:09:07.067+08:00", "detail": "11111111111", "district": "西城区", "district_code": "110102", "email": "", "id": 520, "is_default": false, "mobile": "13632269380", "name": "11", "province": "北京市", "province_code": "110000", "telephone": "", "updated_at": "2014-12-07T11:09:07.067+08:00", "zipcode": null } ], "avatar": null, "created_at": "2014-11-26T00:26:43.896+08:00", "id": 595, "identity_card": "3622**********2933", "last_in": "2014-11-26T00:26:43.896+08:00", "name": "圣经-阿门", "notify_email": "", "notify_phone": "", "real_name": "张三", "reg_identity": "422C8EA0D0FC2755E1001320D82DAAF0", "reg_type": "social", "trade_total_amount": 50000, //单位:分 "trade_total_count": 5, "updated_at": "2015-03-31T22:25:37.362+08:00", "customer_level_name": "普通会员", "reward_point": 10, "last_year_reward_point": 10, "birthday": null }, { "addresses": [], "avatar": null, "created_at": "2014-11-26T00:28:37.573+08:00", "id": 596, "identity_card": "3622**********2933", "last_in": "2014-11-26T00:26:43.896+08:00", "name": "seem", "notify_email": "", "notify_phone": "", "real_name": "张三", "reg_identity": "A703FFB67275BD6AFF5E512775B15447", "reg_type": "social", "trade_total_amount": 50000, //单位:分 "trade_total_count": 5, "updated_at": "2014-11-26T00:28:37.573+08:00", "customer_level_name": "普通会员", "total_credit": 400, "trade_total_amount": 400, "trade_total_count": 1, "reward_point": 10, "last_year_reward_point": 10, "birthday": null } ] }
GET /customers/count
获取店铺中 Customer 总数
- 获取应用创建 Customer 总数
- GET /customers/count
{ "count": 160 }
GET /customers/#{id}
获取指定 ID 的 Customer
- 获取 ID 为 595 的 Customer
- GET /customers/595
{ "customer": { "addresses": [ { "city": "市辖区", "city_code": "110100", "completed_address": "中国,北京市,市辖区,西城区,11111111111", "country": "中国", "country_code": "CN", "created_at": "2014-12-07T11:09:07.067+08:00", "detail": "11111111111", "district": "西城区", "district_code": "110102", "email": "", "id": 520, "is_default": false, "mobile": "13632269380", "name": "11", "province": "北京市", "province_code": "110000", "telephone": "", "updated_at": "2014-12-07T11:09:07.067+08:00", "zipcode": null } ], "avatar": null, "created_at": "2014-11-26T00:26:43.896+08:00", "id": 595, "identity_card": "3622**********2933", "last_in": "2014-11-26T00:26:43.896+08:00", "name": "圣经-阿门", "notify_email": "", "notify_phone": "", "real_name": "张三", "reg_identity": "422C8EA0D0FC2755E1001320D82DAAF0", "reg_type": "social", "trade_total_amount": 50000, //单位:分 "trade_total_count": 5, "updated_at": "2015-03-31T22:25:37.362+08:00", "customer_level_name": "普通会员", "reward_point": 10, "last_year_reward_point": 10, "birthday": null } }
POST /customers
创建新的 Customer
- reg_type
- 账号类型:
1
:邮箱注册2
:手机号码注册3
:用户名注册
- reg_identity
- 账号唯一标识:
reg_type = 1
:邮箱reg_type = 2
:手机号码reg_type = 3
:用户名
- password
- 账号密码,4-40个字符
- notify_email
- 接收通知的邮箱
- notify_phone
- 接收通知的手机号码
- real_name
- 客户真实姓名
- identity_card
- 18位身份证号码
- avatar
- 顾客头像信息:
{"attachment": base64图片类型, "file_name": 文件名}
- 创建 Customer
- POST /customers
{ "customer": { "reg_type":"email", "reg_identity": "for@example.com", "password":"123456", "notify_email":"for@example.com", "notify_phone":"13632269380", "identity_card": "3622**********2933", "real_name": "张三", "birthday": "1990-01-01" } }
{ "customer": { "addresses": [], "avatar": null, "created_at": "2014-11-26T00:26:43.896+08:00", "id": 4009, "identity_card": "3622**********2933", "last_in": "2014-11-26T00:26:43.896+08:00", "name": "wangzilong", "notify_email": "for@example.com", "notify_phone": "", "real_name": "张三", "reg_identity": "for@example.com", "reg_type": "email", "trade_total_amount": 0, //单位:分 "trade_total_count": 0, "updated_at": "2015-04-28T20:20:22.747+08:00", "customer_level_name": "普通会员", "birthday": "1990-01-01T00:00:00.000+08:00", } }
- 缺少
reg_identity
参数,创建 Customer 时会返回错误信息 - POST /customer
{ "customer": { "reg_type":"email", "password":"123456", "notify_email":"for@example.com", "notify_phone":"13632269380", "identity_card": "3622**********2933", "real_name": "张三" } }
{ "code": 422, "errors": { "reg_identity": [ "不可为空" ] } }
- 缺少
PUT /customers/#{id}
修改指定 ID 的 Customer
- notify_email
- 接收通知的邮箱
- notify_phone
- 接收通知的手机号码
- real_name
- 客户真实姓名
- identity_card
- 18位身份证号码
- birthday
- 生日
- 修改
id=4009
对应账号的notify_email
- PUT /customers/4009
{ "customer": { "notify_email":"new@example.com", "notify_phone":"13632269381", "identity_card": "3622**********2933", "real_name": "张三", "birthday": "1990-01-01" } }
{ "customer": { "addresses": [], "avatar": null, "created_at": "2014-11-26T00:26:43.896+08:00", "id": 4009, "identity_card": "3622**********2933", "last_in": "2014-11-26T00:26:43.896+08:00", "name": "wangzilong", "notify_email": "new@example.com", "notify_phone": "13632269381", "real_name": "张三" "reg_identity": "for@example.com", "reg_type": "email", "trade_total_amount": 0, //单位:分 "trade_total_count": 0, "updated_at": "2015-04-28T21:08:14.067+08:00", "customer_level_name": "普通会员", "updated_at": "1990-01-01T00:00:00.000+08:00" } }
- 修改
DELETE /customers/#{id}
删除指定 ID 的 Customer。若指定账号已下单,则无法删除。
- 删除ID为4009的 Customer
- DELETE /customers/4009
{}
PUT /customers/#{id}/adjust_reward_point
修改指定 ID 的 Customer的积分。
- reward_point
- 调整的积分数量
- type
- 调整类型:
plus
: 增加积分minus
: 减少积分
- admin_memo
- 管理员备注
- desc
- 顾客看的经积分说明信息
- 修改ID为4009的 Customer的积分
PUT/customers/4009/adjust_reward_point
{ "reward_point": 10, "type": "plus", "admin_memo": "赠送积分", "desc": "参与晒单活动,赠送积分" }
{}
PUT /customers/#{id}/adjust_credit
修改指定 ID 的 Customer的经验值。
- credit
- 调整的经验值
- type
- 调整类型:
plus
: 增加经验值minus
: 减少经验值
- admin_memo
- 管理员备注
- desc
- 顾客看的经验值说明信息
- 修改ID为4009的 Customer的经验值
PUT/customers/4009/adjust_credit
{ "credit": 10, "type": "plus", "admin_memo": "赠送经验值", "desc": "参与晒单活动,赠送经验值" }
{}