POST /jobs (发布任务)

POST /jobs (发布任务)

介绍

本 API 让请求者发布一个新的集智任务。这个集智任务将被展示在我们的平台上,有兴趣的工作者即可以接受并完成这个任务。

我们提供三种不同的方式让请求者定制自己的任务:

指定任务类型

在发布任务时,请求者可以选择指定任务类型,让相同任务类型的任务聚集起来,方便工作者做大量类似的任务。当请求者指定任务类型时,本任务的 title, description, reward, keywords, taskDuration, lifetime, maxTasks, 和 autoApprovalDelay 均会继承任务类型设定的内容。除了 maxTasks 之外,均无法更改。

HTTP Request

URL

https://api.crowdsdom.com/v1/jobs

HTTP Method

POST

HTTP Header

Content-Type: application/json
Authorization: YOUR_ACCESS_TOKEN

参数

Body

以下的参数在 http 请求的 Body 中以 JSON 的格式传入。

名称 描述 Type Default Required
title 工作者看到的任务标题。 String None Yes
description 介绍该任务的简短描述。 String None Yes
jobTypeId 任务的任务类型之专属识别号,定义了任务的 title, description, reward, keywords, taskDuration, lifetime, maxTasks, 和 autoApprovalDelay。
当请求者指定了任务类型,以上这些栏位均变为非必填。除了 maxTasks 之外,均无法在本请求中更改。
String None No
questionsType 任务发布的方式,必须符合三种预设的方式之一。
详情请见任务问题表单的数据结构
String None Yes
internalQuestionsForm 内部问题表单 Object None No
externalQuestionsForm 外部问题表单 Object None No
htmlQuestionsForm HTML问题表单 Object None No
reward 工作者完成任务能得到的酬劳,由 amount 与 currencyCode 组成。amount 是指酬劳的金额,currencyCode 则是币种。
范例:若想设定酬劳为¥0.1,则应该在 reward 传入:{“amount” : 0.10, “currencyCode”: “CNY”}
Object None Yes
keywords 让工作者更易搜索到该任务的关键词 (组)。
若有超过一个关键词,用逗号隔开。
String None No
lifetime 任务失效的时间 (秒),失效后任何工作者均无法接受该任务。
最小值: 600(10 分钟),最大值:2592000(30天)
Integer 604800 No
taskDuration 工作者接受指定工作后,必须完成任务的时间 (秒)
最小值:300(5分钟),最大值:86400(1天)
Integer 300 No
maxTasks 能够接受该任务的工作者数量
最小值:1,最大值:10000
Integer 1 No
autoAprrovalDelay 系统自动批准工作结果的时间 (秒)。若在这段时间内请求者没有主动拒绝,则视为该工作被接受
最小值:0 (立即接受),最大值:2592000(30天)
Integer 86400 No

回复

若 http request 成功发布任务(status code: 200),系统将会返回已发布的集智任务(Job),详情请见集智任务的数据结构。若没成功,系统则会返回错误的代码及原因。

示例

以Python requests 直接调用 API 接口为例:

请求

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

import json
import requests

API_URL = "https://api.crowdsdom.com/v1/jobs"

headers = {
"Authorization": "YOUR_ACCESS_TOKEN",
"Content-Type": "application/json"}

job_settings = {
"title":"微博情感分析",
"description":"判断博文中所表达的情绪",
"keywords": ["情感分析","微博"],
"questionsType":"internalQuestionsForm",
"internalQuestionsForm": {
"questions": [{
"id":"sentiment",
"title":"黄山温泉太啃外地人了一张票298而本地人却58太不合理了!",
"isRequired": True,
"answerType": "SelectionAnswer",
"answerSpec": {
"minSelectionCount": 1,
"maxSelectionCount": 1,
"style": "radiobutton",
"optionSpecs": [
{"id":"positive","text":"正面"},
{"id":"negative","text":"负面"},
{"id":"neutral","text":"中性"}
]
}
}]
},
"reward": {"amount": 0.1, "currencyCode": "CNY"}
}

data = json.dumps(job_settings)

response = requests.post(API_URL, headers=headers, data=data)

回复

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
"id": "56023bc793a22d17004b86be",
"status": "assignable",
"taskDuration": 300,
"description": "判断博文中所表达的情绪",
"reviewStatus": "NotReviewed",
"title": "微博情感分析",
"numberOfTasksAvailable": 0,
"questionsType": "internalQuestionsForm",
"numberOfTasksPending": 0,
"numberOfTasksCompleted": 0,
"autoApprovalDelay": 86400,
"maxTasks": 1,
"updatedAt": "2015-09-23T05:42:31.567Z",
"internalQuestionsForm": {
"questions": [
{
"isRequired": true,
"title": "黄山温泉太啃外地人了一张票298而本地人却58太不合理了!",
"answerType": "SelectionAnswer",
"id": "sentiment",
"answerSpec": {
"optionSpecs": [
{
"text": "正面",
"id": "positive"
},
{
"text": "负面",
"id": "negative"
},
{
"text": "中性",
"id": "neutral"
}
],
"style": "radiobutton",
"maxSelectionCount": 1,
"minSelectionCount": 1
}
}
]
},
"keywords": [
"情感分析",
"微博"
],
"lifetime": 600,
"expirationTime": "2015-09-23T05:52:31.565Z",
"reward": {
"amount": 0.1,
"formattedPrice": "0.1元"
},
"createdAt": "2015-09-23T05:42:31.565Z",
"ownerId": "55fffdbc220c681700f5eaca"
}

原文:大专栏  POST /jobs (发布任务)


猜你喜欢

转载自www.cnblogs.com/wangziqiang123/p/11657638.html