A simple REST API for retrieving basic data from Divako
REST API Documentation can be found here: https://api.divako.no
<?php
const api_key = 'your-api-key';
const divako_url = 'https://api-v2.divako.no';
// Simple HTTP Request function to make REST API requests
function http_request( $method, $url, array $post = [], array $header = [] ): mixed
{
$json = json_encode( $post );
$header = array_merge( [
"Content-Type: application/json",
"Content-Length: " . strlen( $json ) ], $header );
$ch = curl_init( divako_url . $url );
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, $method );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $json );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 2 );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
curl_setopt( $ch, CURLOPT_HTTPHEADER, $header );
$str = curl_exec( $ch );
return json_decode( $str, true );
}
// requesting list of categories
$categories = http_request('GET', '/categories', [], [ "X-Authorization: " . api_key ] );
// print list of categories
print_r($categories);
This approach defines how we assign IDs in Divako, allowing us to avoid using full names consistently. All systems are interconnected using these concise ID names.
ID | Name |
---|---|
DevEUI | Device ID |
GwEUI | Gateway ID |
MID | Meter ID |
CID | Category ID |
GID | Group ID |
PID | Project ID |
UID | User ID |
IID | Issue ID |
AID | Analysis ID |
LID | Log ID |