金数据高级API文档 (jinshuju.com)

注意此文档仅限通用型saas平台产品和金数据企业高级版及以上版本使用,且仅支持这两种类型的用户开通

本文档适用于您的金数据账号位于 jinshuju.com,如有疑问请联系客服或者销售

金数据API使用OAuth 2标准进行用户验证。

发送请求

所有的URL需要以https://api.jinshuju.com/v4/开头。仅支持SSL。目前API版本为v4版本。例如,想获得当前用户的基本信息情况:

  1. curl https://api.jinshuju.com/v4/me?access_token=...

OAuth 2验证

v4版本的金数据API支持OAuth 2。你可以使用标准的OAuth交互协议进行访问。相关URL如下:

  • 认证域: https://account.jinshuju.com
  • 接口域: https://api.jinshuju.com/v4

1. 转向到金数据申请验证

1.1 转向到金数据申请企业中用户的验证

  1. GET https://account.jinshuju.com/oauth/authorize

参数

参数名称 类型 备注
client_id string 必须,注册的金数据应用ID,目前仅对金数据商业合作伙伴开放。
redirect_uri string 必须,金数据应用的callback URI,当授权完成之后要转向的地址。
response_type string 必须,OAuth 2中必须将其指定为code
scope string 空格隔开的列表。目前支持的scope包括:public profile forms read_entries form_setting,默认为public。
state string 唯一随机的的字符串,用来防止跨站攻击。

1.2 转向到金数据申请企业的验证

  1. GET https://account.jinshuju.com/org_oauth/authorize

参数

参数名称 类型 备注
client_id string 必须,注册的金数据应用ID,目前仅对金数据商业合作伙伴开放。
redirect_uri string 必须,金数据应用的callback URI,当授权完成之后要转向的地址。
response_type string 必须,OAuth 2中必须将其指定为code
scope string 空格隔开的列表。目前支持的scope包括:public profile forms read_entries form_setting users,默认为public。
state string 唯一随机的的字符串,用来防止跨站攻击。

2. 获得访问的access token

2.1 获取用户访问的access token

用户同意之后,金数据将会转向到你的网站,并带上code和之前提供的state参数。如果state不匹配,你可以终止这个请求。

拿到code之后,就可以交换access token:

  1. POST https://account.jinshuju.com/oauth/token

参数

参数名称 类型 备注
client_id string 必须,注册的金数据应用ID,目前仅对金数据商业合作伙伴开放。
client_secret string 必须,金数据应用的secret。
code string 必须,在1.1中获得的用户code。
redirect_uri string 必须,金数据应用的callback URI,当授权完成之后要转向的地址。
grant_type string 必须,指定为 authorization_code
state string 在第一步使用的唯一随机的的字符串。

默认情况下,返回的response的形式如下:

  1. {
  2. "access_token": "2994eec8c8b19c2a2103ae2a335dc781220bb701d4c2c7d1b4cc7c629353f8a4",
  3. "token_type": "bearer",
  4. "expires_in": 7200,
  5. "refresh_token": "a563ed398b919388bc2e87b29f8d3b6e42a1195cdc1d9e36c6e9bcaa153bc6d3",
  6. "scope": "public forms read_entries",
  7. "created_at": 1455680792
  8. }

2.2 获取企业访问的access token

企业同意之后,金数据将会转向到你的网站,并带上code和之前提供的state参数。如果state不匹配,你可以终止这个请求。

拿到code之后,就可以交换access token:

  1. POST https://account.jinshuju.com/org_oauth/token

参数

参数名称 类型 备注
client_id string 必须,注册的金数据应用ID,目前仅对金数据商业合作伙伴开放。
client_secret string 必须,金数据应用的secret。
code string 必须,在1.2中获得的企业code。
redirect_uri string 必须,金数据应用的callback URI,当授权完成之后要转向的地址。
grant_type string 必须,指定为 authorization_code
state string 在第一步使用的唯一随机的的字符串。

默认情况下,返回的response的形式如下:

  1. {
  2. "access_token": "2994eec8c8b19c2a2103ae2a335dc781220bb701d4c2c7d1b4cc7c629353f8a4",
  3. "token_type": "bearer",
  4. "expires_in": 7200,
  5. "refresh_token": "a563ed398b919388bc2e87b29f8d3b6e42a1195cdc1d9e36c6e9bcaa153bc6d3",
  6. "scope": "public forms read_entries",
  7. "created_at": 1455680792
  8. }

2.3 使用refresh token获得新的access_token

目前access_token有效期为7200秒,当access_token过期时,可以使用refresh_token来获得新的access_token。

刷新用户的access_token:

  1. POST https://account.jinshuju.com/oauth/token

参数

参数名称 类型 备注
client_id string 必须,注册的金数据应用ID,目前仅对金数据商业合作伙伴开放
client_secret string 必须,金数据应用的secret
refresh_token string 必须,在2.1中获取access_token时得到的refresh_token。
grant_type string 必须,指定为 refresh_token

