Automated REST API Integration & Compliance Calculation Engine
Engineers spent hours manually cleaning building utility data, formatting payloads, and running repetitive external compliance/rating calculations (NABERS) across commercial portfolios—creating massive human-error risk and monthly delivery lag.
Architected an automated, zero-touch data pipeline that ingests raw multi-site operational data, performs schema validation, dynamically constructs JSON payloads, interfaces directly with external REST APIs, and parses responses into audit-ready executive outputs in seconds.
"Why embed the API engine inside an Excel / Power Query / VBA runtime architecture instead of a standalone Python CLI script? Because the end-users were operational field engineers who live inside spreadsheets. Building the REST orchestration directly into their native working environment drove 100% adoption on day one with zero local Python environment configuration or IT permission tickets required."
' =========================================================================
' Asset: Tower_Alpha_DXB // NABERS Energy API Automated Orchestration
' Sub: ExecuteCompliancePayloadDispatch(ByVal AssetID As String, ByVal TelemetryPayload As String)
' =========================================================================
Public Sub ExecuteCompliancePayloadDispatch(ByVal AssetID As String)
Dim http As Object, jsonBody As String, endpointURL As String
Dim httpStatus As Long, responseText As String, retryCount As Integer
endpointURL = "https://api.compliance-engine.internal/v2/ratings/commercial"
' Construct strictly typed JSON payload with sanitized meter telemetry
jsonBody = "{" & _
"""asset_id"": """ & AssetID & """," & _
"""assessment_period"": {""start"": ""2025-01-01"", ""end"": ""2025-12-31""}," & _
"""gross_floor_area_sqm"": 48250.0," & _
"""rated_hours_per_week"": 55.0," & _
"""half_hourly_consumption_kwh"": " & GetTelemetryStreamBuffer(AssetID) & _
"}"
Set http = CreateObject("MSXML2.ServerXMLHTTP.6.0")
' Exponential backoff retry handler for 429 / 503 HTTP responses
retryCount = 0
Do
http.Open "POST", endpointURL, False
http.setRequestHeader "Content-Type", "application/json"
http.setRequestHeader "Authorization", "Bearer " & GetSecureVaultToken()
http.setRequestHeader "X-Audit-Origin", "DXB-Asset-Automator-v2.4"
http.send jsonBody
httpStatus = http.Status
If httpStatus = 200 Or httpStatus = 201 Then
responseText = http.responseText
ParseAndCommitRatingRecord AssetID, responseText
Exit Do
ElseIf httpStatus = 429 And retryCount < 4 Then
retryCount = retryCount + 1
Sleep (2 ^ retryCount) * 1000 ' 2s, 4s, 8s backoff
Else
LogErrorToAuditLog AssetID, httpStatus, http.responseText
Err.Raise vbObjectError + 501, "API_FAULT", "HTTP Failure: " & httpStatus
End If
Loop
End Sub