能源節能績效 API 模組
能源節能績效API提供全面的節能項目評估功能,幫助企業量化節能措施的實際效果,計算投資回報率(ROI),並生成符合國際標準的節能驗證報告。
POST
/api/v2/energy/performance
計算節能措施的實際績效,包括節能量、成本節省和投資回報率。
請求參數
{
"project_id": "string, 必填, 節能項目ID",
"baseline_data": {
"start_date": "YYYY-MM-DD, 必填, 基準期開始日期",
"end_date": "YYYY-MM-DD, 必填, 基準期結束日期",
"energy_usage": "number, 必填, 基準期能源使用量",
"unit": "string, 必填, 能源單位"
},
"reporting_data": {
"start_date": "YYYY-MM-DD, 必填, 報告期開始日期",
"end_date": "YYYY-MM-DD, 必填, 報告期結束日期",
"energy_usage": "number, 必填, 報告期能源使用量",
"unit": "string, 必填, 能源單位"
},
"cost_data": {
"project_cost": "number, 選填, 項目總成本",
"currency": "string, 選填, 貨幣代碼"
}
}
回應範例
{
"status": "success",
"data": {
"project_id": "proj_12345",
"savings": {
"energy": 1250,
"unit": "kWh",
"percentage": 15.5,
"cost": 6250,
"currency": "TWD"
},
"performance": {
"actual_vs_expected": 98.2,
"unit": "percent",
"rating": "excellent"
},
"roi": {
"payback_period": 18,
"unit": "months",
"net_present_value": 125000,
"currency": "TWD"
}
}
}
程式碼範例
// PHP 範例
$url = 'https://api.faucetsolution.com.tw/v2/energy/performance';
$data = [
'project_id' => 'proj_12345',
'baseline_data' => [
'start_date' => '2023-01-01',
'end_date' => '2023-03-31',
'energy_usage' => 8500,
'unit' => 'kWh'
],
'reporting_data' => [
'start_date' => '2023-04-01',
'end_date' => '2023-06-30',
'energy_usage' => 7200,
'unit' => 'kWh'
]
];
$options = [
'http' => [
'header' => [
"Authorization: Bearer YOUR_API_KEY",
"Content-Type: application/json"
],
'method' => 'POST',
'content' => json_encode($data)
]
];
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$response = json_decode($result, true);
# Python 範例
import requests
url = "https://api.faucetsolution.com.tw/v2/energy/performance"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {
"project_id": "proj_12345",
"baseline_data": {
"start_date": "2023-01-01",
"end_date": "2023-03-31",
"energy_usage": 8500,
"unit": "kWh"
},
"reporting_data": {
"start_date": "2023-04-01",
"end_date": "2023-06-30",
"energy_usage": 7200,
"unit": "kWh"
}
}
response = requests.post(url, headers=headers, json=data)
result = response.json()
// Java 範例
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import org.json.JSONObject;
public class EnergyPerformance {
public static void main(String[] args) throws Exception {
String url = "https://api.faucetsolution.com.tw/v2/energy/performance";
String apiKey = "YOUR_API_KEY";
JSONObject data = new JSONObject();
data.put("project_id", "proj_12345");
JSONObject baseline = new JSONObject();
baseline.put("start_date", "2023-01-01");
baseline.put("end_date", "2023-03-31");
baseline.put("energy_usage", 8500);
baseline.put("unit", "kWh");
data.put("baseline_data", baseline);
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(data.toString()))
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
// C# 範例
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program {
static async Task Main() {
var client = new HttpClient();
var request = new HttpRequestMessage {
Method = HttpMethod.Post,
RequestUri = new Uri("https://api.faucetsolution.com.tw/v2/energy/performance"),
Headers = {
{ "Authorization", "Bearer YOUR_API_KEY" }
},
Content = new StringContent(
"{\"project_id\":\"proj_12345\"," +
"\"baseline_data\":{" +
"\"start_date\":\"2023-01-01\"," +
"\"end_date\":\"2023-03-31\"," +
"\"energy_usage\":8500," +
"\"unit\":\"kWh\"}," +
"\"reporting_data\":{" +
"\"start_date\":\"2023-04-01\"," +
"\"end_date\":\"2023-06-30\"," +
"\"energy_usage\":7200," +
"\"unit\":\"kWh\"}}",
Encoding.UTF8,
"application/json")
};
var response = await client.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
POST
/api/v1/energy/upload
上傳設備用電數據,支持批量上傳和多種數據格式。
請求參數
{
"device_id": "string, 必填, 設備唯一識別碼",
"readings": [
{
"timestamp": "ISO8601, 必填, 讀取時間",
"energy_usage": "number, 必填, 能源使用量",
"unit": "string, 必填, 能源單位",
"voltage": "number, 選填, 電壓",
"current": "number, 選填, 電流",
"power_factor": "number, 選填, 功率因數"
}
],
"metadata": {
"location": "string, 選填, 設備位置",
"device_type": "string, 選填, 設備類型"
}
}
回應範例
{
"status": "success",
"data": {
"device_id": "dev_12345",
"uploaded_records": 24,
"first_timestamp": "2023-01-01T00:00:00Z",
"last_timestamp": "2023-01-01T23:00:00Z",
"total_energy": 1250.5,
"unit": "kWh"
}
}
程式碼範例
// PHP 範例
$url = 'https://api.faucetsolution.com.tw/v1/energy/upload';
$data = [
'device_id' => 'dev_12345',
'readings' => [
[
'timestamp' => '2023-01-01T00:00:00Z',
'energy_usage' => 52.3,
'unit' => 'kWh',
'voltage' => 220,
'current' => 5.2
],
[
'timestamp' => '2023-01-01T01:00:00Z',
'energy_usage' => 48.7,
'unit' => 'kWh'
]
]
];
$options = [
'http' => [
'header' => [
"Authorization: Bearer YOUR_API_KEY",
"Content-Type: application/json"
],
'method' => 'POST',
'content' => json_encode($data)
]
];
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$response = json_decode($result, true);
# Python 範例
import requests
from datetime import datetime, timezone
url = "https://api.faucetsolution.com.tw/v1/energy/upload"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {
"device_id": "dev_12345",
"readings": [
{
"timestamp": datetime.now(timezone.utc).isoformat(),
"energy_usage": 52.3,
"unit": "kWh"
}
]
}
response = requests.post(url, headers=headers, json=data)
result = response.json()
// Java 範例
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import org.json.JSONObject;
import org.json.JSONArray;
public class EnergyUpload {
public static void main(String[] args) throws Exception {
String url = "https://api.faucetsolution.com.tw/v1/energy/upload";
String apiKey = "YOUR_API_KEY";
JSONObject data = new JSONObject();
data.put("device_id", "dev_12345");
JSONArray readings = new JSONArray();
JSONObject reading1 = new JSONObject();
reading1.put("timestamp", "2023-01-01T00:00:00Z");
reading1.put("energy_usage", 52.3);
reading1.put("unit", "kWh");
readings.put(reading1);
data.put("readings", readings);
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(data.toString()))
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
// C# 範例
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program {
static async Task Main() {
var client = new HttpClient();
var request = new HttpRequestMessage {
Method = HttpMethod.Post,
RequestUri = new Uri("https://api.faucetsolution.com.tw/v1/energy/upload"),
Headers = {
{ "Authorization", "Bearer YOUR_API_KEY" }
},
Content = new StringContent(
"{\"device_id\":\"dev_12345\"," +
"\"readings\":[{" +
"\"timestamp\":\"2023-01-01T00:00:00Z\"," +
"\"energy_usage\":52.3," +
"\"unit\":\"kWh\"}]}",
Encoding.UTF8,
"application/json")
};
var response = await client.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
GET
/api/v1/energy/advice?device_id={device_id}&period={period}
基於設備歷史用電數據,提供AI生成的節能建議。
請求參數
參數 | 類型 | 說明 |
---|---|---|
device_id | string | 必填,設備唯一識別碼 |
period | string | 選填,分析期間(7d, 30d, 90d),預設30d |
回應範例
{
"status": "success",
"data": {
"device_id": "dev_12345",
"analysis_period": {
"start": "2023-01-01",
"end": "2023-01-31"
},
"average_daily_usage": 45.2,
"unit": "kWh",
"peak_hours": [9, 10, 14, 15],
"recommendations": [
{
"id": "rec_001",
"type": "schedule_adjustment",
"description": "建議調整設備運行時間,避開用電高峰時段(9-11,14-16)",
"estimated_saving": 12.5,
"unit": "percent"
},
{
"id": "rec_002",
"type": "equipment_upgrade",
"description": "考慮升級設備至能源效率等級A++型號",
"estimated_saving": 25.0,
"unit": "percent",
"payback_period": 24,
"unit": "months"
}
]
}
}
程式碼範例
// PHP 範例
$url = 'https://api.faucetsolution.com.tw/v1/energy/advice?device_id=dev_12345&period=30d';
$options = [
'http' => [
'header' => [
"Authorization: Bearer YOUR_API_KEY",
"Content-Type: application/json"
],
'method' => 'GET'
]
];
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$response = json_decode($result, true);
# Python 範例
import requests
url = "https://api.faucetsolution.com.tw/v1/energy/advice"
params = {
"device_id": "dev_12345",
"period": "30d"
}
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
response = requests.get(url, headers=headers, params=params)
result = response.json()
// Java 範例
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
public class EnergyAdvice {
public static void main(String[] args) throws Exception {
String deviceId = "dev_12345";
String period = "30d";
String url = "https://api.faucetsolution.com.tw/v1/energy/advice?device_id=" +
URLEncoder.encode(deviceId, StandardCharsets.UTF_8) +
"&period=" + URLEncoder.encode(period, StandardCharsets.UTF_8);
String apiKey = "YOUR_API_KEY";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.GET()
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
// C# 範例
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program {
static async Task Main() {
var client = new HttpClient();
var request = new HttpRequestMessage {
Method = HttpMethod.Get,
RequestUri = new Uri("https://api.faucetsolution.com.tw/v1/energy/advice?device_id=dev_12345&period=30d"),
Headers = {
{ "Authorization", "Bearer YOUR_API_KEY" }
}
};
var response = await client.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
GET
/api/v1/energy/summary?start_date={start_date}&end_date={end_date}&granularity={granularity}
取得指定期間的節能總表,可按日、週、月或年粒度返回數據。
請求參數
參數 | 類型 | 說明 |
---|---|---|
start_date | YYYY-MM-DD | 必填,開始日期 |
end_date | YYYY-MM-DD | 必填,結束日期 |
granularity | string | 選填,數據粒度 (day, week, month, year),預設day |
device_ids | string[] | 選填,設備ID列表,多個ID用逗號分隔 |
回應範例
{
"status": "success",
"data": {
"summary": {
"total_energy_usage": 1250.5,
"total_energy_saving": 312.6,
"saving_percentage": 25.0,
"unit": "kWh",
"cost_saving": 1563.0,
"currency": "TWD"
},
"details": [
{
"period": "2023-01-01",
"energy_usage": 52.3,
"energy_saving": 13.1,
"saving_percentage": 25.0,
"cost_saving": 65.5
},
{
"period": "2023-01-02",
"energy_usage": 48.7,
"energy_saving": 12.2,
"saving_percentage": 25.0,
"cost_saving": 61.0
}
]
}
}
程式碼範例
// PHP 範例
$url = 'https://api.faucetsolution.com.tw/v1/energy/summary?start_date=2023-01-01&end_date=2023-01-31&granularity=day';
$options = [
'http' => [
'header' => [
"Authorization: Bearer YOUR_API_KEY",
"Content-Type: application/json"
],
'method' => 'GET'
]
];
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$response = json_decode($result, true);
# Python 範例
import requests
url = "https://api.faucetsolution.com.tw/v1/energy/summary"
params = {
"start_date": "2023-01-01",
"end_date": "2023-01-31",
"granularity": "day"
}
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
response = requests.get(url, headers=headers, params=params)
result = response.json()
// Java 範例
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
public class EnergySummary {
public static void main(String[] args) throws Exception {
String startDate = "2023-01-01";
String endDate = "2023-01-31";
String granularity = "day";
String url = "https://api.faucetsolution.com.tw/v1/energy/summary?start_date=" +
URLEncoder.encode(startDate, StandardCharsets.UTF_8) +
"&end_date=" + URLEncoder.encode(endDate, StandardCharsets.UTF_8) +
"&granularity=" + URLEncoder.encode(granularity, StandardCharsets.UTF_8);
String apiKey = "YOUR_API_KEY";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.GET()
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
// C# 範例
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program {
static async Task Main() {
var client = new HttpClient();
var request = new HttpRequestMessage {
Method = HttpMethod.Get,
RequestUri = new Uri("https://api.faucetsolution.com.tw/v1/energy/summary?start_date=2023-01-01&end_date=2023-01-31&granularity=day"),
Headers = {
{ "Authorization", "Bearer YOUR_API_KEY" }
}
};
var response = await client.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
GET
/api/v1/energy/abnormal?start_date={start_date}&end_date={end_date}&threshold={threshold}
查詢指定期間內的異常用電事件,可設定閾值來定義異常標準。
請求參數
參數 | 類型 | 說明 |
---|---|---|
start_date | YYYY-MM-DD | 必填,開始日期 |
end_date | YYYY-MM-DD | 必填,結束日期 |
threshold | number | 選填,異常閾值(標準差的倍數),預設2.0 |
device_ids | string[] | 選填,設備ID列表,多個ID用逗號分隔 |
回應範例
{
"status": "success",
"data": {
"total_abnormal_events": 3,
"average_usage": 45.2,
"standard_deviation": 12.3,
"threshold": 2.0,
"unit": "kWh",
"events": [
{
"timestamp": "2023-01-15T14:30:00Z",
"device_id": "dev_12345",
"energy_usage": 82.5,
"deviation": 3.03,
"possible_cause": "設備過載或故障",
"suggested_action": "檢查設備狀態,考慮維修或更換"
},
{
"timestamp": "2023-01-20T09:15:00Z",
"device_id": "dev_12345",
"energy_usage": 78.3,
"deviation": 2.69,
"possible_cause": "非計劃性運行",
"suggested_action": "檢查排程設定"
}
]
}
}
程式碼範例
// PHP 範例
$url = 'https://api.faucetsolution.com.tw/v1/energy/abnormal?start_date=2023-01-01&end_date=2023-01-31&threshold=2.0';
$options = [
'http' => [
'header' => [
"Authorization: Bearer YOUR_API_KEY",
"Content-Type: application/json"
],
'method' => 'GET'
]
];
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$response = json_decode($result, true);
# Python 範例
import requests
url = "https://api.faucetsolution.com.tw/v1/energy/abnormal"
params = {
"start_date": "2023-01-01",
"end_date": "2023-01-31",
"threshold": 2.0
}
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
response = requests.get(url, headers=headers, params=params)
result = response.json()
// Java 範例
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
public class EnergyAbnormal {
public static void main(String[] args) throws Exception {
String startDate = "2023-01-01";
String endDate = "2023-01-31";
double threshold = 2.0;
String url = "https://api.faucetsolution.com.tw/v1/energy/abnormal?start_date=" +
URLEncoder.encode(startDate, StandardCharsets.UTF_8) +
"&end_date=" + URLEncoder.encode(endDate, StandardCharsets.UTF_8) +
"&threshold=" + threshold;
String apiKey = "YOUR_API_KEY";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.GET()
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
// C# 範例
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program {
static async Task Main() {
var client = new HttpClient();
var request = new HttpRequestMessage {
Method = HttpMethod.Get,
RequestUri = new Uri("https://api.faucetsolution.com.tw/v1/energy/abnormal?start_date=2023-01-01&end_date=2023-01-31&threshold=2.0"),
Headers = {
{ "Authorization", "Bearer YOUR_API_KEY" }
}
};
var response = await client.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
節能績效分析
此圖表顯示最近12個月的節能績效趨勢,包括實際節能量與預期目標的比較。
API使用統計
您的API呼叫使用情況與配額限制。
設備用電分析
各設備的用電量佔比與節能潛力分析。