MoeilijkheidsgraadDifficulty: expert

Ga naar
Inhoud

Content

Table of Contents
minLevel1
maxLevel1

Leerdoelen

Na het lezen van dit artikel zul je in staat zijn om:

  • begrijpen wat API's voor Workplace kunnen doen

  • workplace API's testen

API staat voor Application Programming Interface en maakt eenvoudige uitwisseling van gegevens en functionaliteit mogelijk. De Workplace API documentatie (Swagger) is beschikbaar in een apart tabblad in het GO menu.

Hoe krijg ik toegang tot de API van Workplace?

Learning Objectives

After reading this article, you’ll be able to:

  • understand what Workplace APIs can do

  • test Workplace APIs


API stands for Application Programming Interface and allows easy exchange of data and functionality. The Workplace API documentation (Swagger) is available in a separate tab in the GO menu.

How to access Workplace API

De optie verschijnt alleen voor gebruikers met een ontwikkelaars- of beheerdersrol. Zie Roles & Profiles voor meer informatie.

Image RemovedOm de API's in je eigen projecten te gebruiken (bijvoorbeeld postman), is het misschien interessant om de
  • Login with your credentials

The option appears only for users who have a developer or admin role assigned to them. See Roles & Profiles for more information.

Image Added

To use the APIs in your own projects (eg postman), you might be interested to use the swagger.json-link te gebruiken. Zoals je in de schermafbeelding kunt zien, wordt de "nieuwste" pagina standaard geopend, maar dit kan natuurlijk veranderen.

