Metrics
API Version 2 (V2)
Stress
You can retrieve user stress data by user_id and filter by date range
Get stress data by user_id
GET
Request
Query Parameters
user_id
required
String
User ID returned by add integration request. This key should be stored in your database against the user and used for all interactions with the Spike API.
start_date
required
String
Date from in YYYY-MM-DD format
end_date
required
String
Date to in YYYY-MM-DD format
Header Parameters
authorizationtoken
optional
String
Client access token (deprecated)
x-spike-auth
required
String
Client access token
Python
Node.js
Ruby
Java
Curl
1import requests
2
3url = "https://api.spikeapi.com/v2/metrics/stress/?user_id=fa1e3803-6068-4ea7-9788-eccce210daa1&start_date=2020-05-01&end_date=2020-05-01"
4headers = {}
5headers['x-spike-auth'] = 'fa0b3803-1111-2222-9788-eccce210d30c'
6response = requests.request("GET", url, headers=headers)
7
8print(response.text)
Responses
200
1{
2 "user_id": "fa1e3803-6068-4ea7-9788-eccce210daa1",
3 "start_date": "2020-05-01",
4 "end_date": "2020-05-01",
5 "type": "stress",
6 "source": [
7 {
8 "name": "garmin",
9 "status": "OK"
10 }
11 ],
12 "data": [
13 {
14 "date": "2020-05-01",
15 "timezone_offset": 10800,
16 "min_stress": 35.0,
17 "avg_stress": 42.0,
18 "max_stress": 49.0,
19 "stress_samples": [
20 {
21 "time": "2020-05-01T00:00:00",
22 "value": 49
23 },
24 {
25 "time": "2020-05-01T00:03:00",
26 "value": 35
27 },
28 {
29 "time": "2020-05-01T00:06:00",
30 "value": -2
31 }
32 ],
33 "source":"garmin"
34 }
35]
36}
1<style>
2@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300&display=swap');
3
4.h2, .h3, .list, .description{
5 font-family: 'Poppins', sans-serif;
6 font-weight: 500;
7}
8
9.h2 {
10 margin-top: -20px;
11 margin-bottom: 20px;
12
13 font-size: 30px;
14}
15
16.h3 {
17 font-size: 22px;
18 margin-top: -20px;
19}
20
21.list-wrapper {
22 white-space: normal;
23 margin-top: -10px;
24}
25
26.list, .description {
27 font-size: 14px;
28}
29
30</style>
31<h2 class="h2">Fields</h2>
32<h3 class="h3">Stress.date</h3>
33<ul class="list-wrapper">
34 <li class="list">Type: String</li>
35 <li class="list">Format: Date, YYYY-MM-DD</li>
36 <li class="list">Example: 2020-05-01</li>
37</ul><p class="description">Date of measurement</p>
38
39<h3 class="h3">Stress.timezone_offset</h3>
40<ul class="list-wrapper">
41 <li class="list">Type: Int</li>
42 <li class="list">Unit: Seconds</li>
43 <li class="list">Example: 2400</li>
44</ul><p class="description">Time zone offset from UTC as seconds</p>
45
46<h3 class="h3">Stress.min_stress</h3>
47<ul class="list-wrapper">
48 <li class="list">Type: Float</li>
49 <li class="list">Example: 14.0</li>
50</ul><p class="description">The minimum value for stress in the day</p>
51
52<h3 class="h3">Stress.avg_stress</h3>
53<ul class="list-wrapper">
54 <li class="list">Type: Float</li>
55 <li class="list">Example: 14.0</li>
56</ul><p class="description">The average value for stress in the day</p>
57
58<h3 class="h3">Stress.max_stress</h3>
59<ul class="list-wrapper">
60 <li class="list">Type: Float</li>
61 <li class="list">Example: 14.0</li>
62</ul><p class="description">The maximum value for stress in the day</p>
63
64<h3 class="h3">Stress.stress_samples.time</h3>
65<ul class="list-wrapper">
66 <li class="list">Type: String</li>
67 <li class="list">Format: Date time, YYYY-MM-DDThh:mm:ss</li>
68 <li class="list">Example: 2021-05-01T01:52:13</li>
69</ul><p class="description">Date and time when the sample was registeredl</p>
70
71<h3 class="h3">Stress.stress_samples.value</h3>
72<ul class="list-wrapper">
73 <li class="list">Type: Int</li>
74 <li class="list">Example: 27</li>
75 <li class="list">Note: For Garmin -2 means too much motion and -1 means not enough data to detect stress</li>
76</ul><p class="description">Stress level value</p>
77
78<h3 class="h3">Stress.source</h3>
79<ul class="list-wrapper">
80 <li class="list">Type: String</li>
81 <li class="list">Example: fitbit</li>
82</ul><p class="description">Data source</p>
83
84
85
86