返回的response的形式如下,得到新的access_token 和refresh_token:

  1. {
  2. "access_token": "0909a26c330883cf2cd44f8926c663ac1d639ed2940d879fb2bf4a62e06ff4a8",
  3. "token_type": "bearer",
  4. "expires_in": 7200,
  5. "refresh_token": "648478764ff94d09d62f78c8fad8c2b7886ee93c59090ececacd6dfe1b648949",
  6. "scope": "public forms read_entries",
  7. "created_at": 1455710364
  8. }

刷新企业的access_token:

  1. POST https://account.jinshuju.com/org_oauth/token

参数

参数名称 类型 备注
client_id string 必须,注册的金数据应用ID,目前仅对金数据商业合作伙伴开放
client_secret string 必须,金数据应用的secret
refresh_token string 必须,在2.2中获取access_token时得到的refresh_token。
grant_type string 必须,指定为 refresh_token

返回的response的形式如下,得到新的access_token 和refresh_token:

  1. {
  2. "access_token": "0909a26c330883cf2cd44f8926c663ac1d639ed2940d879fb2bf4a62e06ff4a8",
  3. "token_type": "bearer",
  4. "expires_in": 7200,
  5. "refresh_token": "648478764ff94d09d62f78c8fad8c2b7886ee93c59090ececacd6dfe1b648949",
  6. "scope": "public forms read_entries",
  7. "created_at": 1455710364
  8. }

3. 使用access token访问API

  1. GET https://api.jinshuju.com/v4/forms?access_token=...

你可以把token放在URL中。也可以使用Authorization header如下:

  1. Authorization: bearer OAUTH-TOKEN

例如使用curl

  1. curl -H "Authorization: bearer OAUTH-TOKEN" https://api.jinshuju.com/v4/forms

Redirect URL

redirect_uri是必须的。如果你使用omniauth-jinshuju,就可以使用类似于https://domain.com/auth/jinshuju/callback的地址。

Scopes

