Aan de slag
Met een API (Application Programming Interface) kunt u programma’s eenvoudig met elkaar verbinden of zelf uitbreidingen ontwikkelen. Onderaan deze pagina vindt u alle beschikbare commando’s.
Onze API is beschikbaar voor betalende gebruikers.
De API in- of uitschakelen
U kunt de API inschakelen in de Powertools. Na het inloggen kunt u de commando's testen voordat u ze in uw eigen app gebruikt.
De API is standaard uitgeschakeld voor accounts die via ons platform of via partners zoals Google zijn aangemaakt. Voor accounts die via een externe app zijn aangemaakt, is de API standaard ingeschakeld.
Uw app registreren
Voordat u een app kunt verbinden, dient de ontwikkelaar contact met ons op te nemen, zodat wij deze app een unieke client_id en client_name kunnen toekennen.
Onze architectuur met één enkel endpoint
We gebruiken bewust slechts één endpoint:
https://yourbuildingmanager.online/framework/_secured_api_v2.php
Hoewel dit ongebruikelijk is, maakt het de ontwikkeling van een integratie eenvoudiger: er bestaat geen twijfel over of een contract via /contracts moet worden opgehaald en of de bijbehorende betalingen via /contracts of /payments moeten worden opgehaald, enz.
We zijn ons er echter van bewust dat de OpenAPI-standaard en bepaalde apps moeilijkheden kunnen ondervinden wanneer één eindpunt zowel met als zonder authenticatie moet werken. Daarom voorzien we voor deze apps ook een afzonderlijk eindpunt zonder authenticatie:
https://yourbuildingmanager.online/framework/_secured_api_login_v2.php
Apps die een afzonderlijk eindpunt zonder authenticatie vereisen, kunnen dit gebruiken om zich aan te melden bij ons systeem.
Uw account aanmaken of verbinden
De app kan gewoon een knop voorzien. De gebruiker krijgt ons inlogscherm te zien met de vraag of die een bestaande of nieuwe account wil verbinden:
De rest verloopt automatisch tussen de app en ons platform.
De ontwikkelaars van de app dienen de nodige communicatiekanalen tussen ons platform en hun app op te zetten. Voor de API-verbinding gebruiken we de OAuth-standaard, aangevuld met enkele bijkomende gegevens om de goede werking van ons platform te garanderen.
De volgende tabel geeft een overzicht van de verwachte gegevens:
| Name | Origin | Type | Info |
|---|---|---|---|
| Resource Owner (User) | OAuth | string | The owner of the account, who has to give consent to the API connection |
| Client (app) | OAuth | string | The third-party application that request access to our platform yourbuildingmanager.online |
| Authorization Server | OAuth | string | The server that provides access tokens to the client. In this case it is the server of yourbuildingmanager.online. — Everything can be send to: https://yourbuildingmanager.online/framework/_secured_api_v2.php. — Apps that require a separate endpoint for non-authenticated requests can login via: https://yourbuildingmanager.online/framework/_secured_api_login_v2.php. |
| Resource Server (API) | OAuth | string | The server that will contain/contains the resource owner's data. The Resource Server validates the access tokens to grant the client access |
Fase 1. Autorisatieverzoek (Verstuurd naar het /authorize-eindpunt van de autorisatieserver)
De volgende tabel geeft een overzicht van de verwachte gegevens:
| Name | Origin | Type | Info |
|---|---|---|---|
| APIaction | Our platform | string | Tells our API what action you want to take |
| APIactionModes | Our platform | array | Tells our API what mode of the requested action you want to take |
| scope | OAuth | string | full access = read write |
| response_type | OAuth | string | Indicates what you want to receive back. |
| client_id | OAuth | string | The id of your app, received when you register your app with us |
| redirect_uri | OAuth | string | The URI to which our platform redirects the user. It needs to be identical as the URI registered with us! |
| code_verifier | OAuth | string | A code generated and stored within your app. It is generated in phase 1, and used in phase 3 to check the retrieved answer on its correctness |
| code_challenge | OAuth | string | A cryptographic hash of the code_verifier |
| code_challenge_method | OAuth | string | The method used to hash the PKCE (Proof Key for Code Exchange) challenge. We use 'S256' |
| user_name | Our platform | string | The displayed name of this user, used to create a new account with us if desired |
| user_email | Our platform | string | The email of this user, used to create a new account with us if desired |
De app genereert een code_verifier, die via de code_challenge_method 'S256' wordt omgezet in een code_challenge. Deze gegevens worden intern bewaard, bijvoorbeeld:
"code_verifier": "_NC96QvugVljCtNu8o9B8JIsUokGamlEsDh03STwqa0",
"code_challenge": "kJnSpDlgLZ1R97JpwnuE9Fjv_qtUvO_owMl9ZYq2gh4",
"code_challenge_method": "S256",
"state": "0123456789",
}
Deze gegevens worden vervolgens naar de autorisatieserver verzonden. Tijdens de eerste aanmelding zijn geen autorisatiegegevens vereist.
Merk op dat we naast de standaard OAuth-gegevens en openID ook de APIaction, APIactionModes, user_name en user_email opvragen, zodat gebruikers die nog geen account hebben op ons platform, dit met één klik kunnen aanmaken:
"APIaction": "API.connect",
"APIactionModes": ["connectExternalAccount"],
"scope": "read write",
"response_type": "code",
"client_id": "34K0-1LSOCKBLEWMBLWAAPEEEG3BNW",
"redirect_uri": "https://example.com/callback.php",
"state": "0123456789",
"code_challenge": "kJnSpDlgLZ1R97JpwnuE9Fjv_qtUvO_owMl9ZYq2gh4",
"code_challenge_method": "S256",
"user_name": "Steve",
"user_email": "steve@domain.com"
}
Fase 2. Callback met autorisatiecode (Teruggestuurd naar uw redirect_uri)
De volgende tabel geeft een overzicht van de verwachte gegevens:
| Name | Origin | Type | Info |
|---|---|---|---|
| code | OAuth | string | The code (authorization code) is returned after the initial authorization request. It is used to create the final connection |
| state | OAuth | string | A random string up to 200 characters generated by your app to prevent Cross-Site Request Forgery (CSRF). It is generated and stored by your app, and echoed back by our platform during security checks. The app must compare the returned state value with the original value it generated and stored. If the values do not match, the connection request must be rejected. |
Er worden een 'code' en een 'state' teruggestuurd naar de client.
"code": "3acc87d7164afb449dadc34ab6d5f5",
"state": "0123456789",
}
Aan de hand van de intern opgeslagen 'code_verifier' kan de client vervolgens controleren of het verzoek correct werd ontvangen.
Fase 3. Tokenwisselverzoek (Verstuurd via een server-side POST-verzoek naar /token)
De volgende tabel geeft een overzicht van de verwachte gegevens:
| Name | Origin | Type | Info |
|---|---|---|---|
| APIaction | Our platform | string | Tells our API what action you want to take |
| APIactionModes | Our platform | array | Tells our API what mode of the requested action you want to take |
| client_id | OAuth | string | The id of your app, received when you register your app with us |
| grant_type | OAuth | string | Must be set to 'authorization_code' |
| code | OAuth | string | The code (authorization code) is returned after the initial authorization request. It is used to create the final connection |
| code_verifier | OAuth | string | A code generated and stored within your app. It is generated in phase 1, and used in phase 3 to check the retrieved answer on its correctness |
| redirect_uri | OAuth | string | The URI to which our platform redirects the user. It needs to be identical as the URI registered with us! |
Stuur vervolgens onderstaande gegevens naar ons platform:
"APIaction": "API.connect",
"APIactionModes": ["APItokenExchange"],
"client_id": "34K0-1LSOCKBLEWMBLWAAPEEEG3BNW",
"grant_type": "authorization_code",
"code": "3acc87d7164afb449dadc34ab6d5f5",
"code_verifier": "_NC96QvugVljCtNu8o9B8JIsUokGamlEsDh03STwqa0"
}
Fase 4. Tokenrespons (Teruggestuurd als JSON vanuit het token-eindpunt)
De volgende tabel geeft een overzicht van de verwachte gegevens:
| Name | Origin | Type | Info |
|---|---|---|---|
| access_token | OAuth | string | This token is valid for 1 hour. If expired, the app has to request a new one via the refresh_token. |
| expires_in | OAuth | string | The lifetime of the access_token in seconds. |
| refresh_token | OAuth | string | This token is valid for 90 days. If expired, the user has to re-authenticate. |
| refresh_token_expires_in | OAuth | string | The lifetime of the refresh_token in seconds. |
| scope | OAuth | string | full access = read write |
| message | Our platform | string | Always present in the response. It provides additional information from our platform regarding the processing of the request |
Als antwoord ontvangt u de 'access_token' en de 'refresh_token'. De 'access_token' moet u bij elk verzoek aan ons platform meesturen in twee HTTP-headers: HTTP_AUTHORIZATION met de 'access_token' als waarde en HTTP_X_API_CLIENT met de waarde 'external'.
"access_token": YJ4TRKO9PLKTK87KA34AKAIK75SA",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "242RG-BNQV9VNWNPPWAVHW-D_WOIBVOSDBSUBES",
"refresh_token_expires_in": 7776000,
"scope": "read write",
"message": "The token is attached to this message."
}
Fase 5. Tokens vernieuwen
De volgende tabel geeft een overzicht van de verwachte gegevens:
| Name | Origin | Type | Info |
|---|---|---|---|
| APIaction | Our platform | string | Tells our API what action you want to take |
| APIactionModes | Our platform | array | Tells our API what mode of the requested action you want to take |
| client_id | OAuth | string | The id of your app, received when you register your app with us |
| refresh_token | OAuth | string | This token is valid for 90 days. If expired, the user has to re-authenticate. |
De 'access_token' is één uur geldig. Daarna moet uw app via de 'refresh_token' een nieuwe code ophalen. Gebruik het volgende commando om een nieuwe 'access_token' op te halen:
"APIaction": "API.connect",
"APIactionModes": ["APItokenRefresh"],
"client_id": "34K0-1LSOCKBLEWMBLWAAPEEEG3BNW",
"refresh_token": "9c1402e23d8566b1093492de5a98ddf362b55fc03f42cb7ffe698f125081c635"
}
U ontvangt hetzelfde antwoord als in fase 4, maar dan met andere tokens.
Informatie uitwisselen
De volgende tabel geeft een overzicht van de verwachte gegevens:
| Name | Origin | Type | Info |
|---|---|---|---|
| HTTP_AUTHORIZATION | OAuth | string | A standard HTTP header, marked as 'Bearer ', that contains your retrieved 'access_token'. |
| HTTP_X_API_CLIENT | Our platform | string | A standaard HTTP header with the required value: external. The request gets rejected if the value is incorrect. |
| APIaction | Our platform | string | Tells our API what action you want to take |
| APIactionModes | Our platform | array | Tells our API what mode of the requested action you want to take |
| client_id | OAuth | string | The id of your app, received when you register your app with us |
| success | Our platform | boolean | Always present in the response. It provides additional information from our platform regarding the processing of the request |
| message | Our platform | string | Always present in the response. It provides additional information from our platform regarding the processing of the request |
| data | Our platform | array or string | The data retrieved from our platform. It can be of any form, depending on what was requested. It is most of the times present, except on an error, or e.g. when a downloadable file was requested |
| link | Our platform | string | The page to which the user should be redirected in some cases. It is only present when a redirect or navigation is required, and often only when the user uses the web interface. |
| download_url | Our platform | string | The link from which a file can be downloaded. It is only present when explicitly asking for a file |
Stuur vervolgens gewoon de onderstaande informatie naar https://yourbuildingmanager.online/framework/_secured_api_v2.php.
Let op: elk verzoek, met uitzondering van het inloggen, vereist authenticatie via HTTP-headers!
HTTP_X_API_CLIENT = external
JSON
{
"APIaction": "API.buildings.retrieve",
"APIactionModes": ["default"],
"client_id": "34K0-1LSOCKBLEWMBLWAAPEEEG3BNW",
[add required variables (see below)],
[add optional variables (see below)],
}
Let op de `APIaction` en `APIactionModes`. De actie vertelt ons platform wat u wilt doen. De mode vertelt welke variant u hiervan wilt uitvoeren. Afhankelijk van de actie en mode zijn bijkomende gegevens vereist of mogelijk, zoals de referentie van uw gebouw in build_ref. Deze kunt u toevoegen aan de gegevens die u doorstuurt.
Elke API-actie retourneert een antwoord volgens onderstaande structuur:
{
"success": true,
"message": "Your data has been retrieved",
"data": ["retrieved data"],
"link": "https://example.com/page_to_go_to.php",
"download_url": "https://example.com/file_to_download.php"
}
Beschikbare acties
Een AI of agent kan onze API leren kennen door de technische documentatie te raadplegen op de OpenAPI-pagina.
De voor mensen leesbare documentatie is ingedeeld per onderwerp:
- Connect to our platform
- Handle buildings
- Handle contracts
- Handle files
- Handle logs
- Handle units
- Handle user accounts
- Retrieve legislation
Beperkingen op het API-gebruik
We vragen je vriendelijk om het gebruik van onze API te beperken tot wat daadwerkelijk nodig is. Haal bijvoorbeeld gegevens alleen op wanneer de gebruiker hierom vraagt, of voer maximaal één automatische update per 24 uur uit. De meeste gegevens op ons platform worden zelf ook slechts eenmaal per 24 uur opgehaald.
Bij overmatig of onnodig API-gebruik behouden we ons het recht voor om de API-toegang in te trekken.