The Jabmo REST API is based on Jabmo Account Sensing. It provides developers with the names of the companies that visit your website including behavioral and firmographics data.
This API helps you get lists of accounts that have visited your website and their marketing engagements including ads clicked, website pages visited and emails viewed.
This API identifies users using their Jabmo account. Jabmo Analytics API responses are available in JSON.
This guide will show you how to make your first calls to Jabmo REST API in a few minutes. You will learn how to authenticate and how to retrive, add and remove data using API endpoints.
Step 1 - Create an account
Before using the Jabmo REST API you will need to open an Jabmo account. If you do not yet have an account, you should contact your customer success manager.
After opening an account, you will receive your unique Jabmo tracker code to paste on your website. Either place the tag at the end of the <body> section of your html pages or use one of our CMS plugins (WordPress, Joomla, Drupal).
As soon as the tag is on your website, you can try all of our code samples below by copying and pasting them in a php file and loading them with localhost.
Step 2 - Get an Authentication Token
To make API calls you need an authentication token. This token has to be in each request header: 'X-Auth-Token:Bearer YOUR_TOKEN'
.
To obtain an authentication token you have to call the /authenticate
endpoint with the POST
method and provide the Jabmo user's username and password as below:
PHP Sample
<?php /*********************************************************** Authenticate Get your user token ************************************************************/ if (isset($_POST['username']) && isset($_POST['password']) && $_POST['username'] != null && $_POST['password'] != null) { $username = $_POST["username"]; $password = $_POST["password"]; $data = array("username" => $username, "password" => $password); $data_string = json_encode($data); //authenticate $ch = curl_init('https://api.jabmo.com/latest/authenticate'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data_string)) ); //execute request $response = curl_exec($ch); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); //close connection curl_close($ch); $decodedData = json_decode($response); $token = $decodedData->{'token'}; } ?> <html> <head> <title>Authenticate</title> <link rel="stylesheet" href="css/style.css"> </head> <body> <div class="main-content"> <form class="form-login" method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> <div class="form-white-background"> <div class="form-title-row"> <h1>Get your API token</h1> </div> <?php if (isset($token) && $token != null) { echo '<div class="form-title-row">'.$token.'</div>'; } else { echo 'Status code: '.$httpcode; echo $decodedData->message; } ?> <div class="form-row"> <label> <span>Login</span> <input type="text" name="username"> </label> </div> <div class="form-row"> <label> <span>Password</span> <input type="password" name="password"> </label> </div> <div class="form-row"> <button type="submit" name="submit">Authenticate</button> </div> </div> </form> </div> </body> </html>
Step 3 - Request REST API
The Jabmo API provides several endpoints where you can retrieve data from your Jabmo account. For example, you can get your Jabmo live company visitors and display them as you want. To do so, here is the code sample:
List accounts
You can retrieve data from your Jabmo account. For example, you can list accounts that visited your website. In order to do so, you can use this code sample:
PHP Sample
<?php /*********************************************************** Accounts List accounts ************************************************************/ $token = 'YOUR_TOKEN'; $ch = curl_init('https://api.jabmo.com/latest/account'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'X-Auth-Token:Bearer '.$token) ); //execute request $response = curl_exec($ch); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); //close connection curl_close($ch); $accounts = json_decode($response); ?> <html> <head> <title>Accounts</title> <link rel="stylesheet" href="css/style.css"> </head> <body> <div class="main-content"> <h1>Accounts</h1> <?php if ($httpcode != 200) { echo 'Status code: '.$httpcode; echo $decodedData->message; } else { date_default_timezone_set('UTC'); echo '<table>'; echo '<tr><th>Account</th><th>Industry</th><th>Country</th><th>Date</th><th>Last Action</th><th>Target Account</th></tr>'; for($i = 0; $i < count($accounts); $i++){ echo '<tr>'; echo '<td>'.$accounts[$i]->name.'</td>'; echo '<td>'.$accounts[$i]->industry.'</td>'; echo '<td>'.$accounts[$i]->country.'</td>'; $ladate = new DateTime(); $ladate->setTimestamp(($accounts[$i]->lastActivityDate)/1000); echo '<td>'.$ladate->format('d F Y H:i:s').'</td>'; $activityType; switch ($accounts[$i]->lastActivityType) { case "website_visit": $activityType = "Website Visit"; break; case "email_viewed": $activityType = "Email Viewed"; break; case "ad_clicked": $activityType = "Ad Clicked"; break; } echo '<td>'.$activityType.'</td>'; echo '<td>'.$accounts[$i]->target.'</td>'; echo '</tr>'; } echo '</table>'; } ?> </div> </body> </html>
Add an alert recipient
Let's try to add data to your Jabmo account. Here's a code sample to add a recipient to an account alert:
PHP Sample
<?php /*********************************************************** Alert Add alert recipient ************************************************************/ $idAccount = 'ACCOUNT_ID'; $idUser = 'USER_ID'; $token = 'YOUR_TOKEN'; $data = array("id" => $idUser); $data_string = json_encode($data); //add alert recipient $ch = curl_init('https://api.jabmo.com/latest/account/'.$idAccount.'/alert-recipient/'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_TIMEOUT, 5); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data_string), 'X-Auth-Token:Bearer '.$token ) ); //execute request $response = curl_exec($ch); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); //close connection curl_close($ch); // decode json response $decodedData = json_decode($response); ?> <html> <head> <title>Add alert recipient</title> <link rel="stylesheet" href="css/style.css"> </head> <body> <div class="main-content"> <h1>Alert recipient added</h1> <p> <?php if ($httpcode != 200) { echo 'Status code: '.$httpcode; echo $decodedData->message; } else { echo $decodedData->firstName.' ' .$decodedData->lastName.'<br/>'; echo 'Email: ' .$decodedData->email; } ?> </p> </div> </body> </html>
Remove an alert recipient
Finally, let's try to remove data from your Jabmo account. To do so, you can remove a recipient from an account alert. Here's a code sample you can use:
PHP Sample
<?php /*********************************************************** Alert Remove alert recipient ************************************************************/ $idAccount = 'ACCOUNT_ID'; $idUser = 'USER_ID'; $token = 'YOUR_TOKEN'; //delete alert recepient $ch = curl_init('https://api.jabmo.com/latest/account/'.$idAccount.'/alert-recipient/'.$idUser); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); curl_setopt($ch, CURLOPT_TIMEOUT, 5); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'X-Auth-Token:Bearer '.$token) ); //execute request $response = curl_exec($ch); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); //close connection curl_close($ch); $decodedData = json_decode($response); $token = $decodedData->{'token'}; ?> <html> <head> <title>Delete alert recepient</title> <link rel="stylesheet" href="css/style.css"> </head> <body> <div class="main-content"> <h1>Alert recipient removed</h1> <p> <?php if ($httpcode != 200) { echo 'Status code: '.$httpcode; echo $decodedData->message; } else { echo $decodedData->firstName.' ' .$decodedData->lastName.'<br/>'; echo 'Email: ' .$decodedData->email; } ?> </p> </div> </body> </html>