API Documentation v1.1

API: Sending Data

Communication to and from our API is done through HTTP GET and POST queries. We support two basic formats for output : JSON and XML. You can access our API from almost any programming language, and in just a few minutes with our plug and play libraries.



You can send data via our API services with POST request. Each request made match a method of the API on our servers. To make the best use of the public API, you should understand the difference between GET and POST methods, in which cases and how to use them.



Data Params

When sending data to our API servers, you need to send 4 types of parameters (2 out of which are optional) with their respective values.


  1. apikey: Your API Key. You can find this from your Account Settings page.
  2. format: The format of response you want back from the server. JSON or XML. Default is JSON. (optional)
  3. type: The type of log you are sending. INFO, WARNING or ERROR. Default is INFO. (optional)
  4. log: Your log text. If you are sending arrays, you can encode it in JSON format.



POST Requests

Data sending can be done via POST requests. A simple CURL request would look something like the one below:
curl --data "apikey=API_KEY&log=Test Log" https://logs.ws/api/1.1/

For example, if your want to send an ERROR type log in XML format with API key "123" and log text as "abc", The final cURL command must be :
curl --data "apikey=123&format=xml&type=error&log=abc" https://logs.ws/api/1.1/

Try Online

You can also try an online demo to see a working version at apibin.org.
Please note that the API key being used at the online demo will not work from any other source since we have added the IP of apibin.org in our whitelist.



Response

The response is sent from the API server in either JSON or XML format depending on the format you have specified when making the request.

Following are examples of success response:

JSON

{"result":true}

XML

<?xml version='1.0' encoding='UTF-8'?>
<output>
<result>true</result>
</output>

Following are examples of error response:

JSON

{"result":false,"message":"Error 106: Invalid API key"}

XML

<?xml version='1.0' encoding='UTF-8'?>
<output>
<result>false</result>
<message>Error 106: Invalid API key</message>
</output>



Error Messages And Their Interpretation

The following is a compiled list of error messages you might encounter when sending request to our API server:

Error No.Error MessageMeaning
101 API key unspecified API key is mandatory and you did not specify any. You can find your API key under your Account Settings page.
102 Log not specified You are tying to add an empty log. A log should at least be 1 char in length.
103 The IP xxx.xxx.xx.x is not recognized as a valid IP. The request is originating from an IP address that is not specified in your whitelist. You can add an IP to your whitelist from your Account Settings page.
105 There was an error adding your log. We have been intimated about this and we are fixing it. Some internal glitch happened and we have been intimated about it. We will be fixing up the problem ASAP.
106 Invalid API key You have specified an incorrect API key. You can find your API key under your Account Settings page.
110 Unsupported method. Use POST to add logs. You are using a method that is not supported for adding logs. You should always use a POST method to add logs.
111 No data found. Your search parameters could not find any logs.



 

Libraries

You can check out the API library documentations for PHP or jQuery