-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClarity_API_1.html
55 lines (35 loc) · 1.44 KB
/
Clarity_API_1.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test of Clarity API </title>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script>
getSensorData('146592'); // sensor index = Colo Jackson St
function getSensorData(sensor_index) {
// https://api.purpleair.com/v1/sensors/146592/history?start_timestamp=20240221&end_timestamp=20240323&fields=pm2.5_alt
let startEndTimes = "&start_timestamp=2024-07-01T16:38:33Z&end_timestamp=2024-07-10T16:38:33Z";
// fields: ["time_stamp", "humidity", "temperature", "pm2.5_alt", "pm1.0_atm", "pm10.0_atm"]
let fields = "&fields=pm2.5_alt, pm1.0_atm, pm10.0_atm, temperature, humidity";
let avg = "&average = 60";
let my_api_read_key = 'u7JGpnsQK9pM6XO52v5gxiP63j7EYUTw0nZzMsk5';
let my_org = 'acterrOUK5';
// let my_url = 'https://clarity-data-api.clarity.io/v2/measurements?startTime=2019-05-30&code=' + my_api_read_key + '&limit=1000';
let my_url = 'https://clarity-data-api.clarity.io/v2/datasources?org=' + my_org;
// We use the Fetch API to send our request and return the response.
fetch (my_url, {
headers: {
'X-API-KEY': my_api_read_key
}
})
.then(response => response.json())
.then(results => {
console.log(results);
//console.log("Humidity: " + results.data[0][2]); // double array
});
}
</script>
</body>
</html>