REST API

Getting started

Welcome to the 'Hello World' tutorial of the Realtime Reporter API. The API is an universal REST API, this means every developer can use it and it can communicatie with all scripting languages. In this tutorial we will use PHP as example language.

1: Get your API key

  • Be sure you have an active Realtime.report account and inlog.
  • Go to API Settings of your account.
  • Create an API key

2: Make your first API request

Once you have your API key we are almost ready. In this tutorial we will get the list of your accommodations, it's very easy by running the following code.

// Load your vendor Autoloader
/*
* Example get tag - How to get tag information from the  API
* https://api.realtime.report/v1/tags/{id}
*/
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');

	/*
    * Parameters:
    * device_id : Int
    */
    $data = array();
    $data['device_id'] = 3244 ;

	/*
	* All data is returned in a tag opject
	*/
    $tag = $reporter->get_tag('tag_id', $data);

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


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

If everything is right, you will get a response like this.

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{
    "id": "82449b8e92eb4f678707",
    "name": "Valve open",
    "is_setpoint": true,
    "is_alarm": false,
    "value": true,
    "Address": "DB.dbx3.2",
    "Location": "database",
    "db_number": "1",
    "type": "BOOL",
    "offset": "3",
    "bit_offset": "2"
}

You're done! That's all, try and play with our API.