-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathapiary.apib
348 lines (292 loc) · 11.5 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
FORMAT: 1A
HOST: https://rt.ambientweather.net/
# Ambient Weather REST API
Access an Ambient Weather user's weather station data programmatically using our REST API
##### Authentication
Two API Keys are required for all REST API requests:
+ `applicationKey` - identifies the developer / application. To create an application key please login to your AmbientWeather.net account page (https://ambientweather.net/account)
+ `apiKey` - grants access to past/present data for a given user's devices. A typical consumer-facing application will initially ask the user to create an `apiKey` on their AmbientWeather.net account page (https://ambientweather.net/account) and paste it into the app. Developers for personal or in-house apps will also need to create an apiKey on their own account page.
##### Rate Limiting
API requests are capped at 1 request/second for each user's apiKey and 3 requests/second per applicationKey. When this limit is exceeded, the API will return a 429 response code. Please be kind to our servers :)
##### Helper Libraries
+ Node.js - https://github.com/owise1/ambient-weather-api
+ PHP (Laravel) - https://github.com/Jafo232/ambient_api
+ Rust - https://github.com/JoshuaKimsey/ambient-weather-api
+ Go - https://github.com/lrosenman/ambient
+ Python - https://github.com/avryhof/ambient_api
+ Python (asyncio) - https://github.com/bachya/aioambient
+ R - https://github.com/andrewflack/ambientweatheR
+ Java - https://github.com/rsv-code/ambient-weather-java
+ Swift - https://github.com/MikeManzo/SwiftyWeatherKit
+ .NET 5 - https://github.com/ChaseDRedmon/Cirrus
##### Other Resources
+ API Wiki - https://github.com/ambient-weather/api-docs/wiki
+ This documentation's repository - https://github.com/ambient-weather/api-docs
## Devices [/v1/devices{?apiKey,applicationKey}]
### List User's Devices [GET]
Provides a list of the user's available devices along with each device's most recent data.
+ Parameters
+ applicationKey (required) - Application Key
+ apiKey (required) - API Key for user account
+ Response 200 (application/json)
[
{
"macAddress": "00:00:00:00:00:00",
"info": {
"name": "My Weather Station",
"location": "Home"
},
"lastData": {
"dateutc": 1515436500000,
"date": "2018-01-08T18:35:00.000Z",
"winddir": 58,
"windspeedmph": 0.9,
"windgustmph": 4,
"maxdailygust": 5,
"windgustdir": 61,
"winddir_avg2m": 63,
"windspdmph_avg2m": 0.9,
"winddir_avg10m": 58,
"windspdmph_avg10m": 0.9,
"tempf": 66.9,
"humidity": 30,
"baromrelin": 30.05,
"baromabsin": 28.71,
"tempinf": 74.1,
"humidityin": 30,
"hourlyrainin": 0,
"dailyrainin": 0,
"monthlyrainin": 0,
"yearlyrainin": 0,
"feelsLike": 66.9,
"dewPoint": 34.45380707462477
}
}
]
## Device Data [/v1/devices/{macAddress}{?apiKey,applicationKey,endDate,limit}]
+ Parameters
+ macAddress (required) - device Mac Address
+ apiKey (required) - API Key for user account
+ applicationKey (required) - Application Key
+ endDate (optional) - The most recent datetime. Results descend from there. If left blank, the most recent results will be returned. Date format should be in milliseconds since the epoch or string representations outlined here: https://momentjs.com/docs/#/parsing/string/. Note: datetimes are stored in UTC.
+ limit (optional, number) - The maximum number of results to return (max: 288)
+ Default: 288
### Query Device Data [GET]
Fetch data for a given device. Data is stored in 5 or 30 minute increments. A list of all possible fields is here: https://github.com/ambient-weather/api-docs/wiki/Device-Data-Specs
+ Response 200 (application/json)
[
{
"dateutc": 1515436500000,
"date": "2018-01-08T18:35:00.000Z",
"winddir": 58,
"windspeedmph": 0.9,
"windgustmph": 4,
"maxdailygust": 5,
"windgustdir": 61,
"winddir_avg2m": 63,
"windspdmph_avg2m": 0.9,
"winddir_avg10m": 58,
"windspdmph_avg10m": 0.9,
"tempf": 66.9,
"humidity": 30,
"baromrelin": 30.05,
"baromabsin": 28.71,
"tempinf": 74.1,
"humidityin": 30,
"hourlyrainin": 0,
"dailyrainin": 0,
"monthlyrainin": 0,
"yearlyrainin": 0,
"feelsLike": 66.9,
"dewPoint": 34.45380707462477
}
]
# Group Ambient Realtime API
Access an Ambient Weather user's weather station data in realtime using our Realtime API
##### Authentication
You will be working with two types of keys when using the Realtime API:
+ `applicationKey` - identifies the developer / application. This key is passed to the server when you make the initial connection
+ `apiKey` - identifies a user. This key grants read-only access to all of the devices for a given user. It is used in the `subscribe` command (see below)
##### Websockets
The realtime API uses Websockets and is based on Socket.io (https://socket.io/). The easiest way to use the API is to use a Socket.io helper library. They are available in most languages.
Socket.io Endpoint: `https://rt2.ambientweather.net/?api=1&applicationKey=....`
* The realtime subdomain is different than the REST subdomain (realtime = `rt2`, REST = `rt`).
* Include query parameters `api=1` to identify the api version
* Include `applicationKey=....` to identify your application
Upon successful connection, you'll send commands and listen for responses.
##### Helper Libraries
+ Node.js - https://github.com/owise1/ambient-weather-api
###### Command: connect
Connect to the Realtime API
###### Command: disconnect
Disconnect from the Realtime API
###### Command: subscribe
Listen for new data from all the devices for users' apiKeys.
command body - an object containing the property apiKeys that is an array of apiKeys:
```
{
apiKeys:
[
'multiple',
'apiKeys',
'are fine'
]
}
```
###### Command: unsubscribe
Stop listening for new data from all the devices for users' apiKeys.
command body - an object containing the property apiKeys that is an array of apiKeys:
```
{
apiKeys:
[
'multiple',
'apiKeys',
'are fine'
]
}
```
##### Event: subscribed
`subscribed` events are emitted after you send a `subscribe` or `unsubscribe` command. It will list all of the devices you are currently subscribed to and, if applicable, will return apiKeys that are not valid.
event body - an object containing one or more properties
+ `devices` - an array containing objects for all of the devices you are currently subscribed to
+ `invalidApiKeys` - an array of apiKeys that aren't valid
```
{
"devices": [
{
"macAddress": "00:00:00:00:00:00",
"info": {
"name": "My Weather Station",
"location": "Home"
"address": "this_device_physical_street_address",
"elevation": 60.72509002685547,
"coords": {
"coords": {
"lat": xxx.xxxxxxx,
"lon": xxx.xxxxxxx
},
"geo": {
"type": "Point",
"coordinates": [
xxx.xxxxxxx,
xxx.xxxxxxx
]
}
},
"lastData": {
"dateutc": 1515436500000,
"date": "2018-01-08T18:35:00.000Z",
"winddir": 58,
"windspeedmph": 0.9,
"windgustmph": 4,
"maxdailygust": 5,
"windgustdir": 61,
"winddir_avg2m": 63,
"windspdmph_avg2m": 0.9,
"winddir_avg10m": 58,
"windspdmph_avg10m": 0.9,
"tempf": 66.9,
"humidity": 30,
"baromrelin": 30.05,
"baromabsin": 28.71,
"tempinf": 74.1,
"humidityin": 30,
"hourlyrainin": 0,
"dailyrainin": 0,
"monthlyrainin": 0,
"yearlyrainin": 0,
"feelsLike": 66.9,
"dewPoint": 34.45380707462477
"deviceId": "this_devices_unique_device_id"
},
"apiKey": "the_apiKey_for_the_user_this_device_belongs_to"
}
],
"invalidApiKeys": [
'an_api_key_that_is_not_any_good'
],
"method:" "subscribe"
}
```
##### Event: data
`data` events are emitted when a device you are subscribed to sends new data. The data contains a `macAddress` property that you can use to match against the device list supplied by the `subscribed` event
event body - an object representing a device's data point
```
{
"macAddress": "00:00:00:00:00:00",
"dateutc": 1515436500000,
"date": "2018-01-08T18:35:00.000Z",
"winddir": 58,
"windspeedmph": 0.9,
"windgustmph": 4,
"maxdailygust": 5,
"windgustdir": 61,
"winddir_avg2m": 63,
"windspdmph_avg2m": 0.9,
"winddir_avg10m": 58,
"windspdmph_avg10m": 0.9,
"tempf": 66.9,
"humidity": 30,
"baromrelin": 30.05,
"baromabsin": 28.71,
"tempinf": 74.1,
"humidityin": 30,
"hourlyrainin": 0,
"dailyrainin": 0,
"monthlyrainin": 0,
"yearlyrainin": 0,
"feelsLike": 66.9,
"dewPoint": 34.45380707462477,
"tz": "America/New_York"
"device": {
"macAddress": "00:00:00:00:00:00",
"info": {
"name": "My Weather Station",
"coords": {
"coords": {
lat": xxx.xxxxxxx,
lon": xxx.xxxxxxx
},
"address": "his_device_physical_street_address",
"location": "Home",
"elevation": 60.72509002685547,
"geo": {
"type": "Point",
"coordinates": [
xxx.xxxxxxx,
xxx.xxxxxxx
]
}
},
"lastData": {
"dateutc": 1515436500000,
"date": "2018-01-08T18:35:00.000Z",
"winddir": 58,
"windspeedmph": 0.9,
"windgustmph": 4,
"maxdailygust": 5,
"windgustdir": 61,
"winddir_avg2m": 63,
"windspdmph_avg2m": 0.9,
"winddir_avg10m": 58,
"windspdmph_avg10m": 0.9,
"tempf": 66.9,
"humidity": 30,
"baromrelin": 30.05,
"baromabsin": 28.71,
"tempinf": 74.1,
"humidityin": 30,
"hourlyrainin": 0,
"dailyrainin": 0,
"monthlyrainin": 0,
"yearlyrainin": 0,
"feelsLike": 66.9,
"dewPoint": 34.45380707462477,
"deviceId": "this_devices_unique_device_id",
"tz": "America/New_York"
},
"apiKey": "the_apiKey_for_the_user_this_device_belongs_to"
}
}
```