Starting in version 4.7, Slimstat introduced a new REST API, that external applications can utilize to retrieve metrics and reports from the database using the familiar approach already implemented to support shortcodes and other features.


The endpoint is available at

http://your.site.here/wp-json/slimstat/v1/get


The API accepts the following parameters:

  1. token (required)
    It must be defined in Slimstat > Settings > Access Control, and given to users that need access to the endpoint. Please treat these tokens as passwords, as they will grant read access to your reports to anyone who knows them.

  2. function (required)
    This parameter specifies the type of query you would like to perform. Valid values are: count, count-all, recent, recent-all, top and top-all. You can find out more about each function by referring to the Shortcodes documentation.

  3. dimension (required)
    This parameter indicates what dimension to return: * (all data), ip, resource, browser, operating system, etc. Please note that you can only specify one dimension at a time.

  4. filters (optional)
    This parameter is used to filter a given dimension (resources, browsers, operating systems, etc) so that it satisfies certain conditions (i.e.: browser contains Chrome). Please make sure to urlencode this value, and to use the usual filter format.


Examples:

  • Count all the pageviews in the last 15 days
    /wp-json/slimstat/v1/get?token=ABC&function=count&dimension=id&filters=interval%20equals%20-15

  • Get all the pageviews recorded this month so far
    /wp-json/slimstat/v1/get?token=ABC&function=recent&dimension=id


Do not hesitate to contact our support if further clarification is needed.