Public API – GET Beacon

GET all Beacons

/**
 * @author Bluedot Innovation
 * Copyright (c) 2016 Bluedot Innovation. All rights reserved.
 * Get All Beacons client demonstrates listing all the Beacons added to the customer's account from Bluedot backend
 * using 'request' node module.
 */
var request = require('request');
var bdCustomerApiKey = "7cd1ea80-d40e-11e4-84cb-b8ca3a6b879d"; //This key is generated by Bluedot Point Access UI when your account is created
var options = {
    uri: 'https://api.bluedotinnovation.com/1/beacons?customerApiKey=' + bdCustomerApiKey,
    method: 'GET'
};
request ( options,
    function (error, response, body) {
        if (error) {
            console.log(error);
        }
        var result = response.body;
        if( typeof result !== 'string' ) {
            console.log("Error in response");
            return;
            result = JSON.stringify(result)
        }
        console.log(result);
    }
);

GET a specific Beacon

/**
 * @author Bluedot Innovation
 * Copyright (c) 2016 Bluedot Innovation. All rights reserved.
 * Get Beacon client demonstrates listing a Beacon for a given beaconId for a customer's account from Bluedot backend 
 * using 'request' node module.
 */
var request = require('request');
var bdCustomerApiKey = "7cd1ea80-d40e-11e4-84cb-b8ca3a6b879d"; //This key is generated by Bluedot Point Access UI when your account is created
var bdBeaconId = "11146bf3-b894-4491-9ef1-4f151f782730"; // This is the ID of the Beacon being retrieved.
var options = {
    uri: 'https://apiuat2.bluedotinnovation.com/1/beacons?customerApiKey=' + bdCustomerApiKey + '&beaconId=' + bdBeaconId,
    method: 'GET'
};
request ( options,
    function (error, response, body) {
        if (error) {
            console.log(error);
        }
        var result = response.body;
        if( typeof result !== 'string' ) {
            console.log("Error in response");
            return;
            result = JSON.stringify(result)
        }
        console.log(result);
    }
);

GET all Beacons

package com.bluedotinnovation.beacon;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import com.bluedotinnovation.common.BDCommon;
/**
 * @author Bluedot Innovation
 * Copyright (c) 2016 Bluedot Innovation. All rights reserved.
 * Get All Beacons client demonstrates listing all the Beacons added to the customer's account from Bluedot backend
 * using Apache HTTP client and JSON Simple libraries.
 */
public class GetAllBeacons extends BDCommon {
    public static void main(String[] args) throws IOException, KeyManagementException, NoSuchAlgorithmException, ParseException {
         
        String bdCustomerApiKey     = "7cd1ea80-d40e-11e4-84cb-b8ca3a6b879d"; //This key is generated by Bluedot Point Access UI when your account is created
        String bdRestUrl            = "https://api.bluedotinnovation.com/1/beacons?customerApiKey=" + bdCustomerApiKey;
        CloseableHttpClient httpRestClient = HttpClients.custom().setSSLSocketFactory(getSSLContextFactory()).build();
        HttpGet request       = new HttpGet(bdRestUrl);
        HttpResponse response = httpRestClient.execute(request);
        BufferedReader rd     = new BufferedReader (new InputStreamReader(response.getEntity().getContent()));
        JSONParser parser          = new JSONParser();
        String bdApplicationJSON = "";
        while ((bdApplicationJSON = rd.readLine()) != null) {
            Object object = parser.parse(bdApplicationJSON);
            JSONArray bdApplicationJsonArray = (JSONArray) object;
            for (Object applicationObject : bdApplicationJsonArray){
                JSONObject jsonObject =  (JSONObject) applicationObject;
                System.out.println("Beacon name : " + jsonObject.get("name"));
                System.out.println("Beacon ID: " + jsonObject.get("beaconId"));
                System.out.println("Latitude: " + jsonObject.get("latitude"));
                System.out.println("Longitude: " + jsonObject.get("longitude"));
                System.out.println("Description: " + jsonObject.get("description"));
                System.out.println("---------\n");
            }
        }
    }
}

GET a specific Beacon

package com.bluedotinnovation.beacon;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import com.bluedotinnovation.common.BDCommon;
/**
 * @author Bluedot Innovation
 * Copyright (c) 2016 Bluedot Innovation. All rights reserved.
 * Get Beacon client demonstrates listing a Beacon for a given beaconId for a customer's account from Bluedot backend
 * using Apache HTTP client and JSON Simple libraries.
 */
