This repository has been archived by the owner on Jan 26, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmmos-api-public.html
768 lines (737 loc) · 76.6 KB
/
mmos-api-public.html
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
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
<!DOCTYPE html><html><head><meta charset="utf-8"><title>MMOS API documentation</title><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"><style>@import url('https://fonts.googleapis.com/css?family=Roboto:400,700|Inconsolata|Raleway:200');.hljs-comment,.hljs-title{color:#8e908c}.hljs-variable,.hljs-attribute,.hljs-tag,.hljs-regexp,.ruby .hljs-constant,.xml .hljs-tag .hljs-title,.xml .hljs-pi,.xml .hljs-doctype,.html .hljs-doctype,.css .hljs-id,.css .hljs-class,.css .hljs-pseudo{color:#c82829}.hljs-number,.hljs-preprocessor,.hljs-pragma,.hljs-built_in,.hljs-literal,.hljs-params,.hljs-constant{color:#f5871f}.ruby .hljs-class .hljs-title,.css .hljs-rules .hljs-attribute{color:#eab700}.hljs-string,.hljs-value,.hljs-inheritance,.hljs-header,.ruby .hljs-symbol,.xml .hljs-cdata{color:#718c00}.css .hljs-hexcolor{color:#3e999f}.hljs-function,.python .hljs-decorator,.python .hljs-title,.ruby .hljs-function .hljs-title,.ruby .hljs-title .hljs-keyword,.perl .hljs-sub,.javascript .hljs-title,.coffeescript .hljs-title{color:#4271ae}.hljs-keyword,.javascript .hljs-function{color:#8959a8}.hljs{display:block;background:white;color:#4d4d4c;padding:.5em}.coffeescript .javascript,.javascript .xml,.tex .hljs-formula,.xml .javascript,.xml .vbscript,.xml .css,.xml .hljs-cdata{opacity:.5}.right .hljs-comment{color:#969896}.right .css .hljs-class,.right .css .hljs-id,.right .css .hljs-pseudo,.right .hljs-attribute,.right .hljs-regexp,.right .hljs-tag,.right .hljs-variable,.right .html .hljs-doctype,.right .ruby .hljs-constant,.right .xml .hljs-doctype,.right .xml .hljs-pi,.right .xml .hljs-tag .hljs-title{color:#c66}.right .hljs-built_in,.right .hljs-constant,.right .hljs-literal,.right .hljs-number,.right .hljs-params,.right .hljs-pragma,.right .hljs-preprocessor{color:#de935f}.right .css .hljs-rule .hljs-attribute,.right .ruby .hljs-class .hljs-title{color:#f0c674}.right .hljs-header,.right .hljs-inheritance,.right .hljs-name,.right .hljs-string,.right .hljs-value,.right .ruby .hljs-symbol,.right .xml .hljs-cdata{color:#b5bd68}.right .css .hljs-hexcolor,.right .hljs-title{color:#8abeb7}.right .coffeescript .hljs-title,.right .hljs-function,.right .javascript .hljs-title,.right .perl .hljs-sub,.right .python .hljs-decorator,.right .python .hljs-title,.right .ruby .hljs-function .hljs-title,.right .ruby .hljs-title .hljs-keyword{color:#81a2be}.right .hljs-keyword,.right .javascript .hljs-function{color:#b294bb}.right .hljs{display:block;overflow-x:auto;background:#1d1f21;color:#c5c8c6;padding:.5em;-webkit-text-size-adjust:none}.right .coffeescript .javascript,.right .javascript .xml,.right .tex .hljs-formula,.right .xml .css,.right .xml .hljs-cdata,.right .xml .javascript,.right .xml .vbscript{opacity:.5}body{color:black;background:white;font:400 14px / 1.42 'Roboto',Helvetica,sans-serif}header{border-bottom:1px solid #ededed;margin-bottom:12px}h1,h2,h3,h4,h5{color:black;margin:12px 0}h1 .permalink,h2 .permalink,h3 .permalink,h4 .permalink,h5 .permalink{margin-left:0;opacity:0;transition:opacity .25s ease}h1:hover .permalink,h2:hover .permalink,h3:hover .permalink,h4:hover .permalink,h5:hover .permalink{opacity:1}.triple h1 .permalink,.triple h2 .permalink,.triple h3 .permalink,.triple h4 .permalink,.triple h5 .permalink{opacity:.15}.triple h1:hover .permalink,.triple h2:hover .permalink,.triple h3:hover .permalink,.triple h4:hover .permalink,.triple h5:hover .permalink{opacity:.15}h1{font:200 36px 'Raleway',Helvetica,sans-serif;font-size:36px}h2{font:200 36px 'Raleway',Helvetica,sans-serif;font-size:30px}h3{font-size:100%;text-transform:uppercase}h5{font-size:100%;font-weight:normal}p{margin:0 0 10px}p.choices{line-height:1.6}a{color:#18bc9c;text-decoration:none}li p{margin:0}hr.split{border:0;height:1px;width:100%;padding-left:6px;margin:12px auto;background-image:linear-gradient(to right, rgba(0,0,0,0) 20%, rgba(0,0,0,0.2) 51.4%, rgba(255,255,255,0.2) 51.4%, rgba(255,255,255,0) 80%)}dl dt{float:left;width:130px;clear:left;text-align:right;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:700}dl dd{margin-left:150px}blockquote{color:rgba(0,0,0,0.5);font-size:15.5px;padding:10px 20px;margin:12px 0;border-left:5px solid #e8e8e8}blockquote p:last-child{margin-bottom:0}pre{background-color:#f5f5f5;padding:12px;border:1px solid #cfcfcf;border-radius:6px;overflow:auto}pre code{color:black;background-color:transparent;padding:0;border:none}code{color:#444;background-color:#f5f5f5;font:'Inconsolata',monospace;padding:1px 4px;border:1px solid #cfcfcf;border-radius:3px}ul,ol{padding-left:2em}table{border-collapse:collapse;border-spacing:0;margin-bottom:12px}table tr:nth-child(2n){background-color:#fafafa}table th,table td{padding:6px 12px;border:1px solid #e6e6e6}.text-muted{opacity:.5}.note,.warning{padding:.3em 1em;margin:1em 0;border-radius:2px;font-size:90%}.note h1,.warning h1,.note h2,.warning h2,.note h3,.warning h3,.note h4,.warning h4,.note h5,.warning h5,.note h6,.warning h6{font-family:200 36px 'Raleway',Helvetica,sans-serif;font-size:135%;font-weight:500}.note p,.warning p{margin:.5em 0}.note{color:black;background-color:#eff7fc;border-left:4px solid #3498db}.note h1,.note h2,.note h3,.note h4,.note h5,.note h6{color:#3498db}.warning{color:black;background-color:#fcf0ef;border-left:4px solid #d62c1a}.warning h1,.warning h2,.warning h3,.warning h4,.warning h5,.warning h6{color:#d62c1a}header{margin-top:24px}nav{position:fixed;top:24px;bottom:0;overflow-y:auto}nav .resource-group{padding:0}nav .resource-group .heading{position:relative}nav .resource-group .heading .chevron{position:absolute;top:12px;right:12px;opacity:.5}nav .resource-group .heading a{display:block;color:black;opacity:.7;border-left:2px solid transparent;margin:0}nav .resource-group .heading a:hover{text-decoration:none;background-color:bad-color;border-left:2px solid black}nav ul{list-style-type:none;padding-left:0}nav ul a{display:block;font-size:13px;color:rgba(0,0,0,0.7);padding:8px 12px;border-top:1px solid #ededed;border-left:2px solid transparent;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}nav ul a:hover{text-decoration:none;background-color:bad-color;border-left:2px solid black}nav ul>li{margin:0}nav ul>li:first-child{margin-top:-12px}nav ul>li:last-child{margin-bottom:-12px}nav ul ul a{padding-left:24px}nav ul ul li{margin:0}nav ul ul li:first-child{margin-top:0}nav ul ul li:last-child{margin-bottom:0}nav>div>div>ul>li:first-child>a{border-top:none}.preload *{transition:none !important}.pull-left{float:left}.pull-right{float:right}.badge{display:inline-block;float:right;min-width:10px;min-height:14px;padding:3px 7px;font-size:12px;color:#000;background-color:#ededed;border-radius:10px;margin:-2px 0}.badge.get{color:white;background-color:#3498db}.badge.head{color:white;background-color:#3498db}.badge.options{color:white;background-color:#3498db}.badge.put{color:white;background-color:#f39c12}.badge.patch{color:white;background-color:#f39c12}.badge.post{color:white;background-color:#18bc9c}.badge.delete{color:white;background-color:#e74c3c}.collapse-button{float:right}.collapse-button .close{display:none;color:#18bc9c;cursor:pointer}.collapse-button .open{color:#18bc9c;cursor:pointer}.collapse-button.show .close{display:inline}.collapse-button.show .open{display:none}.collapse-content{max-height:0;overflow:hidden;transition:max-height .3s ease-in-out}nav{width:220px}.container{max-width:940px;margin-left:auto;margin-right:auto}.container .row .content{margin-left:244px;width:696px}.container .row:after{content:'';display:block;clear:both}.container-fluid nav{width:22%}.container-fluid .row .content{margin-left:24%}.container-fluid.triple nav{width:16.5%;padding-right:1px}.container-fluid.triple .row .content{position:relative;margin-left:16.5%;padding-left:24px}.middle:before,.middle:after{content:'';display:table}.middle:after{clear:both}.middle{box-sizing:border-box;width:51.5%;padding-right:12px}.right{box-sizing:border-box;float:right;width:48.5%;padding-left:12px}.right a{color:#18bc9c}.right h1,.right h2,.right h3,.right h4,.right h5,.right p,.right div{color:white}.right pre{background-color:#1d1f21;border:1px solid #1d1f21}.right pre code{color:#c5c8c6}.right .description{margin-top:12px}.triple .resource-heading{font-size:125%}.definition{margin-top:12px;margin-bottom:12px}.definition .method{font-weight:bold}.definition .method.get{color:#2e80b8}.definition .method.head{color:#2e80b8}.definition .method.options{color:#2e80b8}.definition .method.post{color:#2eb89d}.definition .method.put{color:#b8822e}.definition .method.patch{color:#b8822e}.definition .method.delete{color:#b83b2e}.definition .uri{word-break:break-all;word-wrap:break-word}.definition .hostname{opacity:.5}.example-names{background-color:#eee;padding:12px;border-radius:6px}.example-names .tab-button{cursor:pointer;color:black;border:1px solid #ddd;padding:6px;margin-left:12px}.example-names .tab-button.active{background-color:#d5d5d5}.right .example-names{background-color:#444}.right .example-names .tab-button{color:white;border:1px solid #666;border-radius:6px}.right .example-names .tab-button.active{background-color:#5e5e5e}#nav-background{position:fixed;left:0;top:0;bottom:0;width:16.5%;padding-right:14.4px;background-color:#fbfbfb;border-right:1px solid #f0f0f0;z-index:-1}#right-panel-background{position:absolute;right:-12px;top:-12px;bottom:-12px;width:48.6%;background-color:#333;z-index:-1}@media (max-width:1200px){nav{width:198px}.container{max-width:840px}.container .row .content{margin-left:224px;width:606px}}@media (max-width:992px){nav{width:169.4px}.container{max-width:720px}.container .row .content{margin-left:194px;width:526px}}@media (max-width:768px){nav{display:none}.container{width:95%;max-width:none}.container .row .content,.container-fluid .row .content,.container-fluid.triple .row .content{margin-left:auto;margin-right:auto;width:95%}#nav-background{display:none}#right-panel-background{width:48.6%}}.back-to-top{position:fixed;z-index:1;bottom:0;right:24px;padding:4px 8px;color:rgba(0,0,0,0.5);background-color:#ededed;text-decoration:none !important;border-top:1px solid #ededed;border-left:1px solid #ededed;border-right:1px solid #ededed;border-top-left-radius:3px;border-top-right-radius:3px}.resource-group{padding:12px;margin-bottom:12px;background-color:white;border:1px solid #ededed;border-radius:6px}.resource-group h2.group-heading,.resource-group .heading a{padding:12px;margin:-12px -12px 12px -12px;background-color:#ededed;border-bottom:1px solid #ededed;border-top-left-radius:6px;border-top-right-radius:6px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.triple .content .resource-group{padding:0;border:none}.triple .content .resource-group h2.group-heading,.triple .content .resource-group .heading a{margin:0 0 12px 0;border:1px solid #ededed}nav .resource-group .heading a{padding:12px;margin-bottom:0}nav .resource-group .collapse-content{padding:0}.action{margin-bottom:12px;padding:12px 12px 0 12px;overflow:hidden;border:1px solid transparent;border-radius:6px}.action h4.action-heading{padding:6px 12px;margin:-12px -12px 12px -12px;border-bottom:1px solid transparent;border-top-left-radius:6px;border-top-right-radius:6px;overflow:hidden}.action h4.action-heading .name{float:right;font-weight:normal;padding:6px 0}.action h4.action-heading .method{padding:6px 12px;margin-right:12px;border-radius:3px;display:inline-block}.action h4.action-heading .method.get{color:#000;background-color:white}.action h4.action-heading .method.head{color:#000;background-color:white}.action h4.action-heading .method.options{color:#000;background-color:white}.action h4.action-heading .method.put{color:#000;background-color:white}.action h4.action-heading .method.patch{color:#000;background-color:white}.action h4.action-heading .method.post{color:#000;background-color:white}.action h4.action-heading .method.delete{color:#000;background-color:white}.action h4.action-heading code{color:#444;background-color:rgba(255,255,255,0.7);border-color:transparent;font-weight:normal;word-break:break-all;display:inline-block;margin-top:2px}.action dl.inner{padding-bottom:2px}.action .title{border-bottom:1px solid white;margin:0 -12px -1px -12px;padding:12px}.action.get{border-color:#3498db}.action.get h4.action-heading{color:white;background:#3498db;border-bottom-color:#3498db}.action.head{border-color:#3498db}.action.head h4.action-heading{color:white;background:#3498db;border-bottom-color:#3498db}.action.options{border-color:#3498db}.action.options h4.action-heading{color:white;background:#3498db;border-bottom-color:#3498db}.action.post{border-color:#18bc9c}.action.post h4.action-heading{color:white;background:#18bc9c;border-bottom-color:#18bc9c}.action.put{border-color:#f39c12}.action.put h4.action-heading{color:white;background:#f39c12;border-bottom-color:#f39c12}.action.patch{border-color:#f39c12}.action.patch h4.action-heading{color:white;background:#f39c12;border-bottom-color:#f39c12}.action.delete{border-color:#e74c3c}.action.delete h4.action-heading{color:white;background:#e74c3c;border-bottom-color:#e74c3c}</style></head><body class="preload"><a href="#top" class="text-muted back-to-top"><i class="fa fa-toggle-up"></i> Back to top</a><div class="container"><div class="row"><nav><div class="resource-group"><div class="heading"><div class="chevron"><i class="open fa fa-angle-down"></i></div><a href="#top">Overview</a></div><div class="collapse-content"><ul><li><a href="#header-authentication">Authentication</a></li><li><a href="#header-api-error-handling">API error handling</a></li><li><a href="#header-error-states">Error States</a></li><li><a href="#header-error-responses">Error responses</a></li></ul></div></div><div class="resource-group"><div class="heading"><div class="chevron"><i class="open fa fa-angle-down"></i></div><a href="#api">API</a></div><div class="collapse-content"><ul><li><a href="#api-api-information-get"><span class="badge get"><i class="fa fa-arrow-down"></i></span>Getting API information</a></li></ul></div></div><div class="resource-group"><div class="heading"><div class="chevron"><i class="open fa fa-angle-down"></i></div><a href="#players">Players</a></div><div class="collapse-content"><ul><li><a href="#players-tasks-post"><span class="badge post"><i class="fa fa-plus"></i></span>Get new task for player</a></li><li><a href="#players-players-get"><span class="badge get"><i class="fa fa-arrow-down"></i></span>Player statistics</a></li></ul></div></div><div class="resource-group"><div class="heading"><div class="chevron"><i class="open fa fa-angle-down"></i></div><a href="#classifications">Classifications</a></div><div class="collapse-content"><ul><li><a href="#classifications-classifications-post"><span class="badge post"><i class="fa fa-plus"></i></span>Create a Classification</a></li></ul></div></div><p style="text-align: center; word-wrap: break-word;"><a href="https://api.depo.mmos.blue">https://api.depo.mmos.blue</a></p></nav><div class="content"><header><h1 id="top">MMOS API documentation</h1></header><p>The API of <a href="http://mmos.ch">Massively Multiplayer Online Science</a> for citizen science clients</p>
<div class="note">
<h2 id="header-authentication">Authentication <a class="permalink" href="#header-authentication" aria-hidden="true">¶</a></h2>
<p>All calls requires <a href="https://en.wikipedia.org/wiki/Hash-based_message_authentication_code">HMAC-SHA256 authentication</a>. The documetation of the exact procedures to successfully sign API calls are given to developers separately. Note that gameId is connected to APiKeys, so where a gameId is needed, a mismatch will result in error as well (100010 - Authentication API Key not matching gameId).</p>
</div>
<h1 id="header-api-error-handling">API error handling <a class="permalink" href="#header-api-error-handling" aria-hidden="true">¶</a></h1>
<h2 id="header-error-states">Error States <a class="permalink" href="#header-error-states" aria-hidden="true">¶</a></h2>
<p>The common <a href="https://github.com/for-GET/know-your-http-well/blob/master/status-codes.md">HTTP Response Status Codes</a> are used.</p>
<h2 id="header-error-responses">Error responses <a class="permalink" href="#header-error-responses" aria-hidden="true">¶</a></h2>
<p>Sample error response:</p>
<pre><code>{
"<span class="hljs-attribute">code</span>": <span class="hljs-value"><span class="hljs-number">103010</span></span>,
"<span class="hljs-attribute">error</span>": <span class="hljs-value"><span class="hljs-string">"Player with code 'nonexistingplayercode' doesn't exist in the database"</span>
</span>}</code></pre>
<p>Validation errors with json requests result in a HTTP 400 response:</p>
<pre><code>{
"<span class="hljs-attribute">code</span>": <span class="hljs-value"><span class="hljs-number">100120</span></span>,
"<span class="hljs-attribute">error</span>": <span class="hljs-value"><span class="hljs-string">"Validation errors"</span></span>,
"<span class="hljs-attribute">details</span>": <span class="hljs-value">[
{
"<span class="hljs-attribute">code</span>": <span class="hljs-value"><span class="hljs-string">"INVALID_TYPE"</span></span>,
"<span class="hljs-attribute">params</span>": <span class="hljs-value">[<span class="hljs-string">"integer"</span>, <span class="hljs-string">"string"</span>]</span>,
"<span class="hljs-attribute">message</span>": <span class="hljs-value"><span class="hljs-string">"Expected type integer but found type string"</span></span>,
"<span class="hljs-attribute">path</span>": <span class="hljs-value"><span class="hljs-string">"#/gameId"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"The id given by MMOS for the game client for identification"</span>
</span>}
]
</span>}</code></pre>
<p>JSON schema to validate error responses:</p>
<pre><code>{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"object"</span></span>,
"<span class="hljs-attribute">required</span>": <span class="hljs-value">[<span class="hljs-string">"code"</span>, <span class="hljs-string">"error"</span>]</span>,
"<span class="hljs-attribute">additionalProperties</span>": <span class="hljs-value"><span class="hljs-literal">false</span></span>,
"<span class="hljs-attribute">properties</span>": <span class="hljs-value">{
"<span class="hljs-attribute">code</span>": <span class="hljs-value">{ "<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"integer"</span></span>, "<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Error code"</span> </span>}</span>,
"<span class="hljs-attribute">error</span>": <span class="hljs-value">{ "<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>, "<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Error message"</span> </span>}</span>,
"<span class="hljs-attribute">details</span>": <span class="hljs-value">{ "<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"object"</span></span>, "<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Detailed error object"</span> </span>}
</span>}
</span>}</code></pre>
<section id="api" class="resource-group"><h2 class="group-heading">API <a href="#api" class="permalink">¶</a></h2><div id="api-api-information" class="resource"><h3 class="resource-heading">API information <a href="#api-api-information" class="permalink"> ¶</a></h3><div id="api-api-information-get" class="action get"><h4 class="action-heading"><div class="name">Getting API information</div><a href="#api-api-information-get" class="method get">GET</a><code class="uri">/</code></h4><p>Returns statistical information about the API</p>
<h4>Example URI</h4><div class="definition"><span class="method get">GET</span> <span class="uri"><span class="hostname">https://api.depo.mmos.blue</span>/</span></div><div class="title"><strong>Response <code>200</code></strong><div class="collapse-button"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><div class="inner"><h5>Headers</h5><pre><code><span class="hljs-attribute">Content-Type</span>: <span class="hljs-string">application/json; charset=utf-8</span></code></pre><div style="height: 1px;"></div><h5>Body</h5><pre><code>{
{
<span class="hljs-string">"name"</span>: <span class="hljs-string">"mmos-api-2"</span>,
<span class="hljs-string">"version"</span>: <span class="hljs-string">"2.0.11"</span>,
<span class="hljs-string">"description"</span>: <span class="hljs-string">"Massively Multiplayer Online Science - Citizen Science Server API 2, © 2015-2017 MMOS Sàrl"</span>,
<span class="hljs-string">"homepage"</span>: <span class="hljs-string">"http://mmos.ch"</span>,
<span class="hljs-string">"stats"</span>: {
<span class="hljs-string">"uptime"</span>: <span class="hljs-number">3.564</span>,
<span class="hljs-string">"uptimeFriendly"</span>: <span class="hljs-string">"a few seconds"</span>,
<span class="hljs-string">"uptimeSince"</span>: <span class="hljs-string">"2017-05-21T19:26:28.472Z"</span>,
<span class="hljs-string">"platform"</span>: <span class="hljs-string">"darwin"</span>,
<span class="hljs-string">"architecture"</span>: <span class="hljs-string">"x64"</span>,
<span class="hljs-string">"nodeVersion"</span>: <span class="hljs-string">"v6.10.0"</span>,
<span class="hljs-string">"nodeEnv"</span>: <span class="hljs-string">"local"</span>
}
}
}</code></pre><div style="height: 1px;"></div><h5>Schema</h5><pre><code>{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"object"</span></span>,
"<span class="hljs-attribute">required</span>": <span class="hljs-value">[<span class="hljs-string">"name"</span>, <span class="hljs-string">"version"</span>, <span class="hljs-string">"description"</span>, <span class="hljs-string">"homepage"</span>, <span class="hljs-string">"stats"</span>]</span>,
"<span class="hljs-attribute">additionalProperties</span>": <span class="hljs-value"><span class="hljs-literal">false</span></span>,
"<span class="hljs-attribute">properties</span>": <span class="hljs-value">{
"<span class="hljs-attribute">name</span>": <span class="hljs-value">{ "<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>, "<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Application name"</span> </span>}</span>,
"<span class="hljs-attribute">version</span>": <span class="hljs-value">{ "<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>, "<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Version number"</span> </span>}</span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value">{ "<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>, "<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Description of the service"</span> </span>}</span>,
"<span class="hljs-attribute">homepage</span>": <span class="hljs-value">{ "<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>, "<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"MMOS homepage"</span> </span>}</span>,
"<span class="hljs-attribute">stats</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"object"</span></span>,
"<span class="hljs-attribute">required</span>": <span class="hljs-value">[<span class="hljs-string">"uptime"</span>, <span class="hljs-string">"uptimeFriendly"</span>, <span class="hljs-string">"uptimeSince"</span>, <span class="hljs-string">"platform"</span>, <span class="hljs-string">"architecture"</span>, <span class="hljs-string">"nodeVersion"</span>, <span class="hljs-string">"nodeEnv"</span>]</span>,
"<span class="hljs-attribute">additionalProperties</span>": <span class="hljs-value"><span class="hljs-literal">false</span></span>,
"<span class="hljs-attribute">properties</span>": <span class="hljs-value">{
"<span class="hljs-attribute">uptime</span>": <span class="hljs-value">{ "<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"number"</span></span>, "<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Server uptime in seconds"</span> </span>}</span>,
"<span class="hljs-attribute">uptimeFriendly</span>": <span class="hljs-value">{ "<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>, "<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Server uptime in human readable format"</span> </span>}</span>,
"<span class="hljs-attribute">uptimeSince</span>": <span class="hljs-value">{ "<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>, "<span class="hljs-attribute">format</span>": <span class="hljs-value"><span class="hljs-string">"date-time"</span></span>, "<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Server start time"</span> </span>}</span>,
"<span class="hljs-attribute">platform</span>": <span class="hljs-value">{ "<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>, "<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Host operating system platform"</span> </span>}</span>,
"<span class="hljs-attribute">architecture</span>": <span class="hljs-value">{ "<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>, "<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Host processor architecture"</span> </span>}</span>,
"<span class="hljs-attribute">nodeVersion</span>": <span class="hljs-value">{ "<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>, "<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Node.js version"</span> </span>}</span>,
"<span class="hljs-attribute">nodeEnv</span>": <span class="hljs-value">{ "<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>, "<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Node.js environment"</span> </span>}
</span>}
</span>}
</span>}
</span>}</code></pre><div style="height: 1px;"></div></div></div></div></div></section><section id="players" class="resource-group"><h2 class="group-heading">Players <a href="#players" class="permalink">¶</a></h2><div id="players-tasks" class="resource"><h3 class="resource-heading">Tasks <a href="#players-tasks" class="permalink"> ¶</a></h3><div id="players-tasks-post" class="action post"><h4 class="action-heading"><div class="name">Get new task for player</div><a href="#players-tasks-post" class="method post">POST</a><code class="uri">/games/{game}/players/{player}/tasks</code></h4><p>This is the API call to get a new task for a player.</p>
<h4>Example URI</h4><div class="definition"><span class="method post">POST</span> <span class="uri"><span class="hostname">https://api.depo.mmos.blue</span>/games/<span class="hljs-attribute" title="game">:gameCode</span>/players/<span class="hljs-attribute" title="player">:playerCode</span>/tasks</span></div><div class="title"><strong>URI Parameters</strong><div class="collapse-button show"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><dl class="inner"><dt>game</dt><dd><code>string</code> <span class="required">(required)</span> <span class="text-muted example"><strong>Example: </strong><span>:gameCode</span></span><p>Game code</p>
</dd><dt>player</dt><dd><code>string</code> <span class="required">(required)</span> <span class="text-muted example"><strong>Example: </strong><span>:playerCode</span></span><p>Player code</p>
</dd></dl></div><div class="title"><strong>Request</strong><div class="collapse-button"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><div class="inner"><h5>Headers</h5><pre><code><span class="hljs-attribute">Content-Type</span>: <span class="hljs-string">application/json; charset=utf-8</span></code></pre><div style="height: 1px;"></div><h5>Body</h5><pre><code>{
"<span class="hljs-attribute">projects</span>": <span class="hljs-value">[
<span class="hljs-string">":projectCode"</span>
]</span>,
"<span class="hljs-attribute">player</span>": <span class="hljs-value">{
"<span class="hljs-attribute">accountCode</span>": <span class="hljs-value"><span class="hljs-string">":accountCode"</span>
</span>}
</span>}</code></pre><div style="height: 1px;"></div><h5>Schema</h5><pre><code>{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"object"</span></span>,
"<span class="hljs-attribute">required</span>": <span class="hljs-value">[
<span class="hljs-string">"projects"</span>
]</span>,
"<span class="hljs-attribute">additionalProperties</span>": <span class="hljs-value"><span class="hljs-literal">false</span></span>,
"<span class="hljs-attribute">properties</span>": <span class="hljs-value">{
"<span class="hljs-attribute">projects</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"array"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"An array of Project codes"</span>
</span>}</span>,
"<span class="hljs-attribute">player</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"object"</span></span>,
"<span class="hljs-attribute">additionalProperties</span>": <span class="hljs-value"><span class="hljs-literal">false</span></span>,
"<span class="hljs-attribute">properties</span>": <span class="hljs-value">{
"<span class="hljs-attribute">accountCode</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"The accountCode of the player"</span>
</span>}
</span>}
</span>}
</span>}
</span>}</code></pre><div style="height: 1px;"></div></div></div><div class="title"><strong>Response <code>201</code></strong><div class="collapse-button"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><div class="inner"><h5>Headers</h5><pre><code><span class="hljs-attribute">Content-Type</span>: <span class="hljs-string">application/json; charset=utf-8</span></code></pre><div style="height: 1px;"></div><h5>Body</h5><pre><code>{
"<span class="hljs-attribute">uid</span>": <span class="hljs-value"><span class="hljs-string">"c5dccfba-d1dc-4b0a-a111-ea6e6bed47f5-1547830463571"</span></span>,
"<span class="hljs-attribute">game</span>": <span class="hljs-value"><span class="hljs-string">":gameCode"</span></span>,
"<span class="hljs-attribute">player</span>": <span class="hljs-value">{
"<span class="hljs-attribute">code</span>": <span class="hljs-value"><span class="hljs-string">":playerCode"</span></span>,
"<span class="hljs-attribute">accountCode</span>": <span class="hljs-value"><span class="hljs-string">":accountCode"</span>
</span>}</span>,
"<span class="hljs-attribute">task</span>": <span class="hljs-value">{
"<span class="hljs-attribute">id</span>": <span class="hljs-value"><span class="hljs-number">10000029</span></span>,
"<span class="hljs-attribute">run</span>": <span class="hljs-value"><span class="hljs-number">1</span></span>,
"<span class="hljs-attribute">project</span>": <span class="hljs-value"><span class="hljs-string">":projectCode"</span></span>,
"<span class="hljs-attribute">isTrainingSet</span>": <span class="hljs-value"><span class="hljs-literal">true</span></span>,
"<span class="hljs-attribute">difficulty</span>": <span class="hljs-value"><span class="hljs-number">1</span></span>,
"<span class="hljs-attribute">assetsSecurityPass</span>": <span class="hljs-value"><span class="hljs-string">"7c48dff5-b823-4b0f-b776-c73ba847bf71"</span></span>,
"<span class="hljs-attribute">assets</span>": <span class="hljs-value">{
"<span class="hljs-attribute">name</span>": <span class="hljs-value"><span class="hljs-string">"https://www.inaturalist.org/listed_taxa/2887491"</span></span>,
"<span class="hljs-attribute">url</span>": <span class="hljs-value"><span class="hljs-string">"Rodrigues flying fox"</span></span>,
"<span class="hljs-attribute">solution</span>": <span class="hljs-value">[
<span class="hljs-string">"Animalia"</span>,
<span class="hljs-string">"Chordata"</span>,
<span class="hljs-string">"Mammalia"</span>,
<span class="hljs-string">"Laurasiatheria"</span>,
<span class="hljs-string">"Chiroptera"</span>,
<span class="hljs-string">"Yinpterochiroptera"</span>,
<span class="hljs-string">"Pteropodidea"</span>,
<span class="hljs-string">"Pteropodidae"</span>,
<span class="hljs-string">"Pteropodinae"</span>,
<span class="hljs-string">""</span>,
<span class="hljs-string">"Pteropus"</span>,
<span class="hljs-string">"Pteropus rodricensis"</span>,
<span class="hljs-string">"https://www.inaturalist.org/listed_taxa/2887491"</span>,
<span class="hljs-string">"Rodrigues flying fox"</span>
]
</span>}</span>,
"<span class="hljs-attribute">info</span>": <span class="hljs-value">{
"<span class="hljs-attribute">info</span>": <span class="hljs-value">{}
</span>}
</span>}
</span>}</code></pre><div style="height: 1px;"></div><h5>Schema</h5><pre><code>{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"object"</span></span>,
"<span class="hljs-attribute">required</span>": <span class="hljs-value">[
<span class="hljs-string">"uid"</span>,
<span class="hljs-string">"game"</span>,
<span class="hljs-string">"player"</span>,
<span class="hljs-string">"task"</span>
]</span>,
"<span class="hljs-attribute">additionalProperties</span>": <span class="hljs-value"><span class="hljs-literal">false</span></span>,
"<span class="hljs-attribute">properties</span>": <span class="hljs-value">{
"<span class="hljs-attribute">uid</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"The unique identifier of the request"</span>
</span>}</span>,
"<span class="hljs-attribute">game</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Game code"</span>
</span>}</span>,
"<span class="hljs-attribute">player</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"object"</span></span>,
"<span class="hljs-attribute">required</span>": <span class="hljs-value">[
<span class="hljs-string">"code"</span>,
<span class="hljs-string">"accountCode"</span>
]</span>,
"<span class="hljs-attribute">additionalProperties</span>": <span class="hljs-value"><span class="hljs-literal">false</span></span>,
"<span class="hljs-attribute">properties</span>": <span class="hljs-value">{
"<span class="hljs-attribute">code</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Player code"</span>
</span>}</span>,
"<span class="hljs-attribute">accountCode</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"The accountCode of the player"</span>
</span>}
</span>}
</span>}</span>,
"<span class="hljs-attribute">task</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"object"</span></span>,
"<span class="hljs-attribute">required</span>": <span class="hljs-value">[
<span class="hljs-string">"id"</span>,
<span class="hljs-string">"project"</span>
]</span>,
"<span class="hljs-attribute">anyOf</span>": <span class="hljs-value">[
{
"<span class="hljs-attribute">required</span>": <span class="hljs-value">[
<span class="hljs-string">"assetsSecurityPass"</span>
]
</span>},
{
"<span class="hljs-attribute">required</span>": <span class="hljs-value">[
<span class="hljs-string">"assets"</span>
]
</span>}
]</span>,
"<span class="hljs-attribute">additionalProperties</span>": <span class="hljs-value"><span class="hljs-literal">false</span></span>,
"<span class="hljs-attribute">properties</span>": <span class="hljs-value">{
"<span class="hljs-attribute">id</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"integer"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Task id"</span>
</span>}</span>,
"<span class="hljs-attribute">run</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"integer"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Marking the run number the task is in. In other words: how many times the number of solutions reached the consensus calculation limit plus 1 (first run means the task hasn't received enough solutions for the first consensus)"</span>
</span>}</span>,
"<span class="hljs-attribute">project</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Project code"</span>
</span>}</span>,
"<span class="hljs-attribute">isTrainingSet</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"boolean"</span></span>,
"<span class="hljs-attribute">descirption</span>": <span class="hljs-value"><span class="hljs-string">"Marking that the player is in the initial training period, or if isTrainingSet is explicitly set in the request. Otherwise this info is hidden"</span>
</span>}</span>,
"<span class="hljs-attribute">difficulty</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"integer"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"The estimated difficulty of a puzzle calculated by Phylo on a 1-10 scale"</span>
</span>}</span>,
"<span class="hljs-attribute">assetsSecurityPass</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Not used currently"</span>
</span>}</span>,
"<span class="hljs-attribute">assets</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"object"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Info to get the assets (ie. images) for the task - project specific"</span>
</span>}</span>,
"<span class="hljs-attribute">info</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"object"</span>
</span>}
</span>}
</span>}
</span>}
</span>}</code></pre><div style="height: 1px;"></div></div></div></div></div><div id="players-players" class="resource"><h3 class="resource-heading">Players <a href="#players-players" class="permalink"> ¶</a></h3><div id="players-players-get" class="action get"><h4 class="action-heading"><div class="name">Player statistics</div><a href="#players-players-get" class="method get">GET</a><code class="uri">/games/{game}/players/{player}?project={project}</code></h4><p>Get player information. Note, that it is only necessary to call this API endpoint at a session start - to check if the player exists and if yes, what is the player status.
During a game session all the information can be acquired from the response of the classification submit call.</p>
<h4>Example URI</h4><div class="definition"><span class="method get">GET</span> <span class="uri"><span class="hostname">https://api.depo.mmos.blue</span>/games/<span class="hljs-attribute" title="game">:gameCode</span>/players/<span class="hljs-attribute" title="player">:playerCode</span>?project=<span class="hljs-attribute" title="project">:projectCode</span></span></div><div class="title"><strong>URI Parameters</strong><div class="collapse-button show"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><dl class="inner"><dt>game</dt><dd><code>string</code> <span class="required">(required)</span> <span class="text-muted example"><strong>Example: </strong><span>:gameCode</span></span><p>Game code</p>
</dd><dt>player</dt><dd><code>string</code> <span class="required">(required)</span> <span class="text-muted example"><strong>Example: </strong><span>:playerCode</span></span><p>Player code</p>
</dd><dt>project</dt><dd><code>string</code> <span>(optional)</span> <span class="text-muted example"><strong>Example: </strong><span>:projectCode</span></span><p>Project code</p>
</dd></dl></div><div class="title"><strong>Response <code>200</code></strong><div class="collapse-button"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><div class="inner"><h5>Headers</h5><pre><code><span class="hljs-attribute">Content-Type</span>: <span class="hljs-string">application/json; charset=utf-8</span></code></pre><div style="height: 1px;"></div><h5>Body</h5><pre><code>{
"<span class="hljs-attribute">uid</span>": <span class="hljs-value"><span class="hljs-string">"1495414829916-418db7e7-36fa-4f93-b540-58705a39daf3"</span></span>,
"<span class="hljs-attribute">game</span>": <span class="hljs-value"><span class="hljs-string">":gameCode"</span></span>,
"<span class="hljs-attribute">player</span>": <span class="hljs-value"><span class="hljs-string">":playerCode"</span></span>,
"<span class="hljs-attribute">createdAt</span>": <span class="hljs-value"><span class="hljs-string">"2018-11-30T10:22:04.000Z"</span></span>,
"<span class="hljs-attribute">project</span>": <span class="hljs-value">{
"<span class="hljs-attribute">code</span>": <span class="hljs-value"><span class="hljs-string">":projectCode"</span></span>,
"<span class="hljs-attribute">classificationCount</span>": <span class="hljs-value"><span class="hljs-number">1</span></span>,
"<span class="hljs-attribute">score</span>": <span class="hljs-value"><span class="hljs-number">0.487171</span></span>,
"<span class="hljs-attribute">reliability</span>": <span class="hljs-value"><span class="hljs-number">0.5091714453488716</span>
</span>}
</span>}</code></pre><div style="height: 1px;"></div><h5>Schema</h5><pre><code>{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"object"</span></span>,
"<span class="hljs-attribute">required</span>": <span class="hljs-value">[
<span class="hljs-string">"uid"</span>,
<span class="hljs-string">"game"</span>,
<span class="hljs-string">"player"</span>
]</span>,
"<span class="hljs-attribute">additionalProperties</span>": <span class="hljs-value"><span class="hljs-literal">false</span></span>,
"<span class="hljs-attribute">properties</span>": <span class="hljs-value">{
"<span class="hljs-attribute">uid</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"The unique identifier of the request"</span>
</span>}</span>,
"<span class="hljs-attribute">game</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Game code"</span>
</span>}</span>,
"<span class="hljs-attribute">player</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Player code"</span>
</span>}</span>,
"<span class="hljs-attribute">createdAt</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Player creation datetime"</span>
</span>}</span>,
"<span class="hljs-attribute">project</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"object"</span></span>,
"<span class="hljs-attribute">required</span>": <span class="hljs-value">[
<span class="hljs-string">"code"</span>,
<span class="hljs-string">"classificationCount"</span>,
<span class="hljs-string">"score"</span>,
<span class="hljs-string">"reliability"</span>
]</span>,
"<span class="hljs-attribute">additionalProperties</span>": <span class="hljs-value"><span class="hljs-literal">false</span></span>,
"<span class="hljs-attribute">properties</span>": <span class="hljs-value">{
"<span class="hljs-attribute">code</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Project code"</span>
</span>}</span>,
"<span class="hljs-attribute">classificationCount</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"integer"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Number of classifications submitted by player to project"</span>
</span>}</span>,
"<span class="hljs-attribute">score</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"number"</span></span>,
"<span class="hljs-attribute">minimum</span>": <span class="hljs-value"><span class="hljs-number">0</span></span>,
"<span class="hljs-attribute">maximum</span>": <span class="hljs-value"><span class="hljs-number">1</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Accuracy score of user in project"</span>
</span>}</span>,
"<span class="hljs-attribute">reliability</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"number"</span></span>,
"<span class="hljs-attribute">minimum</span>": <span class="hljs-value"><span class="hljs-number">0</span></span>,
"<span class="hljs-attribute">maximum</span>": <span class="hljs-value"><span class="hljs-number">1</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Accuracy score reliability"</span>
</span>}
</span>}
</span>}
</span>}
</span>}</code></pre><div style="height: 1px;"></div></div></div></div></div></section><section id="classifications" class="resource-group"><h2 class="group-heading">Classifications <a href="#classifications" class="permalink">¶</a></h2><div id="classifications-classifications" class="resource"><h3 class="resource-heading">Classifications <a href="#classifications-classifications" class="permalink"> ¶</a></h3><div id="classifications-classifications-post" class="action post"><h4 class="action-heading"><div class="name">Create a Classification</div><a href="#classifications-classifications-post" class="method post">POST</a><code class="uri">/classifications</code></h4><p><em>Result object in training set classification request:</em></p>
<p>It should be an array of strings representing phylogenetic classification like:
<em>[ “kingdom”,“phylum”,“class”,“sublcass”,“superorder”,“order”,“suborder”,
“superfamily”,“family”,“subfamily”,“tribe”,“genus”,“taxon_name”,“url”,“taxon_common_name” ]</em></p>
<pre><code>{
"<span class="hljs-attribute">game</span>": <span class="hljs-value"><span class="hljs-string">":gameCode"</span></span>,
"<span class="hljs-attribute">task</span>": <span class="hljs-value">{
"<span class="hljs-attribute">id</span>": <span class="hljs-value"><span class="hljs-number">10000026</span></span>,
"<span class="hljs-attribute">result</span>": <span class="hljs-value">[
<span class="hljs-string">"Animalia"</span>,
<span class="hljs-string">"Chordata"</span>,
<span class="hljs-string">"Mammalia"</span>,
<span class="hljs-string">"Laurasiatheria"</span>,
<span class="hljs-string">"Chiroptera"</span>,
<span class="hljs-string">"Yinpterochiroptera"</span>,
<span class="hljs-string">"Pteropodidea"</span>,
<span class="hljs-string">"Pteropodidae"</span>,
<span class="hljs-string">"Pteropodinae"</span>,
<span class="hljs-string">""</span>,
<span class="hljs-string">"Pteropus"</span>,
<span class="hljs-string">"Pteropus rufus"</span>,
<span class="hljs-string">"https://www.inaturalist.org/listed_taxa/2887488"</span>,
<span class="hljs-string">"Madagascan Flying Fox"</span>
]
</span>}</span>,
"<span class="hljs-attribute">circumstances</span>": <span class="hljs-value">{
"<span class="hljs-attribute">t</span>": <span class="hljs-value"><span class="hljs-number">1</span>
</span>}</span>,
"<span class="hljs-attribute">player</span>": <span class="hljs-value"><span class="hljs-string">":playerCode"</span></span>,
"<span class="hljs-attribute">playergroup</span>": <span class="hljs-value"><span class="hljs-literal">null</span>
</span>}</code></pre>
<h4>Example URI</h4><div class="definition"><span class="method post">POST</span> <span class="uri"><span class="hostname">https://api.depo.mmos.blue</span>/classifications</span></div><div class="title"><strong>Request</strong><div class="collapse-button"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><div class="inner"><h5>Headers</h5><pre><code><span class="hljs-attribute">Content-Type</span>: <span class="hljs-string">application/json; charset=utf-8</span></code></pre><div style="height: 1px;"></div><h5>Body</h5><pre><code>{
"<span class="hljs-attribute">game</span>": <span class="hljs-value"><span class="hljs-string">":gameCode"</span></span>,
"<span class="hljs-attribute">player</span>": <span class="hljs-value"><span class="hljs-string">":playerCode"</span></span>,
"<span class="hljs-attribute">playergroup</span>": <span class="hljs-value"><span class="hljs-string">"group123"</span></span>,
"<span class="hljs-attribute">task</span>": <span class="hljs-value">{
"<span class="hljs-attribute">id</span>": <span class="hljs-value"><span class="hljs-number">10000000</span></span>,
"<span class="hljs-attribute">result</span>": <span class="hljs-value">[
<span class="hljs-string">"Animalia"</span>,
<span class="hljs-string">"Chordata"</span>,
<span class="hljs-string">"Mammalia"</span>,
<span class="hljs-string">"Laurasiatheria"</span>,
<span class="hljs-string">"Chiroptera"</span>,
<span class="hljs-string">"Yinpterochiroptera"</span>,
<span class="hljs-string">"Pteropodidea"</span>,
<span class="hljs-string">"Pteropodidae"</span>,
<span class="hljs-string">"Pteropodinae"</span>,
<span class="hljs-string">""</span>,
<span class="hljs-string">"Pteropus"</span>,
<span class="hljs-string">"Pteropus rufus"</span>,
<span class="hljs-string">"https://www.inaturalist.org/listed_taxa/2887488"</span>,
<span class="hljs-string">"Madagascan Flying Fox"</span>
]
</span>}</span>,
"<span class="hljs-attribute">circumstances</span>": <span class="hljs-value">{
"<span class="hljs-attribute">t</span>": <span class="hljs-value"><span class="hljs-number">6000</span>
</span>}
</span>}</code></pre><div style="height: 1px;"></div><h5>Schema</h5><pre><code>{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"object"</span></span>,
"<span class="hljs-attribute">required</span>": <span class="hljs-value">[
<span class="hljs-string">"game"</span>,
<span class="hljs-string">"player"</span>,
<span class="hljs-string">"playergroup"</span>,
<span class="hljs-string">"task"</span>,
<span class="hljs-string">"circumstances"</span>
]</span>,
"<span class="hljs-attribute">additionalProperties</span>": <span class="hljs-value"><span class="hljs-literal">false</span></span>,
"<span class="hljs-attribute">properties</span>": <span class="hljs-value">{
"<span class="hljs-attribute">game</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Game code"</span>
</span>}</span>,
"<span class="hljs-attribute">player</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Player code"</span>
</span>}</span>,
"<span class="hljs-attribute">playergroup</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value">[
<span class="hljs-string">"string"</span>,
<span class="hljs-string">"null"</span>
]</span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Playergroup code"</span>
</span>}</span>,
"<span class="hljs-attribute">task</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"object"</span></span>,
"<span class="hljs-attribute">required</span>": <span class="hljs-value">[
<span class="hljs-string">"id"</span>,
<span class="hljs-string">"result"</span>
]</span>,
"<span class="hljs-attribute">additionalProperties</span>": <span class="hljs-value"><span class="hljs-literal">false</span></span>,
"<span class="hljs-attribute">properties</span>": <span class="hljs-value">{
"<span class="hljs-attribute">id</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"integer"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"The id given by MMOS for the game client"</span>
</span>}</span>,
"<span class="hljs-attribute">result</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"object"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"The result specified by the task type / project"</span>
</span>}
</span>}
</span>}</span>,
"<span class="hljs-attribute">circumstances</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"object"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"All the circumstantial data of the classification"</span>
</span>}
</span>}
</span>}</code></pre><div style="height: 1px;"></div></div></div><div class="title"><strong>Response <code>201</code></strong><div class="collapse-button"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><div class="inner"><h5>Headers</h5><pre><code><span class="hljs-attribute">Content-Type</span>: <span class="hljs-string">application/json; charset=utf-8</span></code></pre><div style="height: 1px;"></div><h5>Body</h5><pre><code>{
"<span class="hljs-attribute">uid</span>": <span class="hljs-value"><span class="hljs-string">"c1586e99-f42a-4fb3-a652-6dd5aae6ae89-1547835077841"</span></span>,
"<span class="hljs-attribute">score</span>": <span class="hljs-value"><span class="hljs-number">0.69263</span></span>,
"<span class="hljs-attribute">reliability</span>": <span class="hljs-value"><span class="hljs-number">0.5132984967884329</span></span>,
"<span class="hljs-attribute">info</span>": <span class="hljs-value">{}</span>,
"<span class="hljs-attribute">task</span>": <span class="hljs-value">{
"<span class="hljs-attribute">id</span>": <span class="hljs-value"><span class="hljs-number">10000010</span></span>,
"<span class="hljs-attribute">project</span>": <span class="hljs-value"><span class="hljs-string">":projectCode"</span></span>,
"<span class="hljs-attribute">isTrainingSet</span>": <span class="hljs-value"><span class="hljs-literal">false</span></span>,
"<span class="hljs-attribute">classificationCount</span>": <span class="hljs-value"><span class="hljs-number">4</span></span>,
"<span class="hljs-attribute">voteInfo</span>": <span class="hljs-value">{}</span>,
"<span class="hljs-attribute">votes</span>": <span class="hljs-value">{}
</span>}</span>,
"<span class="hljs-attribute">game</span>": <span class="hljs-value"><span class="hljs-string">":gameCode"</span></span>,
"<span class="hljs-attribute">player</span>": <span class="hljs-value">{
"<span class="hljs-attribute">code</span>": <span class="hljs-value"><span class="hljs-string">":playerCode"</span></span>,
"<span class="hljs-attribute">score</span>": <span class="hljs-value"><span class="hljs-number">0.69263</span>
</span>}
</span>}</code></pre><div style="height: 1px;"></div><h5>Schema</h5><pre><code>{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"object"</span></span>,
"<span class="hljs-attribute">required</span>": <span class="hljs-value">[
<span class="hljs-string">"uid"</span>,
<span class="hljs-string">"score"</span>,
<span class="hljs-string">"reliability"</span>,
<span class="hljs-string">"task"</span>,
<span class="hljs-string">"game"</span>,
<span class="hljs-string">"player"</span>
]</span>,
"<span class="hljs-attribute">additionalProperties</span>": <span class="hljs-value"><span class="hljs-literal">false</span></span>,
"<span class="hljs-attribute">properties</span>": <span class="hljs-value">{
"<span class="hljs-attribute">uid</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"The unique identifier of the request"</span>
</span>}</span>,
"<span class="hljs-attribute">score</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"number"</span></span>,
"<span class="hljs-attribute">minimum</span>": <span class="hljs-value"><span class="hljs-number">0</span></span>,
"<span class="hljs-attribute">maximum</span>": <span class="hljs-value"><span class="hljs-number">1</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Accuracy score of classification"</span>
</span>}</span>,
"<span class="hljs-attribute">reliability</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"number"</span></span>,
"<span class="hljs-attribute">minimum</span>": <span class="hljs-value"><span class="hljs-number">0</span></span>,
"<span class="hljs-attribute">maximum</span>": <span class="hljs-value"><span class="hljs-number">1</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Accuracy score reliability"</span>
</span>}</span>,
"<span class="hljs-attribute">info</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"object"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Information about evaluation"</span>
</span>}</span>,
"<span class="hljs-attribute">task</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"object"</span></span>,
"<span class="hljs-attribute">required</span>": <span class="hljs-value">[
<span class="hljs-string">"id"</span>,
<span class="hljs-string">"project"</span>,
<span class="hljs-string">"isTrainingSet"</span>,
<span class="hljs-string">"classificationCount"</span>
]</span>,
"<span class="hljs-attribute">additionalProperties</span>": <span class="hljs-value"><span class="hljs-literal">false</span></span>,
"<span class="hljs-attribute">properties</span>": <span class="hljs-value">{
"<span class="hljs-attribute">id</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"integer"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Tha task id"</span>
</span>}</span>,
"<span class="hljs-attribute">project</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"The project code"</span>
</span>}</span>,
"<span class="hljs-attribute">isTrainingSet</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"boolean"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Whether the task is a gold standard task"</span>
</span>}</span>,
"<span class="hljs-attribute">classificationCount</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"integer"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"The number of classifications submitted to the task"</span>
</span>}</span>,
"<span class="hljs-attribute">solution</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"object"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"The solution of the gold standard task"</span>
</span>}</span>,
"<span class="hljs-attribute">voteInfo</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"object"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Information about the community consensus"</span>
</span>}</span>,
"<span class="hljs-attribute">votes</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"object"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Tha community votes"</span>
</span>}
</span>}
</span>}</span>,
"<span class="hljs-attribute">game</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Game code"</span>
</span>}</span>,
"<span class="hljs-attribute">player</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"object"</span></span>,
"<span class="hljs-attribute">required</span>": <span class="hljs-value">[
<span class="hljs-string">"code"</span>,
<span class="hljs-string">"score"</span>
]</span>,
"<span class="hljs-attribute">additionalProperties</span>": <span class="hljs-value"><span class="hljs-literal">false</span></span>,
"<span class="hljs-attribute">properties</span>": <span class="hljs-value">{
"<span class="hljs-attribute">code</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Player code"</span>
</span>}</span>,
"<span class="hljs-attribute">score</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"number"</span></span>,
"<span class="hljs-attribute">minimum</span>": <span class="hljs-value"><span class="hljs-number">0</span></span>,
"<span class="hljs-attribute">maximum</span>": <span class="hljs-value"><span class="hljs-number">1</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">"Accuracy score of the player"</span>
</span>}</span>,
"<span class="hljs-attribute">scoreChange</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"number"</span></span>,
"<span class="hljs-attribute">minimum</span>": <span class="hljs-value"><span class="hljs-number">0</span></span>,
"<span class="hljs-attribute">maximum</span>": <span class="hljs-value"><span class="hljs-number">1</span></span>,
"<span class="hljs-attribute">description</span>": <span class="hljs-value"><span class="hljs-string">""</span>
</span>}</span>,
"<span class="hljs-attribute">scoredAt</span>": <span class="hljs-value">{
"<span class="hljs-attribute">type</span>": <span class="hljs-value"><span class="hljs-string">"string"</span>
</span>}
</span>}
</span>}
</span>}
</span>}</code></pre><div style="height: 1px;"></div></div></div></div></div></section></div></div></div><p style="text-align: center;" class="text-muted">Generated by <a href="https://github.com/danielgtaylor/aglio" class="aglio">aglio</a> on 16 Jul 2019</p><script>/* eslint-env browser */
/* eslint quotes: [2, "single"] */
'use strict';
/*
Determine if a string ends with another string.
*/
function endsWith(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}
/*
Get a list of direct child elements by class name.
*/
function childrenByClass(element, name) {
var filtered = [];
for (var i = 0; i < element.children.length; i++) {
var child = element.children[i];
var classNames = child.className.split(' ');
if (classNames.indexOf(name) !== -1) {
filtered.push(child);
}
}
return filtered;
}
/*
Get an array [width, height] of the window.
*/
function getWindowDimensions() {
var w = window,
d = document,
e = d.documentElement,
g = d.body,
x = w.innerWidth || e.clientWidth || g.clientWidth,
y = w.innerHeight || e.clientHeight || g.clientHeight;
return [x, y];
}
/*
Collapse or show a request/response example.
*/
function toggleCollapseButton(event) {
var button = event.target.parentNode;
var content = button.parentNode.nextSibling;
var inner = content.children[0];
if (button.className.indexOf('collapse-button') === -1) {
// Clicked without hitting the right element?
return;
}
if (content.style.maxHeight && content.style.maxHeight !== '0px') {
// Currently showing, so let's hide it
button.className = 'collapse-button';
content.style.maxHeight = '0px';
} else {
// Currently hidden, so let's show it
button.className = 'collapse-button show';
content.style.maxHeight = inner.offsetHeight + 12 + 'px';
}
}
function toggleTabButton(event) {
var i, index;
var button = event.target;
// Get index of the current button.
var buttons = childrenByClass(button.parentNode, 'tab-button');
for (i = 0; i < buttons.length; i++) {
if (buttons[i] === button) {
index = i;
button.className = 'tab-button active';
} else {
buttons[i].className = 'tab-button';
}
}
// Hide other tabs and show this one.
var tabs = childrenByClass(button.parentNode.parentNode, 'tab');
for (i = 0; i < tabs.length; i++) {
if (i === index) {
tabs[i].style.display = 'block';
} else {
tabs[i].style.display = 'none';
}
}
}
/*
Collapse or show a navigation menu. It will not be hidden unless it
is currently selected or `force` has been passed.
*/
function toggleCollapseNav(event, force) {
var heading = event.target.parentNode;
var content = heading.nextSibling;
var inner = content.children[0];
if (heading.className.indexOf('heading') === -1) {
// Clicked without hitting the right element?
return;
}
if (content.style.maxHeight && content.style.maxHeight !== '0px') {
// Currently showing, so let's hide it, but only if this nav item
// is already selected. This prevents newly selected items from
// collapsing in an annoying fashion.
if (force || window.location.hash && endsWith(event.target.href, window.location.hash)) {
content.style.maxHeight = '0px';
}
} else {
// Currently hidden, so let's show it
content.style.maxHeight = inner.offsetHeight + 12 + 'px';
}
}
/*
Refresh the page after a live update from the server. This only
works in live preview mode (using the `--server` parameter).
*/
function refresh(body) {
document.querySelector('body').className = 'preload';
document.body.innerHTML = body;
// Re-initialize the page
init();
autoCollapse();
document.querySelector('body').className = '';
}
/*
Determine which navigation items should be auto-collapsed to show as many
as possible on the screen, based on the current window height. This also
collapses them.
*/
function autoCollapse() {
var windowHeight = getWindowDimensions()[1];
var itemsHeight = 64; /* Account for some padding */
var itemsArray = Array.prototype.slice.call(
document.querySelectorAll('nav .resource-group .heading'));
// Get the total height of the navigation items
itemsArray.forEach(function (item) {
itemsHeight += item.parentNode.offsetHeight;
});
// Should we auto-collapse any nav items? Try to find the smallest item
// that can be collapsed to show all items on the screen. If not possible,
// then collapse the largest item and do it again. First, sort the items
// by height from smallest to largest.
var sortedItems = itemsArray.sort(function (a, b) {
return a.parentNode.offsetHeight - b.parentNode.offsetHeight;
});
while (sortedItems.length && itemsHeight > windowHeight) {
for (var i = 0; i < sortedItems.length; i++) {
// Will collapsing this item help?
var itemHeight = sortedItems[i].nextSibling.offsetHeight;
if ((itemsHeight - itemHeight <= windowHeight) || i === sortedItems.length - 1) {
// It will, so let's collapse it, remove its content height from
// our total and then remove it from our list of candidates
// that can be collapsed.
itemsHeight -= itemHeight;
toggleCollapseNav({target: sortedItems[i].children[0]}, true);
sortedItems.splice(i, 1);
break;
}
}
}
}
/*
Initialize the interactive functionality of the page.
*/
function init() {
var i, j;
// Make collapse buttons clickable
var buttons = document.querySelectorAll('.collapse-button');
for (i = 0; i < buttons.length; i++) {
buttons[i].onclick = toggleCollapseButton;
// Show by default? Then toggle now.
if (buttons[i].className.indexOf('show') !== -1) {
toggleCollapseButton({target: buttons[i].children[0]});
}
}
var responseCodes = document.querySelectorAll('.example-names');
for (i = 0; i < responseCodes.length; i++) {
var tabButtons = childrenByClass(responseCodes[i], 'tab-button');
for (j = 0; j < tabButtons.length; j++) {
tabButtons[j].onclick = toggleTabButton;
// Show by default?
if (j === 0) {
toggleTabButton({target: tabButtons[j]});
}
}
}
// Make nav items clickable to collapse/expand their content.
var navItems = document.querySelectorAll('nav .resource-group .heading');
for (i = 0; i < navItems.length; i++) {
navItems[i].onclick = toggleCollapseNav;
// Show all by default
toggleCollapseNav({target: navItems[i].children[0]});
}
}
// Initial call to set up buttons
init();
window.onload = function () {
autoCollapse();
// Remove the `preload` class to enable animations
document.querySelector('body').className = '';
};
</script></body></html>