Scope定义了资源范围。目前支持六个:publicprofileformsread_entriesform_settingusers

  • public, 获取用户的头像、昵称、邮箱、是否为付费用户等信息(邮箱、是否付费将会在后面的版本中移除,如需要,请使用profile scope
  • profile, 获取用户的账户信息,邮箱、是否为付费用户(只读)、自定义域名(只读)
  • forms, 获取用户所有表单信息、单个表单详情、表单当前状态(是否开启,填写权限,已收集数据量)
  • read_entries, 获取某表单下的数据信息,批量获取或单条获取,并且可基于查询条件获取想要的数据
  • form_setting, 获取、更新表单的设置
  • users, 获取企业中的用户列表

访问限制

访问API是基于金数据授权的用户来做频率限制的,目前企业基础版每个企业20,000次/小时,协作版每个企业30,000次/小时,高级版每个企业50,000次/小时,商业合作版每个企业50,000次/小时,如需更多可联系金数据扩充。

HTTP Header中会留下相应的信息。

  1. X-RateLimit-Limit:120
  2. X-RateLimit-Remaining:119

分页

当请求返回多个条目时,如表单列表、数据列表时,默认每次(per_page)返回20个条目,可以设定per_page参数来单次获得更多的数据,但目前最多支持50条。

例如:

  1. GET https://api.jinshuju.com/v4/forms?access_token=...&per_page=50

在每一次请求返回的header里会包含分页信息,如下表所示:

Header Name Description
X-Total 符合条件的总数,例如X-Total:50
X-Count 当前请求返回的数量,例如X-Count:20
Link 包含上一页(prev)或下一页(next)的访问地址,rel目前仅支持next和prev。

例如获取表单列表时,request header里会返回如下:

  1. Link:<https://api.jinshuju.com/v4/forms?access_token=...&per_page=20&cursor=xxxxx>; rel="prev",
  2. <https://api.jinshuju.com/v4/forms?access_token=...&per_page=20&cursor=xxxxx>; rel="next"

在发出第一次查询请求后,不断的检查返回的Link Header里的next列表,如果存在则直接使用链接去获取,不存在则代表批量获取完成。

链接中的cursor是查询的游标,在访问不同的api时,含义不同。查询表单列表时,代表下一次要取的表单的id;查询数据列表时,代表下一次要取的数据的序号,数据序号是一个递增的整数,由于存在数据删除的情况,所以可能是不连贯的,不建议采用分页数值和序号来拼cursor值。

获取企业中用户列表

需要Scope: users

  1. get https://api.jinshuju.com/v4/users

参数

参数名称 类型 备注
access_token string 必须,必须使用2.2中的企业access token。
provider string 可选,企业的subdomain。
uid string 可选,使用SDK静默注册的用户在用户的profile中记录的uid。

Json Load:

  1. {
  2. "openid": "033ae0b9-ed61-5587-900a-5c95961914ee",
  3. "name": "User_liudalu0002",
  4. "email": "liudalu0002@fake.xitian.com",
  5. "mobile": null,
  6. "role": "teamworker",
  7. "status": "active",
  8. "avatar": null,
  9. "forms_count": 2,
  10. "entries_count": 0,
  11. "authentications": [
  12. {
  13. "provider": "xitian",
  14. "uid": "liudalu0002"
  15. },

获取当前用户信息

需要Scope: public

  1. get https://api.jinshuju.com/v4/me

参数

参数名称 类型 备注
access_token string 必须,可使用2.1中的个人access token;或2.2中的企业access token。
openid string 可选,金数据中用户的唯一标识。如使用2.1中的个人access token,无需携带;如使用2.2中的企业access token,必须携带。

Json Load:

  1. {
  2. "openid": "5af4563b-4146-58a9-a2c0-9c41c488333b",
  3. "name": "张三",
  4. "email": "zhangsan@jinshuju.com",
  5. "mobile": "18000000001",
  6. "role": "admin",
  7. "status": "active",
  8. "avatar": null,
  9. "forms_count": 45,
  10. "entries_count": 21396
  11. },

获取当前企业信息

需要Scope: profile

  1. get https://api.jinshuju.com/v4/profile

参数

参数名称 类型 备注
access_token string 必须,可使用2.1中的个人access token;或2.2中的企业access token。

Json Load:

  1. {
  2. "email": "creator@jinshuju.com",
  3. "organization_name": "金数据",
  4. "organization_subdomain": "jinshuju",
  5. "paid": true,
  6. "custom_domain": "http://com-uat.tunnel.mobi"
  7. }

注册用户

需要Scope: users

  1. post https://api.jinshuju.com/v4/users

参数

参数名称 类型 备注
access_token string 必须,必须使用2.2中的企业access token。
uid string 可选,使用SDK静默注册的用户在用户的profile中记录的uid。

Json Load:

  1. {
  2. "openid": "033ae0b9-ed61-5587-900a-5c95961914ee",
  3. "name": "User_liudalu0002",
  4. "email": "liudalu0002@fake.xitian.com",
  5. "mobile": null,
  6. "role": "teamworker",
  7. "status": "active",
  8. "avatar": null,
  9. "forms_count": 2,
  10. "entries_count": 0,
  11. "authentications": [
  12. {
  13. "provider": "xitian",
  14. "uid": "liudalu0002"
  15. },

获取表单列表

需要Scope: forms

  1. GET https://api.jinshuju.com/v4/forms

参数

参数名称 类型 备注
access_token string 必须,可使用2.1中的个人access token,可获取企业成员的的所有表单;或2.2中的企业access token,可获取企业中的所有表单。
openid string 可选,通过企业的access_token获取用户表单列表时必须填写,通过用户access_token获取用户列表时无需填写。
source string 可选,created可获取所有当前用户是表单创建者的表单列表;managed可获取所有当前用户是表单创建者和表单管理员的表单列表。
  1. [
  2. {
  3. "id": "56c28b33c02f6713aa000092",
  4. "token": "E2FBnj",
  5. "name": "市场调查表",
  6. "entries_count": 0,
  7. "shared": false,
  8. "description": "这是一个市场调查表",
  9. "created_at": "2016-02-16T02:36:35.756Z",
  10. "updated_at": "2016-02-16T02:37:35.756Z",
  11. "setting": {
  12. "icon": "fontello-paper-plane",
  13. "color": "#659199",
  14. "open_rule": "open",
  15. "permission": "public",
  16. "result_state": "closed",
  17. "result_url": null,
  18. "search_state": "closed",
  19. "search_url": null,
  20. "push_url": null
  21. }
  22. },
  23. {
  24. "id": "56b2f86ca3f5206d76000143",
  25. "token": "TivBsE",
  26. "name": "小金俱乐部活动报名",
  27. "entries_count": 0,
  28. "shared": false,
  29. "description": "2016年小金俱乐部第一站来到了上海",
  30. "created_at": "2016-02-04T07:06:20.559Z",
  31. "created_at": "2016-02-04T07:09:20.559Z",
  32. "setting": {
  33. "icon": "fontello-pencil",
  34. "color": "#659199",
  35. "open_rule": "open",
  36. "permission": "public",
  37. "result_state": "closed",
  38. "result_url": null,
  39. "search_state": "closed",
  40. "search_url": null,
  41. "push_url": null
  42. }
  43. }
  44. ]

获取表单详情

需要Scope: forms

  1. GET https://api.jinshuju.com/v4/forms/RygpW3?access_token=...
  1. {
  2. "id": "58d0821a2084c548c9c76938",
  3. "token": "iIAVew",
  4. "name": "包含所有字段的表单",
  5. "entries_count": 3,
  6. "shared": false,
  7. "description": null,
  8. "creator_name": "增长天王",
  9. "creator_openid": "5af4563b-4146-58a9-a2c0-9c41c488333b",
  10. "created_at": "2017-03-21T01:30:02.618Z",
  11. "updated_at": "2017-03-22T10:22:41.050Z",
  12. "fields": [
  13. {
  14. "type": "page_break",
  15. "label": null,
  16. "api_code": "field_1",
  17. "notes": ""
  18. },
  19. {
  20. "type": "formula",
  21. "label": "计算字段",
  22. "api_code": "field_29",
  23. "notes": "",
  24. "validations": {},
  25. "private": false,
  26. "formula": "field_10",
  27. "display_as_percentage": false
  28. },
  29. {
  30. "type": "single_line_text",
  31. "label": "单行文字",
  32. "api_code": "field_2",
  33. "notes": "",
  34. "validations": {},
  35. "predefined_value": null,
  36. "private": false
  37. },
  38. {
  39. "type": "paragraph_text",
  40. "label": "多行文字",
  41. "api_code": "field_3",
  42. "notes": "",
  43. "validations": {},
  44. "predefined_value": null,
  45. "private": false
  46. },
  47. {
  48. "type": "single_choice",
  49. "label": "单项选择",
  50. "api_code": "field_4",
  51. "notes": "",
  52. "validations": {},
  53. "private": false,
  54. "choices": [
  55. {
  56. "name": "选项",
  57. "value": "EtdU",
  58. "hidden": false
  59. },
  60. {
  61. "name": "选项",
  62. "value": "Z47n",
  63. "hidden": false
  64. },
  65. {
  66. "name": "选项",
  67. "value": "eldU",
  68. "hidden": false
  69. }
  70. ],
  71. "allow_other": false
  72. },
  73. {
  74. "type": "multiple_choice",
  75. "label": "多项选择",
  76. "api_code": "field_5",
  77. "notes": "",
  78. "validations": {},
  79. "private": false,
  80. "choices": [
  81. {
  82. "name": "选项",
  83. "value": "9WG4",
  84. "hidden": false
  85. },
  86. {
  87. "name": "选项",
  88. "value": "86rJ",
  89. "hidden": false
  90. },
  91. {
  92. "name": "选项",
  93. "value": "L4NO",
  94. "hidden": false
  95. }
  96. ],
  97. "allow_other": false
  98. },
  99. {
  100. "type": "single_choice",
  101. "label": "图片单选",
  102. "api_code": "field_6",
  103. "notes": "",
  104. "validations": {},
  105. "private": false,
  106. "choices": [
  107. {
  108. "name": "1-Cfl_B1ALQS7VQGj_iSiyPA",
  109. "value": "hd0C",
  110. "hidden": false,
  111. "image_url": "https://dn-jintest.qbox.me/ic/20161026140743_599030@iclarge"
  112. },
  113. {
  114. "name": "1-BJ1Jami58oxr5artYGaqDw",
  115. "value": "RWcw",
  116. "hidden": false,
  117. "image_url": "https://dn-jintest.qbox.me/ic/20161026140743_d3cd8d@iclarge"
  118. },
  119. {
  120. "name": "1-CbGEoJYT-DVnXx0_w-iEeg",
  121. "value": "25gu",
  122. "hidden": false,
  123. "image_url": "https://dn-jintest.qbox.me/ic/20161026140743_9f23fe@iclarge"
  124. }
  125. ]
  126. },
  127. {
  128. "type": "multiple_choice",
  129. "label": "图片多选",
  130. "api_code": "field_7",
  131. "notes": "",
  132. "validations": {},
  133. "private": false,
  134. "choices": [
  135. {
  136. "name": "1-DjFewMYwOJTfcAoDr8wgug",
  137. "value": "gb8K",
  138. "hidden": false,
  139. "image_url": "https://dn-jintest.qbox.me/ic/20161026140753_f10da1@iclarge"
  140. },
  141. {
  142. "name": "1-EcIXQpX2CoV36BiD8fPq9w",
  143. "value": "4cF4",
  144. "hidden": false,
  145. "image_url": "https://dn-jintest.qbox.me/ic/20161026140753_38905f@iclarge"
  146. },
  147. {
  148. "name": "1-G6gfugR9At7OlSj6YxIOKw",
  149. "value": "RP8o",
  150. "hidden": false,
  151. "image_url": "https://dn-jintest.qbox.me/ic/20161026140753_f7e716@iclarge"
  152. }
  153. ]
  154. },
  155. {
  156. "type": "likert",
  157. "label": "矩阵单选",
  158. "api_code": "field_8",
  159. "notes": "",
  160. "validations": {},
  161. "private": false,
  162. "choices": [
  163. {
  164. "name": "选项",
  165. "value": "OrdJ"
  166. },
  167. {
  168. "name": "选项",
  169. "value": "lIP4"
  170. },
  171. {
  172. "name": "选项",
  173. "value": "MSwM"
  174. }
  175. ],
  176. "statements": [
  177. {
  178. "name": "题目",
  179. "value": "vAfq"
  180. },
  181. {
  182. "name": "题目",
  183. "value": "owYy"
  184. },
  185. {
  186. "name": "题目",
  187. "value": "dl9C"
  188. }
  189. ]
  190. },
  191. {
  192. "type": "matrix",
  193. "label": "矩阵填空",
  194. "api_code": "field_9",
  195. "notes": "",
  196. "validations": {},
  197. "private": false,
  198. "statements": [
  199. {
  200. "name": "题目",
  201. "value": "lNIw"
  202. },
  203. {
  204. "name": "题目",
  205. "value": "KvbO"
  206. },
  207. {
  208. "name": "题目",
  209. "value": "dZIP"
  210. }
  211. ],
  212. "dimensions": [
  213. {
  214. "name": "项目",
  215. "value": "vWra"
  216. },
  217. {
  218. "name": "项目",
  219. "value": "SKOh"
  220. },
  221. {
  222. "name": "项目",
  223. "value": "1A1g"
  224. }
  225. ]
  226. },
  227. {
  228. "type": "number",
  229. "label": "数字",
  230. "api_code": "field_10",
  231. "notes": "",
  232. "validations": {},
  233. "predefined_value": null,
  234. "private": false,
  235. "display_as_percentage": false
  236. },
  237. {
  238. "type": "time",
  239. "label": "时间",
  240. "api_code": "field_11",
  241. "notes": "",
  242. "validations": {},
  243. "predefined_value": {},
  244. "private": false
  245. },
  246. {
  247. "type": "date",
  248. "label": "日期",
  249. "api_code": "field_12",
  250. "notes": "",
  251. "validations": {},
  252. "predefined_value": null,
  253. "private": false
  254. },
  255. {
  256. "type": "drop_down",
  257. "label": "下拉框",
  258. "api_code": "field_13",
  259. "notes": "",
  260. "validations": {},
  261. "private": false,
  262. "choices": [
  263. {
  264. "name": "选项",
  265. "value": "DdPZ",
  266. "hidden": false
  267. },
  268. {
  269. "name": "选项",
  270. "value": "WHHp",
  271. "hidden": false
  272. },
  273. {
  274. "name": "选项",
  275. "value": "nQs8",
  276. "hidden": false
  277. }
  278. ],
  279. "allow_other": false
  280. },
  281. {
  282. "type": "section_break",
  283. "label": "描述",
  284. "api_code": "field_14",
  285. "notes": "请在右侧面板添加段落说明信息"
  286. },
  287. {
  288. "type": "page_break",
  289. "label": null,
  290. "api_code": "field_15",
  291. "notes": ""
  292. },
  293. {
  294. "type": "link",
  295. "label": "网址",
  296. "api_code": "field_16",
  297. "notes": "填写示例:http://jinshuju.com 或 https://jinshuju.com",
  298. "validations": {},
  299. "predefined_value": null,
  300. "private": false
  301. },
  302. {
  303. "type": "rating",
  304. "label": "评分",
  305. "api_code": "field_17",
  306. "notes": "",
  307. "validations": {},
  308. "private": false,
  309. "rating_type": "star",
  310. "rating_max": 3
  311. },
  312. {
  313. "type": "cascade_drop_down",
  314. "label": "二级下拉框",
  315. "api_code": "field_18",
  316. "notes": "",
  317. "validations": {},
  318. "private": false,
  319. "choices": [
  320. {
  321. "name": "选项1",
  322. "value": "0TX9",
  323. "sub_choices": [
  324. {
  325. "name": "二级选项1",
  326. "value": "ecv0"
  327. },
  328. {
  329. "name": "二级选项2",
  330. "value": "SUKk"
  331. }
  332. ]
  333. },
  334. {
  335. "name": "选项2",
  336. "value": "dwpt",
  337. "sub_choices": [
  338. {
  339. "name": "二级选项1",
  340. "value": "R15F"
  341. },
  342. {
  343. "name": "二级选项2",
  344. "value": "k346"
  345. }
  346. ]
  347. }
  348. ]
  349. },
  350. {
  351. "type": "attachment",
  352. "label": "附件",
  353. "api_code": "field_19",
  354. "notes": "",
  355. "validations": {},
  356. "private": false,
  357. "max_file_quantity": 1,
  358. "media_type": {
  359. "type": "unlimited",
  360. "value": null
  361. }
  362. },
  363. {
  364. "type": "form_association",
  365. "label": "表单关联",
  366. "api_code": "field_20",
  367. "notes": "",
  368. "validations": {},
  369. "private": false,
  370. "associated_form_token": "ntZv4v",
  371. "associated_field_api_code": "serial_number"
  372. },
  373. {
  374. "type": "single_line_text",
  375. "label": "姓名",
  376. "api_code": "field_21",
  377. "notes": "",
  378. "validations": {},
  379. "predefined_value": null,
  380. "private": false
  381. },
  382. {
  383. "type": "mobile",
  384. "label": "手机",
  385. "api_code": "field_22",
  386. "notes": "",
  387. "validations": {},
  388. "predefined_value": null,
  389. "private": false
  390. },
  391. {
  392. "type": "email",
  393. "label": "邮箱",
  394. "api_code": "field_23",
  395. "notes": "",
  396. "validations": {},
  397. "private": false
  398. },
  399. {
  400. "type": "address",
  401. "label": "地址",
  402. "api_code": "field_24",
  403. "notes": "",
  404. "validations": {},
  405. "predefined_value": {},
  406. "private": false
  407. },
  408. {
  409. "type": "geo",
  410. "label": "地理位置",
  411. "api_code": "field_25",
  412. "notes": "",
  413. "validations": {},
  414. "private": false
  415. },
  416. {
  417. "type": "phone",
  418. "label": "电话",
  419. "api_code": "field_26",
  420. "notes": "",
  421. "validations": {},
  422. "predefined_value": null,
  423. "private": false
  424. },
  425. {
  426. "type": "goods",
  427. "label": "配图商品",
  428. "api_code": "field_27",
  429. "notes": "",
  430. "validations": {},
  431. "private": false,
  432. "with_image": true,
  433. "goods_items": [
  434. {
  435. "name": "1-EcIXQpX2CoV36BiD8fPq9w",
  436. "price": 0,
  437. "description": "",
  438. "api_code": "k6Bw",
  439. "inventory": null,
  440. "hidden": false,
  441. "predefined_value": {
  442. "number": null
  443. }
  444. },
  445. {
  446. "name": "1-G6gfugR9At7OlSj6YxIOKw",
  447. "price": 0,
  448. "description": "",
  449. "api_code": "mfXz",
  450. "inventory": null,
  451. "hidden": false,
  452. "predefined_value": {
  453. "number": null
  454. }
  455. },
  456. {
  457. "name": "1-DjFewMYwOJTfcAoDr8wgug",
  458. "price": 0,
  459. "description": "",
  460. "api_code": "7QWj",
  461. "inventory": null,
  462. "hidden": false,
  463. "predefined_value": {
  464. "number": null
  465. }
  466. }
  467. ]
  468. },
  469. {
  470. "type": "goods",
  471. "label": "无图商品",
  472. "api_code": "field_28",
  473. "notes": "",
  474. "validations": {},
  475. "private": false,
  476. "with_image": false,
  477. "goods_items": [
  478. {
  479. "name": "商品一",
  480. "price": 0,
  481. "description": "",
  482. "api_code": "jQaM",
  483. "inventory": null,
  484. "hidden": false,
  485. "predefined_value": {
  486. "number": null
  487. }
  488. },
  489. {
  490. "name": "商品二",
  491. "price": 0,
  492. "description": "",
  493. "api_code": "Ba3h",
  494. "inventory": null,
  495. "hidden": false,
  496. "predefined_value": {
  497. "number": null
  498. }
  499. },
  500. {
  501. "name": "商品三",
  502. "price": 0,
  503. "description": "",
  504. "api_code": "cpLm",
  505. "inventory": null,
  506. "hidden": false,
  507. "predefined_value": {
  508. "number": null
  509. }
  510. }
  511. ]
  512. }
  513. ],
  514. "setting": {
  515. "icon": "form-icon-photo",
  516. "color": "#46B372",
  517. "open_rule": "open",
  518. "permission": "public",
  519. "gen_code_enabled": false,
  520. "result_state": "closed",
  521. "result_url": null,
  522. "search_state": "closed",
  523. "search_url": null,
  524. "push_url": null,
  525. "success_redirect_url": "https://www.XXX.com",
  526. "success_redirect_fields": [
  527. "serial_number"
  528. ]
  529. }
  530. }

复制表单

注意:示例中的<2d4iH0>为被复制的表单token

  1. POST https://api.jinshuju.com/v4/forms/2d4iH0/copy

复制表单

参数

参数名称 类型 备注
access_token string 必须,可使用2.1中的个人access token,或2.2中的企业access token。
openid string 可选,获取的用户列表中的openid。使用个人的acces token无需填写;使用企业的access token必须填写。
name string 可选,复制出来的表单命名。如果不提供或者为空字符串,将使用“[新]”+原表单名作为复制后的表单的名字。

默认情况下,返回的response的形式如下:

  1. {
  2. "id": "58512d8159601539b83e75fa",
  3. "token": "AyEpBI",
  4. "name": "[新]学习小组第一期话题投票",
  5. "entries_count": 0,
  6. "shared": false,
  7. "description": "这是一个大家都可以加入或旁听的学习小组,",
  8. "created_at": "2016-12-14T11:31:14.255Z",
  9. "updated_at": "2016-12-14T11:31:15.325Z",
  10. "fields": [
  11. {
  12. "type": "single_line_text",
  13. "label": "你的大名",
  14. "api_code": "field_1",
  15. "notes": "",
  16. "validations": {},
  17. "predefined_value": null,
  18. "private": false
  19. },
  20. {
  21. "type": "multiple_choice",
  22. "label": "请选择你喜欢的话题",
  23. "api_code": "field_2",
  24. "notes": "",
  25. "validations": {},
  26. "private": false,
  27. "choices": [
  28. {
  29. "name": "如何理解产品经理这个角色",
  30. "value": "gRpI",
  31. "hidden": false
  32. },
  33. {
  34. "name": "如何提高碎片化阅读的效率",
  35. "value": "gmIV",
  36. "hidden": false
  37. },
  38. {
  39. "name": "利用Excel进行数据分析的技巧",
  40. "value": "qTXj",
  41. "hidden": false
  42. },
  43. {
  44. "name": "如何快速阅读一本书",
  45. "value": "OASQ",
  46. "hidden": false
  47. },
  48. {
  49. "name": "QA进阶。相信我,你们都不需要入门",
  50. "value": "H2YM",
  51. "hidden": false
  52. },
  53. {
  54. "name": "《无价》读书心得分享",
  55. "value": "Ud2N",
  56. "hidden": false
  57. },
  58. {
  59. "name": "设计中关于字体的二三事",
  60. "value": "V2nl",
  61. "hidden": false
  62. },
  63. {
  64. "name": "金数据产品运行的基本原理。",
  65. "value": "BxvN",
  66. "hidden": false
  67. },
  68. {
  69. "name": "金数据设计的基本原则和思考",
  70. "value": "rQAm",
  71. "hidden": false
  72. }
  73. ],
  74. "allow_other": false
  75. }
  76. ],
  77. "setting": {
  78. "icon": "form-icon-chart",
  79. "color": "#BB87AF",
  80. "open_rule": "open",
  81. "permission": "public",
  82. "result_state": "closed",
  83. "result_url": null,
  84. "search_state": "closed",
  85. "search_url": null,
  86. "push_url": null,
  87. "success_redirect_url": null,
  88. "success_redirect_fields": []
  89. }
  90. }

获取表单当前状态

需要Scope: forms

  1. GET https://api.jinshuju.com/v4/forms/RygpW3/status?access_token=...
  1. {
  2. "is_open": true,
  3. "permission": "public",
  4. "entries_count": 60
  5. }

获取多条数据

需要Scope: read_entries

  1. GET https://api.jinshuju.com/v4/forms/RygpW3/entries?access_token=...
  1. [
  2. {
  3. "serial_number": 1,
  4. "field_1": "小金",
  5. "field_16": "金数据",
  6. "field_2": "2jYk",
  7. "field_4": {
  8. "value": "18629058968",
  9. "verified": true
  10. },
  11. "field_3": [
  12. "zI63",
  13. "uN9L"
  14. ],
  15. "field_17": "roody@jinshuju.com",
  16. "field_5": [
  17. "7oLf",
  18. "vQki"
  19. ],
  20. "field_10": "1lq3",
  21. "field_11": "小金的应用场景",
  22. "field_12": "金数据在各行各业的用法",
  23. "field_6": "金数据有没有一些更加高级的技巧呢?",
  24. "field_7": "",
  25. "field_8": "1. 能否参加\n2. 哪个公司?\n3. 金数据的使用情况",
  26. "field_15": "",
  27. "field_18": "",
  28. "creator_name": "o王琰o",
  29. "updater_name": "",
  30. "created_at": "2016-02-17T11:40:31.524Z",
  31. "updated_at": "2016-02-17T11:40:31.524Z",
  32. "info_remote_ip": "123.139.21.4",
  33. "info_platform": "Macintosh",
  34. "info_os": "OS X 10.11.3",
  35. "info_browser": "Chrome 48.0.2564.109"
  36. }
  37. ]

数据查询

查询数据,支持与现有数据列表查询类似的接口

  • 文本、单选、多选、下拉框、评分、商品、序号(serial_number)、扩展属性(x_field_1) http://api.jinshuju.com/v4/forms/aJSON8/entries?access_token=<token>&field_1=xxx 注:获取表单结构中暂无商品字段的item信息 注:全匹配查询,不支持模糊查询

  • 同一字段的多个条件取并集查询 http://api.jinshuju.com/v4/forms/aJSON8/entries?access_token=<token>&field_1[]=xxx&field_1[]=yyy

  • 多个字段取交集查询 http://api.jinshuju.com/v4/forms/aJSON8/entries?access_token=<token>&field_1=xxx&field_2=yyy

  • 矩阵单选查询 http://api.jinshuju.com/v4/forms/aJSON8/entries?access_token=<token>&field_1[<题目code>][]=<选项code>

  • 二级下拉框查询 http://api.jinshuju.com/v4/forms/aJSON8/entries?access_token=<token>&field_1[<一级选项code>]=<二级选项code>

  • 微信省市查询 http://api.jinshuju.com/v4/forms/aJSON8/entries?access_token=<token>&x_field_weixin_province_city[陕西]=西安

  • 数据提交时间查询 指定日期:http://api.jinshuju.com/v4/forms/aJSON8/entries?access_token=<token>&created_at=2016-1-22 某一日期之后:http://api.jinshuju.com/v4/forms/aJSON8/entries?access_token=<token>&created_at[start]=2016-1-22 某一日期之前:http://api.jinshuju.com/v4/forms/aJSON8/entries?access_token=<token>&created_at[end]=2016-1-22 某个日期区间:http://api.jinshuju.com/v4/forms/aJSON8/entries?access_token=<token>&created_at[start]=2015-12-15&created_at[end]=2016-1-22

获取单条数据

需要Scope: read_entries

  1. GET https://api.jinshuju.com/v4/forms/RygpW3/entries/<序列号>?access_token=...

JSON Load:

  1. {
  2. "serial_number": 1,
  3. "field_1": "小金",
  4. "field_16": "金数据",
  5. "field_2": "2jYk",
  6. "field_4": {
  7. "value": "18629058968",
  8. "verified": true
  9. },
  10. "field_3": [
  11. "zI63",
  12. "uN9L"
  13. ],
  14. "field_17": "roody@jinshuju.com",
  15. "field_5": [
  16. "7oLf",
  17. "vQki"
  18. ],
  19. "field_10": "1lq3",
  20. "field_11": "小金的应用场景",
  21. "field_12": "金数据在各行各业的用法",
  22. "field_6": "金数据有没有一些更加高级的技巧呢?",
  23. "field_7": "",
  24. "field_8": "1. 能否参加\n2. 哪个公司?\n3. 金数据的使用情况",
  25. "field_15": "",
  26. "field_18": "",
  27. "creator_name": "o王琰o",
  28. "updater_name": "",
  29. "created_at": "2016-02-17T11:40:31.524Z",
  30. "updated_at": "2016-02-17T11:40:31.524Z",
  31. "info_remote_ip": "123.139.21.4",
  32. "info_platform": "Macintosh",
  33. "info_os": "OS X 10.11.3",
  34. "info_browser": "Chrome 48.0.2564.109"
  35. }

获取、更新表单设置

需要Scope: form_setting

获取表单设置

  1. get https://api.jinshuju.com/v4/forms/RygpW3/setting?access_token=...

Json Load:

  1. {
  2. "icon": "fontello-sound",
  3. "color": "#afa373",
  4. "open_rule": "open",
  5. "permission": "public",
  6. "result_state": "closed",
  7. "result_url": null,
  8. "search_state": "closed",
  9. "search_url": null,
  10. "push_url": null,
  11. "success_redirect_url": "https://baidu.com",
  12. "success_redirect_fields": [
  13. "field_2",
  14. "field_1"
  15. ]
  16. }

更新表单设置

  1. put https://api.jinshuju.com/v4/forms/RygpW3/setting
参数名称 类型 备注
access_token string 必须,可使用2.1中的个人access token,或2.2中的企业access token。
success_redirect_url string 提交成功后的跳转网址
success_redirect_fields string 提交成功后的跳转网址附加字段参数,以及提交给该字段的信息,最多三个参数,多个参数以空格分隔,如”serial_number x_field_1”,超过三个参数会回应报错信息。参数必须为表单里字段,会自动过滤非表单字段,目前支持:序号、单/多行文本、单选、多选、数字、邮箱、电话、日期以及网址等字段。如果表单中包含商品字段,则还可以附带序号和总价。可参考 https://help.jinshuju.net/articles/redirect-with-params.html
push_url string 数据以JSON格式推送的网址,使用请参考https://help.jinshuju.net/articles/http-push

为表单添加协作成员

需要Scope: forms

  1. POST https://api.jinshuju.com/v4/forms/RygpW3/cooperators?access_token=...
参数名称 类型 备注
access_token string 必须,可使用2.1中的个人access token,或2.2中的企业access token。
openid string 必须,获取的用户列表中的openid。这里需填写加为协作成员的用户openid。
role string 必须,指定的角色,仅支持 manager, data_maintainer, data_viewer。

为表单变更协作成员角色

需要Scope: forms

  1. PUT https://api.jinshuju.com/v4/forms/RygpW3/cooperators/<openid>?access_token=...
参数名称 类型 备注
access_token string 必须,可使用2.1中的个人access token,或2.2中的企业access token。
role string 必须,指定的角色,仅支持 manager, data_maintainer, data_viewer。

为表单移除协作成员

需要Scope: forms

  1. DELETE https://api.jinshuju.com/v4/forms/RygpW3/cooperators/<openid>?access_token=...
参数名称 类型 备注
access_token string 必须,可使用2.1中的个人access token,或2.2中的企业access token。

删除表单

需要Scope: forms

  1. DELETE https://api.uat.jinshuju.com/v4/forms/YYtYiX?access_token=...
参数名称 类型 备注
access_token string 必须,可使用2.1中的个人access token,或2.2中的企业access token。