CHAPTER 5
Building upon the standardized data formats established in Phase 1, Phase 2 of WIA-BEMS defines comprehensive API interfaces that enable applications to access, control, and manage building energy systems. These RESTful APIs eliminate the need for custom integration code, enable a competitive marketplace of applications, and provide the foundation for sophisticated energy management solutions.
This chapter explores the complete Phase 2 API specification, examining endpoint design, authentication mechanisms, real-time capabilities, and implementation best practices that ensure secure, performant, and reliable building energy management systems.
WIA-BEMS Phase 2 APIs follow RESTful design principles that make them intuitive, consistent, and easy to implement across different programming languages and platforms.
APIs are organized around resources (buildings, meters, sensors, equipment) rather than actions. Each resource has a unique URL and supports standard HTTP methods (GET, POST, PUT, DELETE) with consistent, predictable behavior.
Each API request contains all information necessary to process it. Servers don't maintain session state, enabling horizontal scaling and simplifying client implementation. Authentication tokens provide secure, stateless identity verification.
APIs use standard HTTP status codes consistently: 200 for success, 201 for resource creation, 400 for client errors, 401 for authentication failures, 404 for not found, 500 for server errors. This consistency enables generic error handling in client applications.
Responses include hypermedia links that guide clients to related resources and available actions. This makes APIs self-documenting and enables clients to navigate relationships without hardcoding URLs.
Phase 2 defines comprehensive endpoints for all building energy management operations. Let's examine the key endpoint categories.
GET /api/v1/buildings
List all buildings accessible to the authenticated user.
GET /api/v1/buildings?limit=50&offset=0&sort=name
Response: 200 OK
{
"buildings": [
{
"building_id": "BLDG-001",
"name": "Headquarters Tower",
"address": {
"street": "123 Energy Way",
"city": "San Francisco",
"state": "CA",
"zip": "94102"
},
"area_sqm": 25000,
"floors": 10,
"type": "commercial_office",
"year_built": 2018,
"certifications": ["LEED Gold", "Energy Star"],
"links": {
"self": "/api/v1/buildings/BLDG-001",
"meters": "/api/v1/buildings/BLDG-001/meters",
"equipment": "/api/v1/buildings/BLDG-001/equipment",
"energy": "/api/v1/buildings/BLDG-001/energy"
}
}
],
"pagination": {
"total": 125,
"limit": 50,
"offset": 0,
"next": "/api/v1/buildings?limit=50&offset=50"
}
}
GET /api/v1/buildings/{building_id}
Get detailed information about a specific building.
PUT /api/v1/buildings/{building_id}
Update building information (requires admin permissions).
GET /api/v1/buildings/{building_id}/energy
Query energy consumption data with flexible filtering.
GET /api/v1/buildings/BLDG-001/energy?
start=2025-01-01T00:00:00Z&
end=2025-01-31T23:59:59Z&
interval=1h&
meter_id=METER-E-301
Response: 200 OK
{
"building_id": "BLDG-001",
"query": {
"start": "2025-01-01T00:00:00Z",
"end": "2025-01-31T23:59:59Z",
"interval": "1h",
"meter_id": "METER-E-301"
},
"data": [
{
"timestamp_start": "2025-01-01T00:00:00Z",
"timestamp_end": "2025-01-01T01:00:00Z",
"energy_kwh": 125.5,
"cost_usd": 18.75,
"quality": "verified"
},
{
"timestamp_start": "2025-01-01T01:00:00Z",
"timestamp_end": "2025-01-01T02:00:00Z",
"energy_kwh": 118.2,
"cost_usd": 17.73,
"quality": "verified"
}
],
"summary": {
"total_energy_kwh": 95240.5,
"total_cost_usd": 14286.08,
"avg_power_kw": 128.0,
"peak_power_kw": 205.3,
"data_completeness": 99.8
}
}
| Query Parameter | Type | Description | Example |
|---|---|---|---|
| start | ISO 8601 timestamp | Start of query period | 2025-01-01T00:00:00Z |
| end | ISO 8601 timestamp | End of query period | 2025-01-31T23:59:59Z |
| interval | Duration string | Aggregation interval | 15m, 1h, 1d |
| meter_id | String | Filter by specific meter | METER-E-301 |
| floor | Integer | Filter by floor | 3 |
| zone | String | Filter by zone | East-Wing |
GET /api/v1/buildings/{building_id}/realtime
Establish WebSocket connection for real-time data streaming.
// WebSocket connection
ws://api.example.com/api/v1/buildings/BLDG-001/realtime
// Subscribe to data streams
{
"action": "subscribe",
"streams": [
{
"type": "power_demand",
"meter_id": "METER-E-301",
"sample_rate": "1s"
},
{
"type": "temperature",
"zone": "Conference-Room-A",
"sample_rate": "30s"
}
]
}
// Receive real-time updates
{
"stream_id": "power_demand_METER-E-301",
"timestamp": "2025-01-15T14:30:00.000Z",
"data": {
"power_kw": 150.25,
"voltage_v": 480,
"current_a": 320,
"power_factor": 0.92
}
}
GET /api/v1/buildings/{building_id}/equipment
List all controllable equipment in building.
POST /api/v1/buildings/{building_id}/equipment/{equipment_id}/commands
Send control commands to equipment.
POST /api/v1/buildings/BLDG-001/equipment/AHU-301/commands
{
"command": "set_temperature",
"parameters": {
"supply_air_temp_setpoint_c": 14.0
},
"authorization": {
"override_reason": "Optimization test",
"duration_minutes": 60
}
}
Response: 202 Accepted
{
"command_id": "cmd-12345",
"status": "accepted",
"equipment_id": "AHU-301",
"estimated_completion": "2025-01-15T14:30:15Z",
"links": {
"status": "/api/v1/commands/cmd-12345"
}
}
POST /api/v1/buildings/{building_id}/analytics
Request analytics calculations or optimization recommendations.
POST /api/v1/buildings/BLDG-001/analytics
{
"analysis_type": "energy_optimization",
"parameters": {
"target_metric": "cost_reduction",
"constraint": "maintain_comfort",
"horizon_hours": 24
}
}
Response: 200 OK
{
"analysis_id": "ana-67890",
"recommendations": [
{
"action": "adjust_hvac_schedule",
"equipment_id": "AHU-301",
"current_setting": "24/7 operation",
"recommended_setting": "7am-7pm weekdays only",
"projected_savings_kwh": 450,
"projected_savings_usd": 67.50,
"confidence": 0.87
},
{
"action": "reduce_lighting_levels",
"zone": "Open-Office-East",
"current_setting": "100% brightness",
"recommended_setting": "75% brightness",
"projected_savings_kwh": 125,
"projected_savings_usd": 18.75,
"confidence": 0.95
}
],
"summary": {
"total_savings_kwh": 575,
"total_savings_usd": 86.25,
"payback_period_days": 0,
"risk_level": "low"
}
}
Security is paramount in building energy management APIs. Phase 2 specifies comprehensive authentication and authorization mechanisms.
WIA-BEMS uses OAuth 2.0 for authentication, supporting multiple grant types for different use cases.
// Authorization Code Flow (for user applications)
POST /oauth/token
{
"grant_type": "authorization_code",
"code": "AUTH_CODE_FROM_AUTHORIZATION_ENDPOINT",
"client_id": "your_client_id",
"client_secret": "your_client_secret",
"redirect_uri": "https://yourapp.com/callback"
}
Response: 200 OK
{
"access_token": "eyJhbGciOiJSUzI1NiIs...",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "tGzv3JOkF0XG5Qx2TlKWIA",
"scope": "building:read energy:read equipment:control"
}
// Client Credentials Flow (for service accounts)
POST /oauth/token
{
"grant_type": "client_credentials",
"client_id": "service_account_id",
"client_secret": "service_account_secret",
"scope": "building:read energy:read"
}
// Use token in API requests
GET /api/v1/buildings/BLDG-001/energy
Authorization: Bearer eyJhbGciOiJSUzI1NiIs...
Fine-grained permissions control what users and applications can access and modify.
| Role | Permissions | Typical Use Case |
|---|---|---|
| Viewer | Read building data, energy consumption | Dashboard displays, reporting tools |
| Operator | Viewer + send commands, adjust setpoints | Building operators, facility managers |
| Administrator | Operator + configure devices, manage users | System administrators, integrators |
| Energy Manager | Viewer + analytics, optimization requests | Energy consultants, analysts |
| Service Account | Configurable per application | Automated systems, integrations |
Comprehensive error handling ensures applications can gracefully handle failures and provide useful feedback to users.
// Example error response
Response: 400 Bad Request
{
"error": {
"code": "INVALID_PARAMETER",
"message": "The 'interval' parameter must be one of: 1m, 5m, 15m, 1h, 1d",
"details": {
"parameter": "interval",
"provided_value": "2h",
"allowed_values": ["1m", "5m", "15m", "1h", "1d"]
},
"timestamp": "2025-01-15T14:30:00Z",
"request_id": "req-abc123"
}
}
| HTTP Code | Error Code | Description | Client Action |
|---|---|---|---|
| 400 | INVALID_PARAMETER | Request parameter is invalid | Fix parameter and retry |
| 401 | UNAUTHORIZED | Authentication required or failed | Obtain valid token |
| 403 | FORBIDDEN | Insufficient permissions | Request access or use different account |
| 404 | RESOURCE_NOT_FOUND | Requested resource doesn't exist | Verify resource ID |
| 429 | RATE_LIMIT_EXCEEDED | Too many requests | Wait and retry (check Retry-After header) |
| 503 | SERVICE_UNAVAILABLE | Temporary service outage | Retry with exponential backoff |
APIs must handle large datasets efficiently without overwhelming clients or servers.
GET /api/v1/buildings/BLDG-001/energy?
start=2025-01-01T00:00:00Z&
end=2025-12-31T23:59:59Z&
limit=1000
Response: 200 OK
{
"data": [...], // 1000 records
"pagination": {
"next_cursor": "eyJsYXN0X2lkIjo...",
"has_more": true
},
"links": {
"next": "/api/v1/buildings/BLDG-001/energy?cursor=eyJsYXN0X2lkIjo..."
}
}
APIs implement rate limiting to ensure fair resource allocation and prevent abuse.
// Rate limit headers in response
HTTP/1.1 200 OK
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 987
X-RateLimit-Reset: 1642267200
// When rate limit exceeded
HTTP/1.1 429 Too Many Requests
Retry-After: 60
{
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Rate limit of 1000 requests per hour exceeded",
"retry_after_seconds": 60
}
}
APIs evolve over time. WIA-BEMS uses URL-based versioning to maintain backwards compatibility.
// Version 1 API
GET /api/v1/buildings/BLDG-001/energy
// Future version 2 API (with breaking changes)
GET /api/v2/buildings/BLDG-001/energy
// Version specified in Accept header (alternative)
GET /api/buildings/BLDG-001/energy
Accept: application/vnd.wia.bems.v1+json
Successfully implementing Phase 2 APIs requires attention to several key considerations.
This chapter explored Phase 2 of WIA-BEMS, examining the comprehensive RESTful API specifications that enable applications to access and control building energy systems. We've seen how standardized APIs eliminate integration complexity, enable secure access, and provide the foundation for sophisticated energy management applications.
With data formats (Phase 1) and API interfaces (Phase 2) established, we're ready to explore Phase 3. Chapter 6 examines the protocol specifications that enable complex workflows, real-time monitoring, automated control sequences, and predictive maintenance. We'll see how standardized protocols build upon the API foundation to enable sophisticated building energy management scenarios.
Korea operates digital transformation through a comprehensive governance system. Digital Government: Digital Platform Government Committee (established September 2022, under the President)·Ministry of the Interior and Safety Digital Government Bureau·e-Government Support Center·Gov.kr·National Citizen Service·KDIS (Korea Digital Information Society)·NIA (National Information Society Agency)·MOIS (Ministry of the Interior and Safety). K-DNS Infrastructure: Korea Internet & Security Agency (KISA) Korea Internet Center·KISA DNS Root Server·KRNIC (Korea Network Information Center)·BGP Korea·National Cyber Security Center (NCSC)·KCC (Korea Communications Commission)·MSIT (Ministry of Science and ICT)·NIA·NIPA. Korean Cloud Infrastructure: KT Cloud·NAVER Cloud (NCloud)·Samsung SDS Cloud·LG U+ Cloud·NHN Cloud·Kakao Enterprise Cloud·SK Telecom Cloud·KISA Cloud Security Assurance Program (CSAP)·KCMVP-validated cloud·ISMS-P (Information Security & Personal Information Management System). Korean Security Certifications: KISA ISMS-P certification·KCMVP (Korean Cryptographic Module Validation Program)·NIS (National Intelligence Service) "National Cryptographic Technology Operation Standards"·NCSC "National Cyber Security Strategy 2024-2028"·CC (Common Criteria) Korean evaluation bodies·EAL4·EAL5·KS X ISO/IEC 15408·19790·24759 Korean Profile. Korean Data Standards: NIA AI Hub·National Data Standardization Committee·Statistics Korea (KOSTAT)·MyData 4 Designated Combination Specialists (Samsung SDS, KICI, KOSTAT, KFTC)·National Institute of Korean Language·National Law Information Center·National Spatial Information Platform·National Spatial Data Center·Korean Spatial Information Standards. Finance and Fintech Standards: FSC (Financial Services Commission)·FSS (Financial Supervisory Service)·FIU (Financial Intelligence Unit)·BOK (Bank of Korea)·FSEC (Financial Security Institute)·KFTC (Korea Financial Telecommunications)·KSD (Korea Securities Depository)·KRX (Korea Exchange) 8-agency cooperation. 5G/6G Communications Infrastructure: 5G subscribers 35 million (2024)·5G base stations 350,000·6G commercialization target 2028·5G dedicated networks 16 operators·6G Acceleration Council (MSIT, 2024). K-Content: KOCCA (Korea Creative Content Agency)·MCST (Ministry of Culture, Sports and Tourism)·KCA (Korea Communications Agency)·Korea Culture Information Service Agency·Korean Film Archive·Korea Publishing Industry Promotion Agency. Data 3 Acts (Personal Information Protection Act·Credit Information Act·Telecommunications Network Act, 2020 enforcement)·Data Industry Act (2021)·Public Data Act (2013)·AI Framework Act (2026)·Digital Platform Government Framework Act (2024 proposed) — Korea digital transformation core legislation.
Korea operates its industrial ecosystem and standardization system through the following core infrastructure. Korea Top 5 Groups: Samsung, Hyundai Motor, LG, SK, Lotte. Each group operates standardization committees and ISO/IEC TC Korean secretariats. Samsung Electronics (semiconductors, displays, home appliances, telecom)·Hyundai Motor (automobiles, mobility)·LG Electronics (home appliances, displays, OLED)·SK hynix (memory)·LG Energy Solution·Samsung SDI (batteries)·POSCO Future M (materials)·Hyundai Mobis (parts). Korean IT Big Tech: NAVER (search, cloud, AI HyperCLOVA)·Kakao (messenger, payment, mobility, banking)·Coupang (e-commerce, logistics)·Karrot Market·Toss·Woowa Brothers. Korea Telcos: SK Telecom·KT·LG U+. 5G·5G dedicated networks·B2B cloud·AI businesses operating. Korea Top 7 Research Universities: Seoul National University·KAIST·POSTECH·Yonsei University·Korea University·UNIST·DGIST·GIST. All serve as standardization R&D bases and ISO/IEC/IEEE Korean chairs. Korea Government-affiliated National Research Institutes (26): KIST, KAERI, KIMM, KIER, KFRI, KRICT, KRIBB, KARI, KASI, KIGAM, KICT, KISTI, KETI, ETRI, NIMS, KIMS, KISDI, KOTRA, STEPI, KOEN, KICCE, KIET, KIPF, KIHASA, KICJ, KLRI. Korea Industrial Complexes / Tech Valleys: Pangyo Techno Valley·Dongtan·Gwanggyo·Songdo IBD·Yeouido·Gangnam·Sihwa·Banwol·Gumi·Ulsan·Changwon·Geoje·Yeosu·Onsan·Cheongju·Iksan·Gwangyang·POSCO Gwangyang Steel Mill·Asan Bay·Seosan·Songdo·Incheon Airport·Sejong·Cheongna·Geomdan. Korea Trade and Finance Infrastructure: Korea International Trade Association (KITA)·Korea Trade-Investment Promotion Agency (KOTRA)·Export-Import Bank of Korea (KEXIM)·Bank of Korea·Kookmin Bank·Shinhan·Hana·Woori·NH Nonghyup·IBK Industrial Bank·SC First Bank·Citi Bank Korea·HSBC Korea·DBS Korea — 14 Korean major banks and foreign banks. Korea K-POP / K-Content: HYBE·SM·YG·JYP 4 major entertainment companies·CJ ENM·tvN·MBC·KBS·SBS·EBS·YTN·Yonhap News TV·JTBC Korean broadcasting·NETFLIX Korea·Disney Plus·TVING·Wavve·Watcha·Coupang Play. Korea Gaming Industry: Nexon·NCsoft·Krafton·Netmarble·Kakao Games·Pearl Abyss·Com2uS·Gamevil·NHN·Smilegate·Webzen. Korea Automotive / Battery: Hyundai Motor·Kia·Genesis·LG Energy Solution·Samsung SDI·SK On·POSCO Future M·EcoPro·L&F battery cathode material suppliers. Korea Semiconductor: Samsung Electronics (HBM3E·HBM4)·SK hynix (HBM3E 12-Hi)·DB HiTek·SK siltron·SK Enpulse·Dongjin Semichem·Seoul Semiconductor·Simmtech·Samsung Display·LG Display.
Korea operates a comprehensive industrial cluster system. Korea Top 12 National Strategic Technologies (5th Science and Technology Master Plan 2023-2027): (1) Semiconductors and Displays (2) Secondary Batteries (3) Advanced Mobility (autonomous driving, UAM) (4) Next-Generation Nuclear (SMR) (5) Advanced Bio (6) Aerospace and Marine (7) Hydrogen (8) Cybersecurity (9) Artificial Intelligence (10) Next-Generation Communications (11) Advanced Robotics and Manufacturing (12) Quantum. 12 fields receive direct investment of 5 trillion KRW annually, cumulative 30 trillion KRW by 2030. Korea Major Industrial Clusters: Pangyo IT Cluster (1,300+ companies, 100 trillion KRW revenue), Gangnam Fintech (200+ companies), Songdo BT Bio Cluster, Daegu Medical Cluster, Ulsan Industry (shipbuilding, petrochemicals, automotive), Changwon Machinery, Changwon National Industrial Complex, Siheung and Banwol (SME manufacturing), Yeosu Petrochemicals, Pyeongtaek Semiconductor (Samsung Electronics Pyeongtaek Campus), Icheon and Cheongju Semiconductor (SK hynix Icheon and Cheongju Campuses), Asan Display (Samsung Display Asan Campus), Gumi Mobile (Samsung Gumi Campus), Pohang Steel (POSCO Pohang Steel Mill), Gwangyang Steel (POSCO Gwangyang Steel Mill), Dangjin Steel (Hyundai Steel Dangjin), Ulsan Automotive (Hyundai Motor Ulsan Plant), Asan Automotive (Hyundai Asan Plant), Kia Gwangju and Sohari, POSCO Gwangyang and Pohang Steel Mills, SK hynix Icheon and Cheongju, Samsung Electronics Hwaseong, Giheung, Pyeongtaek, Onyang, Cheonan, Asan Semiconductor Facilities. Major Industrial Complexes and Techno Valleys: Pangyo Techno Valley (1st 800 companies, 2nd 600 companies, 3rd 1,200 companies), Dongtan Techno Valley, Gwanggyo Techno Valley, Songdo IBD, Yeouido Financial District, Gangnam Teheran-ro Valley, Sihwa, Banwol, Gumi, Ulsan, Changwon, Geoje, Yeosu, Ulsan Mipo, Onsan, Cheongju, Iksan, Gwangyang, Yeosu, POSCO Gwangyang Steel Mill, Asan Bay, Seosan, Songdo, Incheon Airport, Sejong, Cheongna, Geomdan, Pyeongtaek Automotive Industrial Complex, Giheung Semiconductor Complex, Icheon Semiconductor Complex, Asan Display Complex, Gumi Mobile Complex, Changwon National Industrial Complex, Ulsan Mipo National Industrial Complex, Yeosu National Industrial Complex, Onsan National Industrial Complex. Korea Workforce Statistics: STEM undergraduate students 700,000 (26% of all university students), STEM graduate students 170,000, PhD researchers 140,000, STEM doctorates conferred 8,000 annually (Seoul National University 1,200, KAIST 800, POSTECH 400, Yonsei University 700, Korea University 600, UNIST 250, DGIST 100, GIST 200, KISTI 50, KIST and ETRI postdoctoral programs 1,000), information security experts 300,000 (KISA-trained and private), AI experts 50,000 (NIA, IITP, NIPA, Samsung, LG, SK, NAVER, Kakao trained), semiconductor experts 260,000 (Samsung Electronics 60,000, SK hynix 30,000, DB HiTek, SK siltron). National R&D Project Operation: National R&D projects 100,000+ annually (MSIT 35,000, MOTIE 25,000, MSS 20,000, MOE 15,000, others 5,000), R&D participating institutions 25,000+, R&D participating researchers 530,000, National R&D output (papers, patents) 540,000 annually. Korea Corporate R&D Investment Top 10 (2024): Samsung Electronics 28 trillion KRW, LG Electronics 9 trillion KRW, SK hynix 8 trillion KRW, Hyundai Motor 6 trillion KRW, Kia 4 trillion KRW, LG Chem 3.5 trillion KRW, LG Display 3.2 trillion KRW, POSCO 3 trillion KRW, Samsung SDI 2.7 trillion KRW, SK Innovation 2.5 trillion KRW.