public class GetBeacon extends BDCommon {
    public static void main(String[] args) throws IOException, KeyManagementException, NoSuchAlgorithmException {
         
        String bdCustomerApiKey = "7cd1ea80-d40e-11e4-84cb-b8ca3a6b879d"; //This key is generated by Bluedot Point Access UI when your account is created
        String bdBeaconId       = "11146bf3-b894-4491-9ef1-4f151f782730"; //This is the ID of the Beacon which is created when the Beacon is configured on Bluedot Backend
        String bdRestUrl        = "https://api.bluedotinnovation.com/1/beacons?customerApiKey=" +bdCustomerApiKey + "&beaconId=" + bdBeaconId;
        CloseableHttpClient httpRestClient = HttpClients.custom().setSSLSocketFactory(getSSLContextFactory()).build();
        HttpGet request       = new HttpGet(bdRestUrl);
        HttpResponse response = httpRestClient.execute(request);
        BufferedReader rd     = new BufferedReader (new InputStreamReader(response.getEntity().getContent()));
        String line           = "";
        while ( (line = rd.readLine()) != null ) {
             System.out.println(line);
        }
    }
}

GET all Beacons

using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Net;
using System.IO;
using System.Web.Script.Serialization;
/**
 * @author Bluedot Innovation
 * Copyright (c) 2016 Bluedot Innovation. All rights reserved.
 * Get All Beacons client demonstrates listing for all Beacons for a given customer.
 */
namespace BluedotPublicApiClient.beaconclient
{
    public class GetAllBeacons
    {
        private static String customerApiKey = "ca4c8d11-6942-11e4-ba4b-a0481cdc3311"; //This key is generated by Bluedot Point Access UI when your account is created
        String bdRestUrl                     = "https://api.bluedotinnovation.com/1/beacons?customerApiKey=" + customerApiKey;
        public void getAllBeaconsForCustomer()
        {
            HttpClient httpRestClient = new HttpClient();
            HttpResponseMessage serverResponse = httpRestClient.GetAsync(new Uri(bdRestUrl)).Result;
            if (serverResponse.IsSuccessStatusCode)
            {
                var result = serverResponse.Content.ReadAsStringAsync().Result;
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                dynamic beacons = serializer.Deserialize(result, typeof(object)); // Result is an array of json
                foreach (var beacon in beacons)
                {
                    Console.WriteLine("Beacon Id : {0} ", beacon["beaconId"]);
                    Console.WriteLine("Beacon name : {0} ", beacon["name"]);
                    Console.WriteLine("Latitude : {0} ", beacon["latitude"]);
                    Console.WriteLine("Longitude : {0} ", beacon["longitude"]);
                    Console.WriteLine("---------\n");
                }
            }
            else
            {
                Console.WriteLine("{0} ({1})", (int)serverResponse.StatusCode, serverResponse.Content.ReadAsStringAsync().Result);
            }
        }
    }
}

GET a specific Beacon

using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Net;
using System.IO;
using System.Web.Script.Serialization;
/**
 * @author Bluedot Innovation
 * Copyright (c) 2016 Bluedot Innovation. All rights reserved.
 * Get Beacon client demonstrates listing a Beacon for a given beaconId for a customer's account from Bluedot backend.
 */
namespace BluedotPublicApiClient.beaconclient
{
    public class GetBeacon
    {
        private static String beaconId       = "b817bb5d-4b58-4f41-be5f-528fd4c7c95c"; //This is the ID of the Beacon being retrieved.
        private static String customerApiKey = "ca4c8d11-6942-11e4-ba4b-a0481cdc3311"; //This key is generated by Bluedot Point Access UI when your account is created
        String bdRestUrl                     = "https://api.bluedotinnovation.com/1/beacons?customerApiKey=" + customerApiKey + "&beaconId=" + beaconId;
        public void getBeacons()
        {
            HttpClient httpRestClient = new HttpClient();
            HttpResponseMessage serverResponse = httpRestClient.GetAsync(new Uri(bdRestUrl)).Result;
            if (serverResponse.IsSuccessStatusCode)
            {
                var result = serverResponse.Content.ReadAsStringAsync().Result;
                Console.WriteLine("{0}", result);
            }
            else
            {
                Console.WriteLine("{0} ({1})", (int)serverResponse.StatusCode, serverResponse.Content.ReadAsStringAsync().Result);
            }
        }
    }
}
Created by Bluedot DevOps on March 3, 2018

Start the discussion