Use JSON to Update Many Stats

You can update many stats with one call by using JSON. Send a post to http://www.stathat.com/ez with the Content-Type header set to “application/json”. The JSON object needs to have two fields: ezkey and data. “ezkey” is your ezkey, believe it or not. And “data” is an array of stat objects.

Here’s an example:

{
    "ezkey": "XXXYYYZZZ",
    "data": [
        {"stat": "page view", "count": 2},
        {"stat": "messages sent~total,female,europe", "count": 1},
        {"stat": "request time~total,messages", "value": 23.094},
        {"stat": "ws0: load average", "value": 0.732, "t": 1363118126},
    ]
}

The JSON stat objects support the “~” stat names for posting a count/value to multiple stats at once. They also support the optional timestamp parameter “t”.

For more information, see the API docs.


Comments? Send us a tweet.

Permalink:

Previous:
Post to Multiple Stats
Next:
Automatically Run Go Tests When Files Change (OS X)