-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
2174 lines (2103 loc) · 97 KB
/
index.php
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
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<title>OpenSensorData.net</title>
<link rel="stylesheet" type="text/css" href="opensensordata.css">
</head>
<body>
<div class="screen">
<div class="maketitle">
<h2 class="titleHead">OpenSensorData.net</h2>
<div class="author" ></div><br />
<div class="date" ></div>
</div>
<p> OpenSensorData.net is a hosting service where you can store streams of data
that come from any sensor or sensor networks. The use of OpenSensorData.net is
free (like in <span
class="cmti-12">free beer</span>). And the software is Free (like in <span
class="cmti-12">freedom</span>), under the
<a
href="http://www.gnu.org/licenses/gpl.html" >GPLv3</a>. You can <a
href="https://github.com/hanappe/opensensordata.net" >download the code</a> and install it on your own servers
(requirements: Apache/PHP/MySQL).
</p>
<h3 class="likesectionHead"><a
id="x1-1000"></a>Storing your data on OpenSensorData.net</h3>
<p>
</p>
<ol class="enumerate1" >
<li
class="enumerate" id="x1-1002x1">First you must <a
href="#x1-2000doc">know your rights</a>.
</li>
<li
class="enumerate" id="x1-1004x2">Then you must create an account at
<a
href="http://opensensordata.net/createaccount.php" class="url" ><span
class="cmtt-12">http://opensensordata.net/createaccount.php</span></a>
</li>
<li
class="enumerate" id="x1-1006x3">The account creation will generate an API key. Write it down. You will
need it to access the services.
</li>
<li
class="enumerate" id="x1-1008x4">Make sure you understand <a
href="#x1-3000doc">the basic concepts</a>.
</li>
<li
class="enumerate" id="x1-1010x5"><a
href="#x1-4000doc">Define your datastreams and groups of datastreams</a>.
</li>
<li
class="enumerate" id="x1-1012x6"><a
href="#x1-6000doc">Upload your data</a>.
</li>
<li
class="enumerate" id="x1-1014x7"><a
href="#x1-9000doc">Download your data</a>.
</li>
<li
class="enumerate" id="x1-1016x8"><a
href="#x1-10000doc">View your data</a>.
</li></ol>
<p>
</p>
<h4 class="likesubsectionHead"><a
id="x1-2000"></a>Know your rights</h4>
<a
id="x1-2000doc"></a>
<p>The first thing that is important to know is that we store all the data that
you upload to OpenSensorData.net (that’s what it’s for) AND that we
make all of this data freely available to any one under the Open Database
License. The full text of the Open Database License can be found at
<a
href="http://opendatacommons.org/licenses/odbl/" class="url" ><span
class="cmtt-12">http://opendatacommons.org/licenses/odbl/</span></a>. Any rights in individual
contents of the database are licensed under the Database Contents License whose
text can be found <a
href="http://opendatacommons.org/licenses/dbcl/" class="url" ><span
class="cmtt-12">http://opendatacommons.org/licenses/dbcl/</span></a>. If you find
it difficult to comply with this, then you should set up your own data
servers.
</p>
<p> The second important thing is that at any time you can ask us to remove ALL
of the data associated with your account. We will make it possible for you to do
this yourself in the future. For now, however, you have to send your request by
email to the following address: someone AT opensensordata.net.
</p>
<p> The source code of OpenSensorData.net is available under <a
href="http://www.gnu.org/licenses/gpl.html" >version 3 of the
GNU General Public License</a>. That means you can use, study, and modify it, and
that you redistribute modified copies of the source code. The lastest version of the
code is available <a
href="latest.tar.gz" >here</a>.
</p>
<p>
</p>
<h4 class="likesubsectionHead"><a
id="x1-3000"></a>The basic concepts</h4>
<a
id="x1-3000doc"></a>
<p>A <b><span
class="cmbx-12">datapoint</span></b> consists of the time at which the measurement took place and its
output value. For example, on Sunday, March 3rd 2013, at 11.55 am, the
temperature sensor at my home measured 8.63 degrees celsius. The data point
consists of the date (2013-03-10 11:55:00, for the precise format of the date, see
details below), and its value (8.63).
</p>
<p> A <b><span
class="cmbx-12">datastream</span></b> is a series of datapoints. To add a datapoint to a datastream,
you must first create the datastream. The minimum information you have to
specify is a name, but a longer discription is welcome to. In addition, you can add
information such as the geographical location of the sensor, and the timezone in
which it is situated. All datastreams have a number that uniquely identifies it. To
add a datapoint you must specify the datastream in which you want to insert it.
You can pass along the datastream id, but there are other ways too (see <a
href="#x1-6000doc">“Upload
your data”</a>).
</p>
<p> A <b><span
class="cmbx-12">group</span></b> is a set of datastreams that you would like to keep together. Nearly
all sensor boxes or data loggers will generate several datastreams and it obvious
that you want to work with these datastreams together. Groups are flexible and it
is also possible to create a group to bundle datastreams from different locations
and from different users.
</p>
<p> The creation of datastreams and groups is handled in the <a
href="#x1-4000doc">next section</a>.
</p>
<p>
</p>
<h4 class="likesubsectionHead"><a
id="x1-4000"></a>Define your datastreams and groups of datastreams</h4>
<a
id="x1-4000doc"></a>
<p>In most cases, you will not have to create groups and datastreams yourself. If the
sensor box that user OpenSensorData is well designed, you should only provide
the API key and a group name, and the device or software will create the group
and its datastreams automagically.
</p>
<p> In the short future, we will provide a online editor to manipulate groups and
datastreams, however.
</p>
<p> To create a groups and its datastreams, you must send a JSON description to
the server over HTTP. Note that you must always specify the API kay in the
X-OpenSensorData-Key header. The group definition contains a name and a
description. A name can only be used once per account to label a group. So if I
have a sensor box and it uses group name ’greenhouse’, if I install a second
greenhouse I will have to choose another name.
</p>
<p> The set of datagroups are coded in a JSON array, and for each you must
provide its name and description. The datagroups will be automatically created
for you.
</p>
<p> The following example shows the complete HTTP request, with the
headers, following by and empty line, and then the JSON description in the
body.
</p>
<p> <div class="verbatim">
<span
class="cmtt-12">PUT</span><span
class="cmtt-12"> http://opensensordata.net/groups/</span><span
class="cmtt-12"> HTTP/1.1</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">Host:</span><span
class="cmtt-12"> opensensordata.net</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">Content-Type:</span><span
class="cmtt-12"> application/json</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">Content-Length:</span><span
class="cmtt-12"> 100000</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">X-OpenSensorData-Key:</span><span
class="cmtt-12"> 12345678-xxxx-yyyy-zzzz-123456789012</span>
<span
class="cmtt-12"> </span><br />
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">{</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "name":</span><span
class="cmtt-12"> "greenhouse",</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "description":</span><span
class="cmtt-12"> "The</span><span
class="cmtt-12"> sensorbox</span><span
class="cmtt-12"> of</span><span
class="cmtt-12"> the</span><span
class="cmtt-12"> greenhouse</span><span
class="cmtt-12"> on</span><span
class="cmtt-12"> my</span><span
class="cmtt-12"> terrace",</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "datastreams":</span><span
class="cmtt-12"> [</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> {</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "name":</span><span
class="cmtt-12"> "temperature",</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "description":</span><span
class="cmtt-12"> "Temperature"</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> },</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> {</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "name":</span><span
class="cmtt-12"> "Humidity",</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "description":</span><span
class="cmtt-12"> "Humidity"</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> }</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> ]</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">}</span>
</p>
<p></div>
</p>
<p> A simple way to create the group, is to use telnet, connect to opensensordata.net
on port 80, and then copy/paste the example above.
</p>
<p> It is possible to add geolocation data to the datastream description. This
allows the datastream to be positioned on a map. two extra fields are used, the
longitude and latitude. You can specify a timezone. This can be useful for devices
without a real-time clock. Lastly, you can specify a the unit in which the value is
measured. For a complete list of currently supported units, see <a
href="#units" >the list at the end
of the documentation</a>.
</p>
<p> <div class="verbatim">
<span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> ...</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "datastreams":</span><span
class="cmtt-12"> [</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> {</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "name":</span><span
class="cmtt-12"> "temperature",</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "description":</span><span
class="cmtt-12"> "Temperature"</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "longitude":</span><span
class="cmtt-12"> "2.363471",</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "latitude":</span><span
class="cmtt-12"> "48.917536",</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "timezone":</span><span
class="cmtt-12"> "+1",</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "unit":</span><span
class="cmtt-12"> "Celsius"</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> },</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> ...</span>
</p>
<p></div>
</p>
<p> All the error handling in OpenSensorData.net is handled through the <a
href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html" >HTTP
status codes</a>. This makes it easier to communicate to the server in scripts. Status
code 200 indicates that the request was handled successfully. Pretty much
anything else will indicate an error. The body of the response will then contain a
simple plain text error message.
</p>
<p> If all goes well, the request above should have returned:
</p>
<p> <div class="verbatim">
<span
class="cmtt-12">HTTP/1.1</span><span
class="cmtt-12"> 200</span><span
class="cmtt-12"> OK</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">Content-Length:</span><span
class="cmtt-12"> xxx</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">Content-Type:</span><span
class="cmtt-12"> text/html</span>
<span
class="cmtt-12"> </span><br />
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">{</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "id":</span><span
class="cmtt-12"> "387",</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "name":</span><span
class="cmtt-12"> "greenhouse",</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "description":</span><span
class="cmtt-12"> "The</span><span
class="cmtt-12"> sensorbox</span><span
class="cmtt-12"> of</span><span
class="cmtt-12"> the</span><span
class="cmtt-12"> greenhouse</span><span
class="cmtt-12"> on</span><span
class="cmtt-12"> my</span><span
class="cmtt-12"> terrace",</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "datastreams":</span><span
class="cmtt-12"> [</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> {</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "id":</span><span
class="cmtt-12"> "9347",</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "name":</span><span
class="cmtt-12"> "temperature",</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "description":</span><span
class="cmtt-12"> "Temperature"</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> },</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> {</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "id":</span><span
class="cmtt-12"> "9348",</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "name":</span><span
class="cmtt-12"> "Humidity",</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "description":</span><span
class="cmtt-12"> "Humidity"</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> }</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> ]</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">}</span>
</p>
<p></div>
</p>
<p> As you can see, the server returns the same JSON structure, but with an
additional ID field for the group and the new datastreams. These IDs uniquely
define the objects and can be used in other requests, to <a
href="#x1-6000doc">upload data</a>, for
example.
</p>
<p> Variations of the PUT request can be used to modify the definition of an
existing group. To update a group, or datastream, you must explicitely specify the
IDs. In result of the following request, the name of the group will be changed from
’greenhouse’ to ’SmallGreenhouse’. Note that no definition of the datastreams is
given. As a result, no changes to the set of datastreams of the group will be made.
The server response will contain the complete description of the group in JSON,
like above.
</p>
<p> <div class="verbatim">
<span
class="cmtt-12">PUT</span><span
class="cmtt-12"> http://opensensordata.net/groups/</span><span
class="cmtt-12"> HTTP/1.1</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">Host:</span><span
class="cmtt-12"> opensensordata.net</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">Content-Type:</span><span
class="cmtt-12"> application/json</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">Content-Length:</span><span
class="cmtt-12"> 100000</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">X-OpenSensorData-Key:</span><span
class="cmtt-12"> 12345678-xxxx-yyyy-zzzz-123456789012</span>
<span
class="cmtt-12"> </span><br />
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">{</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "id":</span><span
class="cmtt-12"> "387",</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "name":</span><span
class="cmtt-12"> "SmallGreenhouse",</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">}</span>
</p>
<p></div>
</p>
<p> Had we given a description of the group’s datstreams, then these would have
been updated, too. For example, you can remove all the datastreams from the
group using the request below, in which the datastreams field is explicitely set to
an empty array. The datastreams themselves will not be deleted. They will simply
be dissociated from the group.
</p>
<p> <div class="verbatim">
<span
class="cmtt-12">PUT</span><span
class="cmtt-12"> http://opensensordata.net/groups/</span><span
class="cmtt-12"> HTTP/1.1</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">Host:</span><span
class="cmtt-12"> opensensordata.net</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">Content-Type:</span><span
class="cmtt-12"> application/json</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">Content-Length:</span><span
class="cmtt-12"> 100000</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">X-OpenSensorData-Key:</span><span
class="cmtt-12"> 12345678-xxxx-yyyy-zzzz-123456789012</span>
<span
class="cmtt-12"> </span><br />
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">{</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "id":</span><span
class="cmtt-12"> "387",</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "name":</span><span
class="cmtt-12"> "greenhouse",</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "description":</span><span
class="cmtt-12"> "The</span><span
class="cmtt-12"> sensorbox</span><span
class="cmtt-12"> of</span><span
class="cmtt-12"> the</span><span
class="cmtt-12"> greenhouse</span><span
class="cmtt-12"> on</span><span
class="cmtt-12"> my</span><span
class="cmtt-12"> terrace",</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "datastreams":</span><span
class="cmtt-12"> []</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">}</span>
</p>
<p></div>
</p>
<p>
</p>
<h5 class="likesubsubsectionHead"><a
id="x1-5000"></a>Define your datastreams directly</h5>
<a
id="x1-5000doc"></a>
<p>It is not necessary to create a group to create datastreams. Datastreams can be
created directly using a PUT request similar to the one for groups. The URL to
which you must send your request is http://opensensordata.net/datastreams/.
Here’s an example:
</p>
<p> <div class="verbatim">
<span
class="cmtt-12">PUT</span><span
class="cmtt-12"> http://opensensordata.net/datastreams/</span><span
class="cmtt-12"> HTTP/1.1</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">Host:</span><span
class="cmtt-12"> opensensordata.net</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">Content-Type:</span><span
class="cmtt-12"> application/json</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">Content-Length:</span><span
class="cmtt-12"> 100000</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">X-OpenSensorData-Key:</span><span
class="cmtt-12"> 12345678-xxxx-yyyy-zzzz-123456789012</span>
<span
class="cmtt-12"> </span><br />
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">{</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "name":</span><span
class="cmtt-12"> "temperature-4",</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "description":</span><span
class="cmtt-12"> "Temperature",</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "longitude":</span><span
class="cmtt-12"> "2.363471",</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "latitude":</span><span
class="cmtt-12"> "48.917536",</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> "timezone":</span><span
class="cmtt-12"> "+1"</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">}</span>
</p>
<p></div>
</p>
<p> The name of the datastream is unique for every user, i.e.. a user X can
only create one datastream called Y. The response of the request above
will return the JSON description of the new datastream, including its
unique, global ID number. When the datastream is created, any follow-up
PUT request will update the description of the datastream, except its
ID.
</p>
<p>
</p>
<h4 class="likesubsectionHead"><a
id="x1-6000"></a>Upload your data</h4>
<a
id="x1-6000doc"></a>
<p>You can upload a set of datapoints through the following URL:
http://opensensordata.net/upload. The upload interface is designed to accept
many datapoints that have been produced by a sensor device and that are
uploaded through software, not by humans manually.
</p>
<p> To upload data, you must send an HTTP POST request to
http://opensensordata.net/upload, with all the datapoints in the body of the
request. The format of the datapoints is the CSV file format (Comma Separated
Values). This is a textual file format in which each line represents one datapoint.
Each line should contain at least three fields: the ID of the datastream, the date,
and the sensor value. All field values of the datapoint are separated by
commas.
</p>
<p> The following example makes this clear. The first five lines in the example are
the <a
href="http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol" >HTTP request headers</a>. You can pass the key of your account in the
<b><span
class="cmbx-12">X-OpenSensorData-Key</span></b> header.
</p>
<p> <div class="verbatim">
<span
class="cmtt-12">POST</span><span
class="cmtt-12"> /opensensordata.net/upload</span><span
class="cmtt-12"> HTTP/1.1</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">Host:</span><span
class="cmtt-12"> opensensordata.net</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">Content-Type:</span><span
class="cmtt-12"> text/csv</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">Content-Length:</span><span
class="cmtt-12"> 100000</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">X-OpenSensorData-Key:</span><span
class="cmtt-12"> 12345678-xxxx-yyyy-zzzz-123456789012</span>
<span
class="cmtt-12"> </span><br />
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">1,2013-03-03T18:29:43,6.875</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">2,2013-03-03T18:29:43,6.4375</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">3,2013-03-03T18:29:43,61.054</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">4,2013-03-03T18:29:43,61.054</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">5,2013-03-03T18:29:43,70.4128</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">6,2013-03-03T18:29:43,44.8116</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">7,2013-03-03T18:29:43,1021.48</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">8,2013-03-03T18:29:43,131.768</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">1,2013-03-03T18:30:01,6.875</span>
<span
class="cmtt-12"> </span><br /><span
class="cmtt-12">2,2013-03-03T18:30:01,6.4375</span>
<span
class="cmtt-12"> </span><br /><span