-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapiary.apib
More file actions
609 lines (392 loc) · 13.7 KB
/
apiary.apib
File metadata and controls
609 lines (392 loc) · 13.7 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
FORMAT: 1A
# CrowdComputer (CroCo) API
This is the ***Crowdcomputer API***. This API provides and easy way to crowdsourcer your application.
Building the future of Crowdsourcing API: crowdsourcing as a service
[Crowdcomputer](www.crowdcomputer.org) is created at the University of Trento, Italy by [Stefano](www.stefanotranquillini.me) and [Pavel](www.kucherbaev.com).
#Authorization
The api are protected by a *token* authentication. The platform accept two types of tokens that are meant to be used in two scnearios. The *single-requester-app* that should be used when the requester is the same person as the owner of the app, and *multiple-requesters-app* that is for applications that post tasks on behalf of other requesters.
##Single-requester-app
The token identifies the *application*.
Example:
```
e4f4fb816c42b3ff34cc8eb46654a75478fb74c9
```
When a task is created with this token the requester becomes the owner of the application.
There's no need to ask users to login (except for workers, they must be logged in in the platform)
##Multiple-requesters-app
In this case the app can post task on behalf or other users. Users (requesters) have to be logged in in the system (see the rest of this paragraph for clarification).
The token identifies the *user* and the *application*. It is composed of two parts, seprated by a `/`
- apptoken
- usertoken
```
e4f4fb816c42b3ff34cc8eb46654a75478fb74c9/38ce17d422f52a3e3eb88a71c5a547a3e156973c
```
###App token, requester login and authorization
To be able to use the API you have to create an application (*URL NOT AVAILABLE YET*), which will automatically create an application token for you.
The application token identifies your app, thus all the request made with that token will identifiy your application, for example: the list of task of a user is only the list of tasks of that user created with that application.
The user token is given back to you app when a user logs in. To login a user, call this webpage (`../login?callback=<your callback url>`). Once the user logs in the page will redirect to the `callback` page you specified when u created your application.
*Be sure that the `callback` that you specified when you created the app, and the one that you use as parameter of `/login` are the same.*
NB: The user has to grant access to the app before the app can act on his behalf. This will be managed by our login pages.
User token will be appended to the url.
Example:
- `../login?callback=http://test.com`
- users logs in
- app is granted by the user
- systems redirect to `http://test.com?token=38ce17d422f52a3e3eb88a71c5a547a3e156973c`
*this is used to log in the requesters*
#API List
#Group Task
## Task [/task/]
### Retrive the list of task [GET]
This method returns the list of tasks that are created by that specific application
+ Request (text/plain)
+ Headers
Authorization: Token X/Y
+ Body
{}
+ Response 201 (application/json)
+ Body
[
{
"owner": "stefano",
"id": 1,
"title": "Task 1",
"description": "Desc Task 1",
"date_created": "2014-05-01T14:34:21.701",
"date_deadline": "2014-05-05T12:00:00Z",
"status": "ST",
"uuid": "52ed354a896a4ca38edd3946d58d7b06",
"page_url": "http://www.crowdcomputer.com/testpage.html",
"reward" : 1.0
},
{
"owner": "stefano",
"id": 3,
"title": "Task 2",
"description": "task 2",
"date_created": "2014-05-01T20:08:40.446",
"date_deadline": "2014-05-05T12:00:00Z",
"status": "ST",
"uuid": "df78d71867de49029163aca10bf534de",
"page_url": "http://www.crowdcomputer.com/testpage.html",
"reward" : 1.0
}
]
### Create a task [POST]
This creates a task. ***Page URL*** must be an external webpage prepared following the instructions (NOT YET ONLINE). ***reward*** has to be specified in EUR.
+ Request JSON message
+ Headers
Authorization:Token X/Y
+ Body
{
"title" : "Task title",
"description" : "Task Description",
"date_deadline" : "2014-05-05T12:00:00Z",
"page_url":"http://www.crowdcomputer.org/testme.html",
"reward": 0.5
}
+ Response 201 (application/json)
+ Body
{
"owner": "stefano",
"id": 4,
"title": "Task title",
"description": "Task Description",
"date_created": "2014-05-02T21:08:40.446",
"date_deadline": "2014-05-05T12:00:00Z",
"status": "ST",
"uuid": "feed552cd3174a49a4d1324e2cc53de8",
"page_url": "http://www.crowdcomputer.com/testme.html",
"reward" : 0.5
}
## Task Detail [/task/{id}/]
+ Parameters
+ id (required, number) ... The id of the task.
### Get a task [GET]
This updates a task.
+ Request JSON message
+ Headers
Authorization:Token X/Y
+ Body
+ Response 200 (application/json)
+ Body
{
"owner": "stefano",
"id": 4,
"title": "Task title edited",
"description": "Task Description",
"date_created": "2014-05-02T21:08:40.446",
"date_deadline": "2014-05-05T12:00:00Z",
"status": "ST",
"uuid": "feed552cd3174a49a4d1324e2cc53de8",
"page_url": "http://www.crowdcomputer.com/testme.html",
"reward" : 0.5
}
### Update a task [PUT]
This updates a task.
+ Request JSON message
+ Headers
Authorization:Token X/Y
+ Body
{
"title" : "Task title edited",
"description" : "Task Description",
"date_deadline" : "2014-05-05T12:00:00Z",
"page_url":"http://www.crowdcomputer.org/testme.html",
"reward": 0.5
}
+ Response 200 (application/json)
+ Body
{
"owner": "stefano",
"id": 4,
"title": "Task title edited",
"description": "Task Description",
"date_created": "2014-05-02T21:08:40.446",
"date_deadline": "2014-05-05T12:00:00Z",
"status": "ST",
"uuid": "feed552cd3174a49a4d1324e2cc53de8",
"page_url": "http://www.crowdcomputer.com/testme.html",
"reward" : 0.5
}
### Delete a task [DELETE]
This delete a task.
+ Request (*/*)
+ Headers
Authorization:Token X/Y
+ Body
{}
+ Response 204
## Start a task [/task/{id}/start/]
This starts a task
+ Parameters
+ id (required, number) ... The id of the task.
### Start [PUT]
+ Request (*/*)
+ Headers
Authorization:Token X/Y
+ Body
{}
+ Response 200 (application/json)
+ Body
{
'status':'PR'
}
## Stop a task [/task/{id}/stop/]
This stops a task
+ Parameters
+ id (required, number) ... The id of the task.
### Stop [PUT]
+ Request (*/*)
+ Headers
Authorization:Token X/Y
+ Body
{}
+ Response 200 (application/json)
+ Body
{
'status':'ST'
}
#Group TaskInstance
## Task [/task/{id}/taskinstance]
+ Parameters
+ id (required, number) ... The id of the task.
### Retrive the list of taskinstance of a task [GET]
This method returns the list of the task instances of the task identified with `id`
+ Request (text/plain)
+ Headers
Authorization: Token X/Y
+ Body
{}
+ Response 201 (application/json)
+ Body
[
...
]
### Create a taskInstance [POST]
This creates a task instance. ***input*** is the input data for that specific instnace.
This functions checks if the balamnce of the workers is enough to pay this instance.
+ Request JSON message
+ Headers
Authorization:Token X/Y
+ Body
{
"input" : {} //optional, must be a json
}
+ Response 201 (application/json)
+ Body
{
...
}
## TaskInstance Detail [/task/{id}/taskinstance/{id_instance}/]
+ Parameters
+ id (required, number) ... The id of the task.
+ id_instance (required, number) ... The id of the task instance.
### Get a task instnace [GET]
This returns the details of a task instance.
+ Request JSON message
+ Headers
Authorization:Token X/Y
+ Body
+ Response 200 (application/json)
+ Body
{
...
}
### Update a task instance [PUT]
This updates a task instance.
+ Request JSON message
+ Headers
Authorization:Token X/Y
+ Body
{
...
}
+ Response 200 (application/json)
+ Body
{
...
}
### Delete a task instance [DELETE]
This delete a task.
+ Request (*/*)
+ Headers
Authorization:Token X/Y
+ Body
{}
+ Response 204
## Start a task instance [/task/{id}/taskinstance/{id_instance}/start/]
This starts a task
+ Parameters
+ id (required, number) ... The id of the task.
+ id_instance (required, number) ... The id of the task instance.
### Start [POST]
+ Request (*/*)
+ Headers
Authorization:Token X/Y
+ Body
{}
+ Response 200 (application/json)
+ Body
{
'status':'PR'
}
## Stop a task instance [/task/{id}/taskinstance/{id_instance}/stop/]
This stops a task
+ Parameters
+ id (required, number) ... The id of the task.
+ id_instance (required, number) ... The id of the task instance.
### Stop [POST]
+ Request (*/*)
+ Headers
Authorization:Token X/Y
+ Body
{}
+ Response 200 (application/json)
+ Body
{
'status':'ST'
}
## Assign a task instance to a worker [/task/{id}/taskinstance/{id_instance}/assign/]
This assign the task instance to a worker
+ Parameters
+ id (required, number) ... The id of the task.
+ id_instance (required, number) ... The id of the task instance.
### Assign [POST]
+ Request (*/*)
+ Headers
Authorization:Token X/Y
+ Body
{
'worker': 1 //id of the worker
}
+ Response 200 (application/json)
+ Body
{
...
}
## Execute a task instance, thus update the task instance metadata [/task/{id}/taskinstance/{id_instance}/execute/]
This updates the task instance metadata.
+ Parameters
+ id (required, number) ... The id of the task.
+ id_instance (required, number) ... The id of the task instance.
### Execute [POST]
+ Request (*/*)
+ Headers
Authorization:Token X/Y
+ Body
{
'result': {} //a json object
}
+ Response 200 (application/json)
+ Body
{
...
}
## Give the reward to an worker of a task instance [/task/{id}/taskinstance/{id_instance}/reward_give/]
This give the reward to the worker of the instance taking the money from the requester account.
+ Parameters
+ id (required, number) ... The id of the task.
+ id_instance (required, number) ... The id of the task instance.
### Execute [POST]
+ Request (*/*)
+ Headers
Authorization:Token X/Y
+ Body
{}
+ Response 200 (application/json)
+ Body
{
'details': 'Reward of ... given'
}
## Reject the reward to an worker of a task instance [/task/{id}/taskinstance/{id_instance}/reward_reject/]
This rejects the reward for a worker.
+ Parameters
+ id (required, number) ... The id of the task.
+ id_instance (required, number) ... The id of the task instance.
### Execute [POST]
+ Request (*/*)
+ Headers
Authorization:Token X/Y
+ Body
{}
+ Response 200 (application/json)
+ Body
{
'details': 'Reward of ... rejected'
}
## Set the quality of a task instance [/task/{id}/taskinstance/{id_instance}/quality_set/]
This sets the quality of a task instance
+ Parameters
+ id (required, number) ... The id of the task.
+ id_instance (required, number) ... The id of the task instance.
### Execute [POST]
+ Request (*/*)
+ Headers
Authorization:Token X/Y
+ Body
{
'value': 55 //number between 0 and 100
}
+ Response 200 (application/json)
+ Body
{
'details': 'Quality set'
}
## Get the quality of a task instance [/task/{id}/taskinstance/{id_instance}/qualit_get/]
This gets the quality of a task instance
+ Parameters
+ id (required, number) ... The id of the task.
+ id_instance (required, number) ... The id of the task instance.
### Execute [GET]
+ Request (*/*)
+ Headers
Authorization:Token X/Y
+ Body
{
}
+ Response 200 (application/json)
+ Body
{
'value': 55
}