Access

To access the export API, you need an access token. You can create as many as you want here: access token management. Delete tokens at any time to revoke access.

All URLs for the JSON API start with:

https://www.stathat.com/x/ACCESSTOKEN

Replace ACCESSTOKEN with one of your access tokens.

Requests must come in over https.


Stat list

Get a list of all your stats, including name and id.

https://www.stathat.com/x/ACCESSTOKEN/statlist

Example reply:

[{
        "id":"XXXX",
        "name":"request time",
        "public":false,
        "counter":true
  },
  {
        "id":"YYYY",
        "name":"user created",
        "public":true,
        "counter":true
  }]

This will return at most 10,000 stats at a time. If you have more than 10,000 stats, you can specify an offset in your requests to get the next batch of stats.

https://www.stathat.com/x/ACCESSTOKEN/statlist?offset=10000


Stat info by name

Get info about a single stat:

https://www.stathat.com/x/ACCESSTOKEN/stat?name=server+load+average

Example reply:

{
        "id": "ZZZZ",
        "name": "server load average",
        "public": true,
        "counter": true
}

Stat delete

Delete a stat by ID:

DELETE https://www.stathat.com/x/ACCESSTOKEN/stats/STATID

Example reply:

{
	"msg": "stat deleted."
}

Get datasets

Get datasets for a group of stats:

https://www.stathat.com/x/ACCESSTOKEN/data/STATIDD_0/STATID_1?t=1w3h

Example reply:

[{
        "name": "request time",
        "timeframe": "1 week @ 3 hours",
        "points": [{"time":1360861620, "value": 2.159},
                   {"time":1360872420, "value": 1.034},
                   {"time":1360883220, "value": 3.222},
                   {"time":1360894020, "value": 3.101}]
 },
 {
        "name": "user created",
        "timeframe": "1 week @ 3 hours",
        "points": [{"time":1360861620, "value":3},
                   {"time":1360872420, "value":0},
                   {"time":1360883220, "value":19},
                   {"time":1360894020,"value":21}]
 }]

You can get stat ids from the URL used in the web interface or using the /statlist or /stat JSON API calls.

The t parameter specifies the timeframe. The parameter consists of two parts: the duration of the timeframe and the interval. The example above of 1w3h will give you a dataset for the past week and each data point will represent three hours of time. The abbreviations for the time units are as follows:

Abbreviation Time unit
m minute
h hour
d day
w week
M month
y year

If you would like to specify a start time for the dataset, you can add a start parameter. Specify the start time for the dataset using a unix timestamp. For example, to get a dataset for one week starting on 26 November 2012 at 8:10 GMT, you would use the following query:

https://www.stathat.com/x/ACCESSTOKEN/data/STATIDD_0/STATID_1?t=1w3h&start=1353939000

The export API allows you to get daily summary data as well. This uses your timezone to chop the data into days separated exactly at midnight. Any data that in the current day (since midnight) is not returned. The following query returns a daily summary dataset for 7 days:

https://www.stathat.com/x/ACCESSTOKEN/data/STATIDD_0/STATID_1?summary=7d

You can use other timeframe abbreviations as well. For example, 2 months of daily summaries:

https://www.stathat.com/x/ACCESSTOKEN/data/STATIDD_0/STATID_1?summary=2M


© 2011-2015 Numerotron Inc