The reports API allows you to extract statistical data, optionally formatted into various formats for consumption by BI tools such as QlikView, Power BI, Tableau and others. This API is also used internally by the GUI tools when presenting various statistics.
The API can be browsed from your favorite web browser as most links are hyperlinks. E.g. using Chrome and installing one of the many JSON/REST plugins (JSONview) will give you a JSON interface with clickable links where you can move forward, backwards etc. through search answers.
In addition to normal access checks the user requesting the report must have a role allowing that report to run. Reports unavailable to the user are hidden and can not be browsed.
The report endpoint is used for extracting statistical data from the system, making a POST request to the proper URL will run the report and return the data. By default, the data is returned as JSON, but using a concept of formatters the result can also be sent as XML, HTML tables and other formats.
Making a GET request to the same URL will return an object describing the parameters the report expects/supports and some general comments about what the report does.
The report endpoint is organized into three different levels, with the first level being the supplier of the report, the second level a group within that supplier and the third level the actual report within the group.
To retrieve a list of the report suppliers:
https://testaccount.shop4sale.se/admin/api/report/
You can then retrieve the list of groups within that supplier:
https://testaccount.shop4sale.se/admin/api/report/Kodmyran/
A we can then navigate to e.g. the reports covering "Sales":
https://testaccount.shop4sale.se/admin/api/report/Kodmyran/Sales/
This will give us the list of the reports available at this level, clicking on the actual report will give us the parameters the report accepts and the various default values. Parameters involving time accepts ISO 8601 formatted strings, but you can also use a convenient format for relative dates like this:
Etc.
For the special parameters named startTime and endTime you can omit the time part and only specify the date, in which case the startTime field will start at "00:00:00" that day and the endTime field will end at "23:59:59" without further configuration.
To ensure compatibility with the majority of BI tools the API accept one additional parameter "_method" which can be used to run the report even though you are using a HTTP GET request. You can set this field to "POST" to run the report instead of getting its metadata.
You can also set the _format parameter to specify the output you require; these values are currently available:
Format | Description |
---|---|
HTML | A HTML table wrapped in a normal HTML page. It has a default style making it very simple to use. Most BI tools can read this type of data. |
JSON | Returns a JSON formatted array with data. |
XML | Returns an XML document |
geckopiechart | Returns a JSON in Geckoboard custom pie chart format |
geckonumber | Returns a JSON in Geckoboard custom number format |
geckoleaderboard | Returns a JSON in Geckoboard custom leaderboard format |