Mobile SDKs
Statistics
There are two types of data you can retrieve from Spike:
- Records consist of the raw data points collected from user devices or applications.
- Statistics, on the other hand, are calculated values derived from records.
This page is dedicated to the statistics part. It shows more in depth what lays unders Statistic metric from the technical side.
JS
1interface Statistic {
2 start: string; // Start date from which you will receive data
3 end: string; // End date till which you will receive data
4 duration: number; // Duration between start and end dates in miliseconds
5 type: StatisticsType; // See below for the list of types
6 value: number; // Value of statistic in units from the unit field
7 unit: Unit; // Unit type
8 rowCount: number | null; // Number of spike records used to count this value
9 recordIds: UUID[] | null; // List of record ids used to count this value
10}
JS
1enum StatisticsType {
2 steps, // Number of steps
3 distanceTotal, // Total distance
4 distanceWalking, // Walking distance
5 distanceCycling, // Cycling distance
6 distanceRunning, // Running distance
7 caloriesBurnedTotal, // Total burned calories
8 caloriesBurnedBasal, // Total burned basal(passive) calories
9 caloriesBurnedActive // Total burned active calories
10}
11enum Unit {
12 bpm, // Beats per minute
13 meters, // Metric of speed
14 kcal, // Calories metric (kilocalories)
15 count, //
16 kmh, // Metric of speed (kilometers per hour)
17 kmPerMin, // Metric of speed (Kilometers per minutes)
18 celsius, // Metric of temperature (Celsius)
19 percentage // Percentage
20}
Steps response example
1{
2 "uid": "22ba3ed4-81fd-5574-a52f-67a57478517a",
3 "from": "2024-11-20T02:00:00+02:00",
4 "to": "2024-12-03T02:00:00+02:00",
5 "timezone": "Europe/Vilnius",
6 "statistics": [
7 {
8 "interval_start": "2024-11-29T00:00:00+02:00",
9 "interval_end": "2024-11-30T00:00:00+02:00",
10 "interval_duration": 86400000,
11 "statistic_type": "steps",
12 "statistic_value": 3,
13 "statistic_unit": "count",
14 "source_coverage": 0,
15 "record_ids": [
16 "0134dae9-2aa6-87f1-936a-f2fbdd26f06e"
17 ]
18 },
19 {
20 "interval_start": "2024-12-01T00:00:00+02:00",
21 "interval_end": "2024-12-02T00:00:00+02:00",
22 "interval_duration": 86400000,
23 "statistic_type": "steps",
24 "statistic_value": 724,
25 "statistic_unit": "count",
26 "source_coverage": 0,
27 "record_ids": [
28 "0134db31-6483-8315-9954-a6642b6d4ea4",
29 "0134db31-4892-8128-971c-9af8c4801c5e",
30 "0134db31-aca7-8b82-b101-5251890b5b0f",
31 "0134db31-689d-8fe0-a899-2e2c2ce35ad3",
32 "0134db31-e11a-827c-86a2-493f363fb4e7",
33 "0134db31-35ec-811e-84f6-0f01649555db"
34 ]
35 }
36 ]
37}
Distance response example
1{
2 "uid": "22ba3ed4-81fd-5574-a52f-67a57478517a",
3 "from": "2024-11-20T02:00:00+02:00",
4 "to": "2024-12-03T02:00:00+02:00",
5 "timezone": "Europe/Vilnius",
6 "statistics": [
7 {
8 "interval_start": "2024-11-29T00:00:00+02:00",
9 "interval_end": "2024-11-30T00:00:00+02:00",
10 "interval_duration": 86400000,
11 "statistic_type": "distance_total",
12 "statistic_value": 1.41,
13 "statistic_unit": "meters",
14 "source_coverage": 0,
15 "record_ids": [
16 "0134dae9-ea7c-8bbf-9615-56fc8d30b6d9"
17 ]
18 },
19 {
20 "interval_start": "2024-12-01T00:00:00+02:00",
21 "interval_end": "2024-12-02T00:00:00+02:00",
22 "interval_duration": 86400000,
23 "statistic_type": "distance_total",
24 "statistic_value": 496.06,
25 "statistic_unit": "meters",
26 "source_coverage": 0,
27 "record_ids": [
28 "0134db31-a891-887a-bbd6-65f339321e8e",
29 "0134db31-6cc4-8726-985c-98ad8318ec6d",
30 "0134db31-9a48-8775-a174-e643425548ff",
31 "0134db31-1531-8d22-bbf0-cdba56f9e6e3",
32 "0134db31-23ef-86ee-a27d-b4f8911b7385",
33 "0134db31-3ef6-8dac-88b2-76ad6f5a0768"
34 ]
35 }
36 ]
37}