10. Stats
GET /stats/{type}/{aggregate}.{format}
The stats system is designed to give you fast access to aggregated data.
Stats are calculated and are they are not realtime
curl 'http://api.linkmobility.dk/v2/stats/{type}/{aggregate}.json?apikey=[apikey]' -X GET curl 'http://api.linkmobility.dk/v2/stats/{type}/{aggregate}.xml?apikey=[apikey]' -X GET
Type
Choose what type of messages you wan't to search in
Name | Description |
---|---|
inbox | Get stats for incomming messages |
outbox | Get stats for outgoing messages |
Aggregate
Chose what aggregation level you wan't to get stats for
Name | Description |
---|---|
hourly | Get hourly stats |
daily | Get daily stats |
weekly | Get weekly stats |
monthly | Get monthly stats |
Fields
You need to select what you wan't to search for in the stats system
Name | Type | Description |
---|---|---|
group | String | Search group id |
starttime | Date dd-mm-YYYY HH:MM | Search time interval start |
endtime | Date dd-mm-YYYY HH:MM | Search time interval end |
The search groups are pre calculated stats
Type | Group | Description |
---|---|---|
inbox | sum | Total number of messages received |
inbox | keyword:number | Number of received messages per keyword/number |
outbox | sum | Total number of messages sent |
outbox | mcc:status | Number of sent messages per country/status |
If you have admin rights you can select the base aggregation level by using the following options
Name | Type | Description |
---|---|---|
advanced | String | Advanced key that gives you extended access to the stats interface |
type_1 | enum (user, mcc) | Select base type |
value_1 | String | Value to search for |
examples
outbox/daily
curl 'http://api.linkmobility.dk/v2/stats/outbox/daily.json?apikey=[apikey]&starttime=15-02-2015 00:00:00&endtime=18-02-2015 23:59:59&group=sum' -X GET
{ "stats": [ { "year": "2015", "month": "2", "day": "23", "timestamp": "2015-02-23 00:00:00", "type_1": "user", "value_1": "7405", "type_2": "sum", "value_2": "sum", "counter": "1" }, { "year": "2015", "month": "2", "day": "25", "timestamp": "2015-02-25 00:00:00", "type_1": "user", "value_1": "7405", "type_2": "sum", "value_2": "sum", "counter": "4" } ], "status": 200 }
outbox/monthly
curl 'http://api.linkmobility.dk/v2/stats/outbox/monthly.json?apikey=[apikey]&starttime=01-01-2015 00:00:00&endtime=28-02-2015 23:59:59&group=sum' -X GET
{ "stats": [ { "year": "2015", "month": "2", "timestamp": "2015-02-01 00:00:00", "type_1": "user", "value_1": "7405", "type_2": "mcc:status", "value_2": "0:queued", "counter": "1" }, { "year": "2015", "month": "2", "timestamp": "2015-02-01 00:00:00", "type_1": "user", "value_1": "7405", "type_2": "mcc:status", "value_2": "0:rejected", "counter": "1" }, { "year": "2015", "month": "2", "timestamp": "2015-02-01 00:00:00", "type_1": "user", "value_1": "7405", "type_2": "mcc:status", "value_2": "238:received", "counter": "4" } ], "status": 200 }
inbox/monthly
curl 'http://api.linkmobility.dk/v2/stats/inbox/monthly.json?apikey=[apikey]&starttime=01-01-2015 00:00:00&endtime=28-02-2015 23:59:59&group=keyword:number' -X GET
{ "stats": [ { "year": "2015", "month": "2", "timestamp": "2015-02-01 00:00:00", "type_1": "user", "value_1": "7405", "type_2": "keyword:number", "value_2": "HENRIK:1272", "counter": "1" } ], "status": 200 }
POST /stats/inbox.{format}
Ingest data into the stats system. Requires an internal advanced key.
The max batch size to post is 10000
curl 'http://api.linkmobility.dk/v2/stats/inbox.json?apikey=[apikey]' -X GET curl 'http://api.linkmobility.dk/v2/stats/inbox.xml?apikey=[apikey]' -X GET
{ "stats": [ { "code": "1272", "keywordid": "108406", "logtime": "2015-07-06 15:06:23", "materialized_path": "15m/49p", "msgid": "1436187983-48305", "topbruger": "1498", "userid": "7405" }, { "code": "+4512721272", "keywordid": "1234", "logtime": "2015-07-06 15:06:31", "materialized_path": "abc", "msgid": "1436187991-48309", "topbruger": 0, "userid": "7405" }, { "code": "1272", "keywordid": "107543", "logtime": "2015-07-06 15:06:32", "materialized_path": "1xg", "msgid": "1436187992-48313", "topbruger": "0", "userid": "7405" } ] }
POST /stats/outbox.{format}
Ingest data into the stats system. Requires an internal advanced key.
The max batch size to post is 10000
curl 'http://api.linkmobility.dk/v2/stats/outbox.json?apikey=[apikey]' -X GET curl 'http://api.linkmobility.dk/v2/stats/outbox.xml?apikey=[apikey]' -X GET
{ "stats": [ { "logtime": "2015-07-06 00:00:24", "materialized_path": "1s9/4j1", "mcc": "238", "msgid": "f151c342147599d3955c485f98a10d91", "payout": null, "price": "", "splitcount": "1", "status": "received", "topbruger": "2313", "userid": "5869", "group": "external" }, { "logtime": "2015-07-06 00:00:39", "materialized_path": "6lp", "mcc": "238", "msgid": "fe8f9e28811bf0f21f95eefbc59c4142", "payout": null, "price": "", "splitcount": "1", "status": "received", "topbruger": "0", "userid": "8557", "group": "internal" } ] }
Feeling lost? Click on this link! Portal page