REST API

Log tag

POST
https://api.realtime.report/v1/logs/tag

Authentication: API Key

Add a tag value to the logs.

Parameters

device_id
INTEGER
Set the device of the tag. (required)
tag_id
STRING
The unique id string of the tag. (required)
datetime
TIMESTAMP
The GMT 0 - UNIX timestamp, if empty we will use the datetime of the moment the tag is written to our database.
value
VARIABLE
The value of the tag (default 0)

Response

Returns data of the tag

201
application/json; charset=utf-8
id
String
The id of the log
value
String
The value that is logged

Example


/*
* Example get tag - How to get tag information from the  API
* https://api.realtime.report/v1/logs/tag
*/
try {

	/*
    * Initialize the RealtimeReporter API SDK with your API key.
    * See: https://realtime.report/developer
    */
	require_once $_SERVER['DOCUMENT_ROOT'].'/vendor/autoload.php';

	$reporter = new reporter_api ;
    $reporter->set_api_key('YOUR API KEY');

    /*
	* Set the new value
	*/
	$tag_data = array();
	$tag_data['device_id'] = 123;
	$tag_data['tag_id'] = 're4ray34674ydgw21';
	$tag_data['datetime'] = time();
	$tag_data['value'] = 23444 ;

	/*
	* Update the tag value
	*/
    $log = $reporter->log_tag($tag_data);

    /*
    * In this example we print the data in json format on the page
    */
    echo "Log data";
    echo json_encode($log, JSON_PRETTY_PRINT);


} catch (Exception $e) {
    echo "API call failed: " . htmlspecialchars($e->getMessage());
}


Response example

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
    "id": "82449b8e92eb4f678707",
    "value": "23444" 
}

Response Error

Returns an array with error information

230
application/json; charset=utf-8
code
Integer
The error code listed in a list below
message
String
The error message listed in a list below

Error Codes

1000
No valid API key
1001
No tag found
1001
No device found