Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stats endpoint #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 161 additions & 0 deletions Metrics.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,166 @@
For access to the `/api/v2/metrics` endpoints you must be [Authenticated](Authentication.md)

#### GET `/api/v2/metrics/stats`

The main metrics endpoint

Query Params:

|Query Param|Example|Notes|
|:---|:---|:---|
|metric|`scans`|`String` - Required. Valid metrics: `scans`, `taps`|
|from*|`1521561000000`|`Number` - Required. Date in Milliseconds|
|to*|`1524153000000`|`Number` - Required. Date in Milliseconds. to _must_ be after from|
|dimension|`activity`|`String` - Required. Valid dimensions: `activity`, `phyid`, `app`, `destination`, `os`|
|value|`["abc123"]`|`String`or `Array` - Required. Valid values are `all` or an array of IDs for the given dimension|
|interval|`hour`|`String` - Required. Valid intervals: `15min`, `hour`, `day`, `week`, `month`, `quarter`, `year`|
|touchpoint|`abc123`|`String` - Optional, will be deprecated in favor of more robust dimensions. Secondary dimension to pin down further on `destination` dimension|

*NOTE: `stats` is limited by the number of responses based on the `interval`, `from`, and `to`, with the following table:

|Interval| Max Range|
|:---:|:---:|
|`15min`|24 hours|
|`hour`|3 days|
|`day`|91 days|
|`week`|1 year|
|`month`|2 years|
|`quarter`|4 years|

Example Request:
```
https://my.phy.net/api/v2/metrics/stats?metric=scans&from=1521561000000&to=1524153000000&dimension=activity&value=all&interval=day

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are 'from' and 'to' supposed to be swapped here?

Copy link

@rochforp rochforp Apr 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The request I was using that is working is structured a little different
"https://my.phy.net/api/v2/metrics/stats?metric=scans&dimension=phyid&value=all&to=1523982165633&from=1523896360822&interval=day"

dimension followed by value with interval at the end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rochforp The order does not matter with query variables, as long as the keys are unique. They are parsed into an object and accessed from that.

```

Example response:

```
{
"account": [
[
1521590400000,
26
],
[
1521676800000,
20
],
[
1521763200000,
37
],
[
1521849600000,
85
],
[
1521936000000,
90
],
[
1522022400000,
67
],
[
1522108800000,
116
],
[
1522195200000,
205
],
[
1522281600000,
40
],
[
1522368000000,
69
],
[
1522454400000,
68
],
[
1522540800000,
39
],
[
1522627200000,
46
],
[
1522713600000,
29
],
[
1522800000000,
224
],
[
1522886400000,
63
],
[
1522972800000,
33
],
[
1523059200000,
68
],
[
1523145600000,
140
],
[
1523232000000,
23
],
[
1523318400000,
56
],
[
1523404800000,
29
],
[
1523491200000,
35
],
[
1523577600000,
54
],
[
1523664000000,
64
],
[
1523750400000,
80
],
[
1523836800000,
72
],
[
1523923200000,
135
],
[
1524009600000,
76
],
[
1524096000000,
17
]
]
}
```

#### GET `/api/v2/metrics/metric/:metric/:timerange`

The metrics endpoint that returns metric data for a given metric and timerange.
Expand Down