forked from Peterkn2001/blynk-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apiary.apib
503 lines (377 loc) · 12.4 KB
/
apiary.apib
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
FORMAT: 1A
HOST: http://blynk-cloud.com/
# Blynk HTTP RESTful API
Blynk HTTP RESTful API allows to easily read and write values to/from Pins in Blynk apps and Hardware (microcontrollers and microcomputers like Arduino, Raspberry Pi, ESP8266, Particle, etc.).
Every ```PUT``` request will update Pin's state both in apps and on the hardware.
Every ```GET``` request will return current state/value on the given Pin.
We also provide simplified API so you can do updates via GET requests.
## Get pin value [/{auth_token}/get/{pin}]
+ Parameters
+ auth_token (required, string, `4ae3851817194e2596cf1b7103603ef8`) ... authentification token.
+ pin (required, string, `D8`) ... pin you want to read.
### Get pin value [GET]
+ Response 200 (application/json)
[
]
+ Response 200 (application/json)
[
"1"
]
+ Response 200 (application/json)
[
"1",
"2"
]
+ Response 400 (plain/text)
Invalid token.
+ Response 400 (plain/text)
Wrong pin format.
+ Response 400 (plain/text)
Requested pin not exists in app.
## Write pin value via GET [/{auth_token}/update/{pin}?value={value}]
+ Parameters
+ auth_token (required, string, `4ae3851817194e2596cf1b7103603ef8`) ... authentification token.
+ pin (required, string, `D8`) ... pin you want to write.
+ value (required, string, `1`) ... pin value you want to write.
### Write pin value via GET [GET]
+ Response 200
+ Response 400 (plain/text)
Invalid token.
+ Response 400 (plain/text)
Wrong pin format.
+ Response 400 (plain/text)
Requested pin doesn't exist in the app.
+ Response 500 (plain/text)
Unexpected content type. Expecting application/json.
## Write pin value via PUT [/{auth_token}/update/{pin}]
+ Parameters
+ auth_token (required, string, `4ae3851817194e2596cf1b7103603ef8`) ... authentification token.
+ pin (required, string, `D8`) ... pin you want to write.
### Write pin value via PUT [PUT]
+ Request (application/json)
[
"1"
]
+ Request (application/json)
[
"1",
"2"
]
+ Response 200
+ Response 400 (plain/text)
Invalid token.
+ Response 400 (plain/text)
Wrong pin format.
+ Response 400 (plain/text)
Requested pin not exists in app.
+ Response 500 (plain/text)
Unexpected content type. Expecting application/json.
## Set Widget Property via GET [/{auth_token}/update/{pin}?{property}={value}]
+ Parameters
+ auth_token (required, string, `4ae3851817194e2596cf1b7103603ef8`) ... authentification token.
+ pin (required, string, `V0`) ... pin you want to write.
+ property (required, string, `label`) ... property you want to change `label`, `color`, etc. For reserved characters
like space and '#' for color property you need to use appropriate encoding. For example `#23C48E` should be passed as
`%2323C48E` where %23 is encoded '#' character.
+ value (required, string, `MyNewLabel`) ... property value.
### Set Widget Property via GET [GET]
+ Response 200
+ Response 400 (plain/text)
Invalid token.
+ Response 400 (plain/text)
Wrong pin format.
+ Response 400 (plain/text)
Requested pin not exists in app.
+ Response 500 (plain/text)
Unexpected content type. Expecting application/json.
## Hardware network status [/{auth_token}/isHardwareConnected]
+ Parameters
+ auth_token (required, string, `4ae3851817194e2596cf1b7103603ef8`) ... authentification token.
### Checks that hardware with provided token is online and connected to server [GET]
+ Response 200 (application/json)
true
+ Response 200 (application/json)
false
+ Response 400 (plain/text)
Invalid token.
## Application network status [/{auth_token}/isAppConnected]
### Check that application is connected to server and has active project with provided token [GET]
+ Response 200 (application/json)
true
+ Response 200 (application/json)
false
+ Response 400 (plain/text)
Invalid token.
## Send push notification [/{auth_token}/notify]
+ Parameters
+ auth_token (required, string, `4ae3851817194e2596cf1b7103603ef8`) ... authentification token.
### Notify [POST]
+ Request (application/json)
{
"body" : "message no less than 255 chars."
}
+ Response 200
+ Response 400 (plain/text)
Invalid token.
+ Response 400
Body is empty or larger than 255 chars.
+ Response 400
Project is not active.
+ Response 400
No notification widget or widget not initialized.
+ Response 500 (plain/text)
Unexpected content type. Expecting application/json.
## Send email [/{auth_token}/email]
+ Parameters
+ auth_token (required, string, `4ae3851817194e2596cf1b7103603ef8`) ... authentification token.
### Email [POST]
+ Request (application/json)
{
"to" : "email",
"title" : "title",
"subj" : "subj"
}
+ Response 200
+ Response 400 (plain/text)
Invalid token.
+ Response 400
Email body is wrong. Missing or empty fields 'to', 'subj'.
+ Response 400
Project is not active.
+ Response 400
No email widget.
+ Response 500 (plain/text)
Unexpected content type. Expecting application/json.
### Pin history data [/{auth_token}/data/{pin}]
+ Parameters
+ auth_token (required, string, `4ae3851817194e2596cf1b7103603ef8`) ... authentification token.
+ pin (required, string, `D8`) ... pin you want to read.
## Get all history data for specific pin [GET]
+ Response 200 (application/x-gzip)
### QR for project cloning [/{auth_token}/qr]
+ Parameters
+ auth_token (required, string, `4ae3851817194e2596cf1b7103603ef8`) ... authentification token.
## QR for project cloning [GET]
+ Response 200 (image/png)
## Get project [/{auth_token}/project]
Returns project connected with provided token.
+ Parameters
+ auth_token (required, string, `4ae3851817194e2596cf1b7103603ef8`) ... authentification token.
### Get project [GET]
+ Response 200 (application/json)
{
"id":125564119,
"name":"New Project",
"createdAt":0,
"updatedAt":0,
"widgets":[
{
"type":"TWO_AXIS_JOYSTICK",
"id":1036300912,
"x":0,
"y":4,
"color":-308477697,
"width":5,
"height":4,
"pins":[
{
"pin":15,
"pwmMode":false,
"rangeMappingOn":false,
"pinType":"ANALOG",
"value":"1",
"min":0,
"max":255
},
{
"pin":15,
"pwmMode":false,
"rangeMappingOn":false,
"pinType":"ANALOG",
"value":"2",
"min":0,
"max":255
}
],
"split":true,
"autoReturnOn":true,
"portraitLocked":false
},
{
"type":"BUTTON",
"id":1036300899,
"x":5,
"y":0,
"color":616861439,
"width":2,
"height":2,
"pinType":"DIGITAL",
"pin":8,
"pwmMode":false,
"rangeMappingOn":false,
"min":0,
"max":0,
"value":"0",
"pushMode":true
},
{
"type":"LED",
"id":1036300908,
"x":4,
"y":0,
"color":1602017535,
"width":1,
"height":1,
"label":"gggg",
"pin":-1,
"pwmMode":false,
"rangeMappingOn":false,
"min":0,
"max":0,
"frequency":0
},
{
"type":"LED",
"id":1036300904,
"x":7,
"y":0,
"color":1602017535,
"width":1,
"height":1,
"pinType":"VIRTUAL",
"pin":2,
"pwmMode":false,
"rangeMappingOn":false,
"min":0,
"max":0,
"frequency":0
},
{
"type":"TIMER",
"id":276297114,
"x":0,
"y":1,
"color":-308477697,
"width":3,
"height":1,
"pinType":"DIGITAL",
"pin":0,
"pwmMode":false,
"rangeMappingOn":false,
"min":0,
"max":0,
"startTime":75600,
"startValue":"dw\u00000\u00001",
"stopTime":75599,
"stopValue":"dw\u00000\u00000"
},
{
"type":"LED",
"id":1036300903,
"x":4,
"y":1,
"color":1602017535,
"width":1,
"height":1,
"pinType":"VIRTUAL",
"pin":1,
"pwmMode":false,
"rangeMappingOn":false,
"min":0,
"max":0,
"frequency":0
},
{
"type":"SLIDER",
"id":1036300911,
"x":0,
"y":0,
"color":-308477697,
"width":4,
"height":1,
"pinType":"DIGITAL",
"pin":3,
"pwmMode":true,
"rangeMappingOn":false,
"min":0,
"max":255,
"value":"87"
},
{
"type":"LED",
"id":1036300902,
"x":3,
"y":1,
"color":1602017535,
"width":1,
"height":1,
"pinType":"VIRTUAL",
"pin":0,
"pwmMode":false,
"rangeMappingOn":false,
"min":0,
"max":0,
"frequency":0
},
{
"type":"DIGIT4_DISPLAY",
"id":1036300913,
"x":5,
"y":4,
"color":-308477697,
"width":2,
"height":1,
"pinType":"ANALOG",
"pin":14,
"pwmMode":false,
"rangeMappingOn":false,
"min":0,
"max":1023,
"frequency":1000
},
{
"type":"BUTTON",
"id":1036300914,
"x":5,
"y":5,
"color":616861439,
"width":2,
"height":2,
"pinType":"DIGITAL",
"pin":1,
"pwmMode":false,
"rangeMappingOn":false,
"min":0,
"max":0,
"value":"1",
"pushMode":false
},
{
"type":"NOTIFICATION",
"id":1036300915,
"x":5,
"y":7,
"width":2,
"height":1,
"androidTokens":{
"uid":"token"
},
"notifyWhenOffline":false,
"priority":"normal"
},
{
"type":"EMAIL",
"id":1036300916,
"x":5,
"y":9,
"width":2,
"height":1
}
],
"boardType":"Arduino UNO",
"keepScreenOn":false,
"isShared":false,
"isActive":true
}
+ Response 400 (plain/text)
Invalid token.