Little Software Stats uses an API (Application Programming Interface) in order to receive software usage information. The API currently accepts POST data that contains either JSON or XML data. In order to process the JSON and XML data, Little Software Stats uses the json_decode() and simplexml_load_string() (respectively) PHP functions. Therefore, the data must be valid in order to be accepted by the API.

A typical Little Software Stats installation that has rewrite enabled would have the URL to the API look something like http://example.com/api.xml if XML data was being sent, or, http://example.com/api.json if JSON data was being sent. If rewrite was not enabled, then the URL would be something like http://example.com/api.php?type=xml.

The data must be enclosed in double brackets in order to allow more than one request to be processed at time. For example, if your sending XML data then the data field would be <?xml version="1.0"?><data><Events><!-- Event tags --></Events><Events><!-- Event tags --></Events></data> with “Event tags” representing the actual event data. If your sending JSON data then the data field would be [[{Event data}],[{Event data}]] with “Event data” representing the actual event data.

If data is being sent in JSON format then there a few things that should be considered in order for it to be parsed properly. If a string is being used, then any special characters (ie: tab, backspace, newline, etc) then it should have two backslashes instead of one (so a tab would be “\\t” instead of “\t”).

The XML or JSON data is sent through a POST field called “data”. If the data is sent via something other then a POST request then the API will return a HTTP status code of 405 (Method Not Allowed). Once the data has been finished being processed then it will return one of the following codes in the type of data (XML or JSON) that was sent.

Code Reason Notes
1 Success
-8 Empty POST data
-9 Invalid JSON/XML string
-10 Missing required data
-11 Application ID not found This is also returned if the application is set to not receive data
-12 User ID not found
-13 Use POST request (Deprecated)
-14 Application version not found
-15 Invalid event data

The following is an example of error code 1 in XML output:

<Status>
<Code>1</code>
<Message>Success</message>
</Status>

Or, in JSON it would be:

{"status_code":1,"status_message":"Success"}

Comments