Storing Metrics with REST

The REST interface underpins all of the API functionality for RESTful Metrics. Currently all data sent to RESTful Metrics is required to be JSON serialized.

Presently, the API is limted in scope to creating metrics. Fetching metrics will be added to the API soon.

Storing Metric Data Points

To store your data point, you should direct your POST request to the following end point:

    POST http://track.restfulmetrics.com/apps/your_app_id/metrics.json

The Authorization HTTP header needs to be set with your API key.

Each POST request must also include the metric name and a value. Optionally, you can include a distinct identifier for a particular user if you wish to distinguish your metrics later by unique users. More info about distinct user identifiers can be found here.

The actual parameter names for these attributes are a little different from their descriptive names. Here is a translation between the actual parameter names and their respective descriptive names:

Descriptive Name Parameter Name
Metric Name name
Value value
Distinct User Identifier distinct_id

The data for the POST request should be JSON serialized and should look like this:

    {
        metric: {
            name: "some_metric",
            value: 1,
            distinct_id: "5fe5cccc3f5efaf5afe53fe5"
        }
    }

A Curl request would like this:

    curl http://track.restfulmetrics.com/apps/your_app_id/metrics.json -X POST -H "Authorization: your_api_key" -H "Content-Type: application/json" -d '{ "metric": { "name": "some_metric", "value": 1 } }'

RESTful Metrics will respond with a 200 OK fairly quickly (less than 100ms). If speed is of concern in your application, it's recommended you send this POST request asynchronously. If there is an error with your API key, the service will return a 401 Unauthorized.