NoteGebruik genummerde versies (bijv.

. As you can see in the screenshot, "latest" page opens per default, but this is of course subject to change.

Note

Use numbered versions (eg https://go.cobundu.com/rest/v3/docs) om conflicten te vermijden.

Het gebruik van een specifieke versie heeft het voordeel dat je in de toekomst API-versies kunt vergelijken.

Image Removed

De API testen: voorbeelden

Het is mogelijk om de API van Workplace uit te proberen/te testen. Afhankelijk van het verzoek moet je misschien eerst wat informatie invullen.

Voorbeeld 1. De lijst met sensorapparaten ophalen

  1. Selecteer "Uitproberen",

  2. en vervolgens "Uitvoeren",

  3. om een lijst te krijgen van alle sensorapparaten die momenteel aan deze huurder zijn gekoppeld.

Zoals je in het voorbeeld kunt zien, wordt elk sensorkanaal (bv. vochtigheid, temperatuur en CO2 in een comfortsensor) afzonderlijk geleverd.

Image Removed

Voorbeeld 2. De huidige sensorgegevens voor een locatie ophalen

  1. Selecteer "Uitproberen",

  2. Voeg de verplichte locatie-ID toe

  3. en vervolgens "Uitvoeren",

  4. om de huidige sensorgegevens op te halen van alle sensoren die gekoppeld zijn aan die locatie.

Zoals je in het voorbeeld kunt zien, is er 1 comfortsensor gekoppeld aan de opgevraagde locatie. Daarom worden alle beschikbare kanaalwaarden voor deze sensor (temperatuur en vochtigheid in dit geval) geleverd, evenals de tijdstempel waarvoor deze waarden werden ontvangen.

Image Removed
In de onderstaande voorbeelden wordt "locatie-ID" genoemd. Een locatie selecteren op

to avoid conflicts.

Using a specific version has the advantage of being able to compare API versions in future.

image-20240524-135305.pngImage Added

Note

For every API method, make sure to chose the latest version

Status September 2024

Testing the API: examples

It's possible to try out/test the Workplace API. Depending on the request, you might need to fill in some information first.

Example 1. Get the list of sensor devices

  1. Select "Try it out",

  2. then "Execute",

  3. to get a list of all sensor devices currently linked to this tenant.

As you can see in the example, each sensor channel (eg humidity, temperature and CO2 in a comfort sensor) is delivered separately.

image-20240524-135529.pngImage Added

Example 2. Get the current sensor data for a location

  1. Select "Try it out",

  2. Add the mandatory location ID

  3. then "Execute",

  4. to get the current sensor data of all sensors that are linked to that location.

As you can see in the example, 1 comfort sensor is linked to the requested location. Therefore all channel values available for this sensor (temperature and humidity in this case) are delivered, as well as the timestamp for which these values were received.

image-20240524-135801.pngImage Added

Below examples mention “location ID”. Selecting a location on https://go.cobundu.com/ wordt de referentie weergegeven, bijvoorbeeld "Vergaderzaal will show the Reference, e.g. "Meeting Room 1". Maar But in de the Workplace back-end van Workplace heeft elke locatie een unieke locatie-, each location has a unique location ID.

Info

Locatie-Location ID is beschikbaar available in de the Workplace back-end van Workplace https://studio.cobundu.com URL voor elke geselecteerde locatie.

Bijvoorbeeld de Locatie ID voor verdieping "2e verdieping" in Spacewell Antwerpen is "910000000004545".

Image Removed

Voorbeeld 3. Reserveringen

Om de reserveringen uit je omgeving op te halen, kun je Reservations API > "een lijst met reserveringen ophalen" gebruiken.
Wijzig de datums in de zoekinstructie om (gefilterde) reserveringen te krijgen, elk met de locatie-ID, om zo aan te geven welke locatie is geboekt.
Voer locatie-id's in het zoekfilter in om gefilterde gegevens te krijgen.

Voorbeeld 4. Locatie-informatie opvragen

Een locatie selecteren op

for each selected location.

For example the Location ID for floor “2nd floor” in Spacewell Antwerp offices is “910000000004545”

Image Added

Example 3. Reservations

To retrieve the reservations from your environment, you can use Reservations API > "get a list of bookings".
Modify dates in the search instruction and to get (filtered) reservations, each including the location ID, thus indicating which location was booked.
Enter location IDs in the search filter to get filtered data.

Example 4. Get location information

Selecting a location on https://go.cobundu.com/ wordt de referentie weergegeven, bijvoorbeeld "Vergaderzaal will show the Reference, e.g. "Meeting Room 1". Maar But in de the Workplace back-end van Workplace heeft elke locatie een unieke locatie-, each location has a unique location ID.


Locations API kan je helpen die informatie te krijgen.
Afhankelijk van wat er nodig is:

  • een lijst met locaties krijgen voor deze klant

  • specifieke locatie-informatie opvragen (bijvoorbeeld informatie over een reeks "workplace"

    can help you get that information.
    Depending on what is needed:

    • get a list of locations for this client

    • request specific location information (for example information on a set of workplaces): "get location tree" (filter top-level resultaten results = workplace)

    Voorbeeld Example 5. PlattegrondOm een plattegrond van de workplace te krijgen, selecteer je Floor plan

    To get a Workplace floor plan, select API Locations > "get a location's drawing as SVG".
    De gevraagde locatie-ID is in dit geval de verdiepings-
    The requested location ID in this case is the floor ID.
    "TestenTesting" in swagger geeft een antwoord, maar kan de SVG niet weergeven. Voer de vloerlocatie-ID in de volgende URL in om de SVG te zienwill provide a response, but it cannot show the SVG.

    Enter the floor location ID in following URL to see the SVG: https://go.eu1.cloud.cobundu.com/rest/latestv3/locations/vloer locatie floor location ID/tekeningendrawing/svg

    Concrete use case: URL

    om live plattegrond te tonen

    Stel je voor dat je een URL naar je kioskschermen wilt pushen om live gegevens van de Workplace plattegrond te visualiseren.

    Hier stellen we voor om een toegangstoken met een URL op te geven, zodat iedereen met de link de live plattegrond kan zien.

    Alternatieve methoden en veelgestelde vragen hierover vind je hier

    to show live floorplan

    Imagine you want to push a URL to your kiosk screens to visualize Workplace live floorplan data.

    Here, we suggest to provide an access token with a URL, so that anyone with the link can see the live floorplan.

    Alternative methods and Frequently Asked Questions about this can be found here: Workplace live floorplan data visualization

    De hieronder voorgestelde speciale methode omvat webauthenticatie The below suggested dedicated method includes web authentication via Rest API. Dit betekent dat een workplace login + wachtwoord nodig zijn, en de API retourneert een JWT token dat kan worden gebruikt om toegang te krijgen tot alle andere API-aanroepen.

    Vereisten

    • Webkiosk moet worden geconfigureerd in Studio

    • Per verdieping waarvoor je visualisatie wilt instellen, is een Workplace gebruiker nodig:

      • Minimale rechten op de workplace/geen specifieke rol nodig

      • rekening houdend met reserveringsfuncties die zijn ingesteld voor deze omgeving

      • Gebruikersnaam + wachtwoord

    • Om toegang te krijgen tot API: Workplace gebruiker met een Admin of Developer rol

    Oplossing

    API gebruiken om sessietoken te krijgen

    Ga naar http://go.cobundu.com (gebruiker heeft een beheerders- of ontwikkelaarsrol nodig) > API

    Selecteer "auth" > /rest/latest

    This means a Workplace login + password are needed, and the API will return a JWT token which can be used to access all other API calls. For an authorization-related action we have the COBUNDU Authorization service. It has public Swagger UI (and swagger.json-link) available at https://login.cobundu.com/rest/v2/docs. You may use the API via Swagger UI or Postman, or any other tool of your choice. This example is based on our Swagger UI.

    Note

    For every auth-based API method, make sure to choose the latest version (status September 2024: v2 is the latest, so refer to https://login.cobundu.com/rest/v2/docs)

    Prerequisites

    • Web kiosk needs to be configured in Studio

    • Per floor for which you want to set up visualization, a Workplace user is needed:

      • Workplace minimum rights/no specific role needed

      • taking into account reservation features set up for this environment

      • User name + password

    • To access API: Workplace user with either Admin or Developer role

    Solution

    Zoek op
    1. Using API to get session token

      1. Go to https://login.cobundu.com/rest/v2/docs (user needs either Admin or Developer role)

        http
        1. Select "auth" > /auth/ssosettings/{loginId} (retourneer sso-instellingen voor de gebruiker)

        2. Geef gebruikersnaam

        3. De respons geeft de hostnaam van de cobundu SSO-instantie die moet worden gebruikt return sso settings for the user)

        4. Provide user name

        5.  Response body will provide the host name of COBUNDU Auth instance that needs to be used (Workplace IoT Platform is beschikbaar voor de EU en de VS) (kan bijvoorbeeld available for EU and US) (could be eg  "apiUrl" zijn: https://gologin.eu1.cloud.cobundu.com)

        6. Image Removed

        Nog steeds op
        1. image-20240910-073257.pngImage Added
      2. Navigate to the apiUrl + /rest/v2/docs from previous step that is https://gologin.eu1.cloud.cobundu.com (gebruiker heeft een beheerders- of ontwikkelaarsrol nodig) > API

        Selecteer

        /rest/v2/docs is this example (user needs either Admin or Developer role)

        Ga naar
        1. Select "auth" > /rest/latestauth/login (gebruiker authenticerenauthenticate user)

        2. Geef de gebruikersnaam + het wachtwoord op dat wordt gebruikt om toegang te krijgen tot live gegevens

        3. Wijzig de aanmeldingsparameters Specify username + password that will be used to access live data

        4. Change the login parameter "rememberme": true, "setCookie": true

          Image Removed
        5. De respons bevat accessToken

        6. Image Removed
        7. Toegangstoken is klaar voor gebruik

      URL voor webkiosk voorbereiden

        1. The rest field can be removed. Example (try not to leave a comma in the end of the password line):

          image-20240910-073146.pngImage Added

        2.  Response body will provide accessToken

          image-20240910-073431.pngImage Added

        3. Access token is ready to be used

    2. Prepare Web kiosk URL

      1. Go to http://go.cobundu.com (gebruiker heeft de rol van beheerder of ontwikkelaar nodig) > KioskmodusSelecteer de relevante verdieping > open webkioskuser needs either Admin or Developer role) > Kiosk Mode

      2. Select the relevant floor > open web kiosk

      3. Web Kiosk URL heeft het volgende formaat will have format https://go.cobundu.com/kiosk/MEETING%7C1d18e8b0-48a7-464c-8813-66608b474d6d Vervang het hoofddomein van de URL om het juiste cloud-eindpunt (EU of VS) aan te geven, dan krijg je bijv.

      4. In a browser navigate to https://go.cobundu.com/rest/serverinfo or in Postman make a request to https://go.cobundu.com/rest/serverinfo?jwt= and copy/paste accessToken at the end of the URL

        image-20240910-073939.pngImage Added

      5. The apiUrl contains a correct cloud end-point for you account (EU or US). Replace go.cobundu.com in your Web Kiosk URL with this region apiUrl, you'll obtain eg https://go.eu1.cloud.cobundu.com/kiosk/MEETING| ...

      6. Voeg achtervoegsel Add suffix "?jwt=" toe en kopieer/plak accessToken aan het einde van de and copy/paste accessToken at the end of the URL

    3. Toegang tot deze Access this URL (bijvoorbeeld for example in incognitomodus) en de webkiosk zal openen op de gekozen verdieping zonder om identificatie te vragen. Elke 10 minuten wordt een sessie vernieuwd binnen de toepassing.

    4. Nadat de token is verkregen, heb je 10 minuten om deze door te geven in de URL om de plattegrond te openen.

    5. Nadat de plattegrond is geladen, wordt het vernieuwen van de token automatisch uitgevoerd zonder sessieverlies of handmatige tussenkomst.

    Beperkingen

    • Webkiosk toont reserveringsweergave (= gecombineerde bezettingsgraad- en reserveringsgegevens (indien beschikbaar))

    • Als browser crasht/computer is losgekoppeld: herstart het proces om een nieuw toegangstoken te krijgen

    1. incognito mode), and the web kiosk will open on the chosen floor without asking for identification. A session refresh will run inside the application every 10 minutes.

      1. After the token is obtained, there are 10 minutes to pass it in the URL to open the floor plan.

      2. After the floor plan is loaded, further token renewal will run automatically without session loss or any manual intervention.

    Limitations

    • Web kiosk shows Reservation view (= combined Occupancy and Reservations data (if available))

    • If browser crashes/computer is unplugged: restart the process to get a new access token


    Search

    Live Search