數位減碳雲資料交換相關API說明
修訂紀錄
| 年月日 | 版本 | 修改原因 |
|---|---|---|
| 2023/10/25 | 1.0 | 初稿。 |
| 2023/11/13 | 1.1 | Tproof內容調整。 |
| 2023/12/07 | 1.2 | 身份驗證內容調整。 |
| 2023/12/11 | 1.3 | 新增 Event API。 |
| 2024/01/02 | 1.4 | 新增用量查詢 API。 |
| 2024/01/18 | 1.5 | 新增使用次數查詢 API。 |
| 2024/04/18 | 2.0 | 大幅度改版,新增公司資訊以權限設定相關 API。 |
| 2024/05/16 | 2.1 | 查詢公司清單 API 調整。 |
| 2024/06/11 | 2.2 | 開發者網站名稱異動。 |
| 2024/06/13 | 2.3 | 錯誤內容修正。 |
| 2024/09/19 | 3.0 | API 大幅改版。 |
| 2024/09/23 | 3.1 | API 微調。 |
| 2024/09/25 | 3.1 | 新增 產品碳足跡過濾 API。 |
| 2024/09/26 | 3.1 | 碳足跡相關 API 輸出格式調整。 |
| 2024/10/10 | 3.2 | 碳足跡相關 API 增加 PACT 專用輸出格式。 |
| 2024/10/17 | 3.3 | 碳足跡權限相關 API 增加開放資料的設定。 |
| 2024/10/18 | 3.4 | PACT API 依規定路徑調整。 |
文件版本
- 1.x 的版本是為了 PACT 規定的 API 而建置。
- 2.x 的版本新增公司資訊以及使用碳排資訊的權限設定 API 服務。
- 3.x 的版本 API 整合,新建公司資訊 API 取得 client_id, client_secret後開台使用其他 API。
文件說明
本文件基於 PACT 碳足跡排放交換數據的格式結合公司使用現況與及需求制定。使用者建立公司資訊後才能取得 client_id, client_secret 隨後使用這些資料取得 token 之後才能訪問其他的API。
常用規格
- JSON 欄位名稱表示法,參考 [JSONPath expressions] (https://goessner.net/articles/JsonPath/index.html#e2)
- PCF 詳細資料規格,參考 [PCF Data Exchange]
(https://wbcsd.github.io/data-exchange-protocol/v2/)
API 路徑
- API 端點: {baseUrl} 為 https://api.dsce.com.tw/app/api/dsce
- PACT API 端點: {pactUrl} 為 https://api.dsce.com.tw/app/api
API 說明
公司資訊
| 功能 | 端點位置 | Method | 驗證 |
|---|---|---|---|
| 新建公司資訊 | {baseUrl}/companies | POST | |
| 修改公司資訊 | {baseUrl}/companies | PATCH | ● |
| 取得公司資訊 | {baseUrl}/companies/{clientId} | GET | ● |
| 查詢公司資訊 | {baseUrl}/companies/{item}/{value} | GET | ● |
| 現有公司清單 | {baseUrl}/companies | GET | ● |
新建公司資訊
功能敘述
首次使用 API時必須先新建公司資訊,新建成功之後系統會提供一組專用的 client_id, client_secret 透過它們可以取得 Token 用於訪問其他需要通過身份驗證的 API。
Note:
1. 新建公司後會取得 client_id, client_secret 使用取得使用 TOKEN API 取得 Token。
2. 新建公司時系統會預設將資訊廠商設為自己有需要變更請使用資訊廠商API (infoservices) 進行修改。端點位置
Method URL POST {baseUrl}/companies Header
Key Value content-type application/json 路徑參數
參數名稱 描述 無 請求格式
{ 'companyName':'SUN Store', 'isTaiwan':'Y', 'taxIDNumber':'00000000', 'contactName':'sun', 'contactEmail': 'sun@gmail.com', 'agreeVer': true }請求欄位
欄位名稱 描述 說明 companyName 公司名稱 isTaiwan 台灣公司 Y/N taxIDNumber 統一編號 contactName 聯絡人姓名 contactEmail 聯絡人電子郵件 agreeVer 個資同意 Y/N Note: isTaiwan 值為 'Y' 時,taxIDNumber 輸入統一編號;isTaiwan 值為 'N' 時請自訂taxIDNumber不能和其他廠商設定值重覆。
回傳格式
{ 'message': 'OK', 'companyName':'SUN Store', 'isTaiwan':'Y', 'taxIDNumber':'00000000', 'contactName':'sun', 'contactEmail': 'sun@gmail.com', 'agreeVer': true, 'serial': 1, 'companyId': 'urn:uuid:BA82F310-2E69-A6B0-64D0-9C9C933D3834', 'client_id': 'seq240306-141230', 'client_secret':'RjdjaJY7Bei035fVGBuEcweDeZTh6Yw8' }回傳欄位
欄位名稱 描述 說明 $.message 回傳訊息 $.companyName 公司名稱 $.taxIDNumber 統一編號 $.contactName 聯絡人姓名 $.contactEmail 聯絡人電子郵件 $.companyId 公司代碼 $.client_id. client_id $.client_secret client_secret Note: 使用新建公司取得的 client_id, client_secret 去取得 API 授權的 Token。
修改公司資訊
功能敘述
修改公司的聯絡人資訊,包含聯絡人姓名以及聯絡人的電子郵件。
Note: 僅能修改自身公司,無法修改其他公司的資訊。
端點位置
Method URL PATCH {baseUrl}/companies Header
Key Value content-type application/json authorization Bearer {access_token} 路徑參數
參數名稱 描述 無 請求格式
{ 'contactName':'sun', 'contactEmail': 'sun@gmail.com', }請求欄位
欄位名稱 描述 說明 contactName 聯絡人姓名 contactEmail 聯絡人電子郵件 回傳格式
{ 'contactName':'sun', 'contactEmail': 'sun@gmail.com', 'companyName':'SUN Store', 'taxIDNumber':'00000000', 'companyId': 'urn:uuid:BA82F310-2E69-A6B0-64D0-9C9C933D3834', 'client_id': 'seq240306-141230', 'client_secret':'RjdjaJY7Bei035fVGBuEcweDeZTh6Yw8' }回傳欄位
欄位名稱 描述 說明 $.contactName 聯絡人姓名 $.contactEmail 聯絡人電子郵件 $.companyName 公司名稱 $.taxIDNumber 統一編號 $.companyId 公司代碼 $.client_id client_id $.client_secret client_secret
取得公司資訊
功能敘述
已知公司的 clientId,可以透過 clientId 查詢該公司的資訊。
端點位置
Method URL GET {baseUrl}/companies/{clientId} Header
Key Value content-type application/json authorization Bearer {access_token} 路徑參數
參數名稱 描述 clientId 請求格式
無請求欄位
欄位名稱 描述 無 回傳格式
{ 'serial': '14', 'companyName':'SUN Store', 'isTaiwan':'N', 'taxIDNumber':'00000000', 'contactName':'sun', 'contactEmail': 'sun@gmail.com', 'companyId': 'urn:uuid:BA82F310-2E69-A6B0-64D0-9C9C933D3834', 'client_id': 'seq240306-141230', 'isEnabled':'Y', }回傳欄位
欄位名稱 描述 說明 $.serial 公司序號 $.companyName 公司名稱 $.isTaiwan 是否為台灣公司? $.taxIDNumber 統一編號 $.contactName 聯絡人姓名 $.contactEmail 聯絡人電子郵件 $.companyId 公司代碼 $.client_id** client_id $.isEnabled 是否正常使用中?
查詢公司資訊
功能敘述
從現有公司清單使用特定欄位過濾篩選符合情況的公司資訊。
端點位置
Method URL GET {baseUrl}/companies/{item}/{value} Header
Key Value content-type application/json authorization Bearer {access_token} 路徑參數
參數名稱 描述 item 搜尋的屬性 (serial, companyName, companyId, taxIDNumber) value 屬性的值 (value) Note: 使用這些屬性去篩選取得想要的公司資訊。
屬性名稱 描述 serial 公司序號 companyName 公司名稱 companyId 公司代碼 taxIDNumber 統一編號 請求格式
無請求欄位
欄位名稱 描述 無 回傳格式
{ "data": [ { "serial": "14", "companyName": "測試資料02", "taxIDNumber": "23456781", "companyId": "urn:uuid:5445E165-2463-B81A-23CE-C81CC6145ACD" }, { "serial": "17", "companyName": "測試資料03", "taxIDNumber": "34567812", "companyId": "urn:uuid:5445E165-2463-B81A-23CE-C81CC6145ACD" } ] }回傳欄位
欄位名稱 描述 說明 $.serial 公司序號 $.companyName 公司名稱 $.taxIDNumber 統一編號 $.companyId 公司代碼
現有公司清單
功能敘述
取得目前所有公司資訊。
端點位置
Method URL GET {baseUrl}/companies Header
Key Value content-type application/json authorization Bearer {access_token} 路徑參數
參數名稱 描述 無 請求格式
無請求欄位
欄位名稱 描述 無 回傳格式
{ "data": [ { "serial": "14", "companyName": "測試資料02", "taxIDNumber": "23456781", "companyId": "urn:uuid:5445E165-2463-B81A-23CE-C81CC6145ACD" }, { "serial": "17", "companyName": "測試資料03", "taxIDNumber": "34567812", "companyId": "urn:uuid:5445E165-2463-B81A-23CE-C81CC6145ACD" } ] }回傳欄位
欄位名稱 描述 說明 $.serial 公司序號 $.companyName 公司名稱 $.taxIDNumber 統一編號 $.companyId 公司代碼
TOKEN
| 功能 | 端點位置 | Method | 驗證 |
|---|---|---|---|
| 取得使用 TOKEN | {baseUrl}/token | POST | |
| TOKEN 合法性驗證 | {baseUrl}/tokenVerify | POST | ● |
取得使用 TOKEN
功能敘述
client_id, client_secret 在新建公司成功後即可以取得,使用它們來取得授權的 Token 使用其他 API。
Note: 透過 access_token 去使用需要經過驗證的 API。
端點位置
Method URL POST {baseUrl}/token Header
Key Value content-type application/json 路徑參數
參數名稱 描述 無 請求格式
x-www-form-urlencoded請求欄位
欄位名稱 描述 client_id 公司識別碼 client_secret 公司密鑰 grant_type client_credentials 回傳格式
{ 'access_token': 'ttttt', 'expires_in': 1800, 'refresh_expires_in': 0, 'token_type': 'Bearer', 'not-before-policy': 0, 'scope': 'email profile' }回傳欄位
欄位名稱 描述 $.access_token 存取權杖 $.expires_in 過期時間(秒) $.refresh_expires_in 更新權杖過期時間(秒),0表示不採用更新權杖機制 $.token_type 權杖類型 $.not-before-policy 啟用前策略時間(秒) $.scope 權限範圍
TOKEN 合法性驗證
功能敘述
檢查目前的使用的 access_token 是否可以使用?
端點位置
Method URL POST {baseUrl}/tokenVerify Header
Key Value content-type application/json authorization Bearer {access_token} 路徑參數
參數名稱 描述 無 請求格式
無請求欄位
欄位名稱 描述 無 回傳格式
{ 'vaild': true, 'client_id': 'esgdevops01', 'clientHost': '127.0.0.1', 'role': { 'roles': [ 'offline_access', 'uma_authorization', 'default-roles-demo' ] } }回傳欄位
欄位名稱 描述 $.vaild. 合法權限 $.client_id client_id 由新建公司流程發送
資訊廠商設定
| 功能 | 端點位置 | Method | 驗證 |
|---|---|---|---|
| 新建資訊廠商 | {baseUrl}/infoservices | POST | ● |
| 變更資訊廠商 | {baseUrl}/infoservices | PATCH | ● |
| 取得資訊廠商 | {baseUrl}/infoservices | GET | ● |
新建資訊廠商
功能敘述
**Note:**每間公司只能有一間對應的資訊廠商。
設定公司對應的資訊廠商,公司可以透過這個 API 指定自己所屬的資訊廠商,這個資訊廠商將可以代表本公司操作碳足跡資料相關功能。
Note:
1.新增公司資訊後會預設資訊廠商是自己可以透過這系列API 進行修改。
2.僅能修改自身公司,無法設定其他公司的資訊廠商。端點位置
Method URL POST {baseUrl}/infoservices Header
Key Value content-type application/json authorization Bearer {access_token} 路徑參數
參數名稱 描述 無 請求格式
Note: operatorSn 填入資訊廠商的公司序號 (serial),設定完成後該公司可以協助進行碳排資料操作。
{ 'operatorSn': 50, 'comment': "nothing" }請求欄位
欄位名稱 描述 operatorSn 資訊廠商公司序號 comment 備註說明 回傳格式
{ 'message': 'OK' }回傳欄位
欄位名稱 描述 message 設定結果 'OK' 表示設定成功
變更資訊廠商
功能敘述
設定公司對應的資訊廠商,公司可以透過這個 API 修改指定的資訊廠商,資訊廠商可以代表公司進行碳足跡資料相關功能設定。
Note:
1.資訊廠商可以代表公司進行碳足跡資料相關功能設定。
2.僅能修改自身公司,無法設定其他公司的資訊廠商。端點位置
Method URL PATCH {baseUrl}/infoservices Header
Key Value content-type application/json authorization Bearer {access_token} 路徑參數
參數名稱 描述 無 請求格式
{ 'operatorSn': 50, 'comment': "nothing" }Note: operatorSn 對應公司的序號 (serial),設定完成後該公司可以協助進行碳排資料操作。
請求欄位
|欄位名稱 |描述 | |-----------|-----------| |operatorSn |資訊廠商公司序號 | |comment |備註說明 |
回傳格式
{ 'message': 'OK' }回傳欄位
欄位名稱 描述 message 設定結果 'OK' 表示設定成功
取得資訊廠商
功能敘述
查詢本公司的資訊廠商資料,公司可以透過這個 API 檢視目前指定的資訊廠商,這個資訊廠商將可以代表本公司操作碳足跡資料相關功能。
Note: 公司僅能查詢自己本身指定的資訊廠商,無法查詢其他公司資訊廠商設定。
端點位置
Method URL GET {baseUrl}/infoservices Header
Key Value content-type application/json authorization Bearer {access_token} 路徑參數
參數名稱 描述 無 請求格式
無請求欄位
欄位名稱 描述 無 回傳格式
{ "data": { 'serial': '14', 'companyName': '資訊廠商', 'taxIDNumber': '05076416', 'contactName': 'sun', 'contactEmail': 'sun@iii.org.tw', 'companyId': 'urn:uuid:5445E165-2463-B81A-23CE-C81CC6145ACD' } }回傳欄位
欄位名稱 描述 說明 $.serial 公司序號 $.companyName 公司名稱 $.taxIDNumber 統一編號 $.contactName 聯絡人姓名 $.contactEmail 聯絡人電子郵件 $.companyId 公司代碼
產品碳足跡
| 功能 | 端點位置 | Method | 驗證 |
|---|---|---|---|
| 新建產品碳足跡 | {baseUrl}/PCF/{ownerSn} | POST | ● |
| (停用) 刪除產品碳足跡 | {baseUrl}/PCF/{pfpId} | DELETE | ● |
| 修改產品碳足跡 | {baseUrl}/PCF/{pfpId} | PATCH | ● |
| 取得產品碳足跡 | {baseUrl}/PCF/{pfpId} | GET | ● |
| 產品碳足跡清單 | {baseUrl}/PCF | GET | ● |
| 產品碳足跡過濾 | {baseUrl}/PCF/{statusValue} | GET | ● |
| 查詢產品碳足跡 | {baseUrl}/PCF/{statusValue}/{item}/{value} | GET | ● |
新建產品碳足跡
功能敘述
建立產品碳足跡資料。
Note:
1.owerSn 填入實際擁有者的公司代碼,companyIds欄位會自動填入ownerSn公司的companyId。
2.centerSn 填入要授權讀取的公司代碼 EX: 1, 2, 3 不開放則留白。端點位置
Method URL POST. {baseUrl}/PCF/{ownerSn} Header
Key Value content-type application/json authorization Bearer {access_token} 路徑參數
參數名稱 描述 ownerSn 碳排資料擁有者的公司序號 **Note: 新增公司碳排資料 ownerSn 填入公司序號,資訊廠商代操作則代入實際擁有資料的公司代碼。
請求格式
{ "openData": "N", "centerSn": "", "id": "", "specVersion": "2.0.0", "version": 1, "created": "", "status": "Active", "companyName": "My Corp", "companyIds": [""], "productDescription": "Cote'd Or Ethanol", "productIds": [ "urn:gtin:1300000000000", "urn:gtin:1400000000000" ], "productCategoryCpc": "123", "productNameCompany": "Green Ethanol", "comment": "nothing", "pcf": { "declaredUnit": "liter", "unitaryProductAmount": "12.0", "pCfExcludingBiogenic": "0.0", "fossilGhgEmissions": "0.123", "fossilCarbonContent": "0.0", "biogenicCarbonContent": "0.0", "landManagementGhgEmissions": "0.01", "characterizationFactors": "AR5", "crossSectoralStandardsUsed": [ "GHG Protocol Product standard" ], "productOrSectorSpecificRules": [ { "operator": "EPD International", "ruleNames": [ "ABC 2021" ] } ], "boundaryProcessesDescription": "End-of-life included", "referencePeriodStart": "2022-01-01T00:00:00Z", "referencePeriodEnd": "2023-01-01T00:00:00Z", "geographyCountry": "AC", "secondaryEmissionFactorSources": [ { "name": "Ecoinvent", "version": "1.2.3" } ], "exemptedEmissionsPercent": 3.1, "exemptedEmissionsDescription": "xxx", "packagingEmissionsIncluded": false, "primaryDataShare": 56.12, "assurance": { "coverage": "product line", "level": "reasonable", "boundary": "Cradle-to-Gate", "providerName": "My Auditor", "completedAt": "2022-12-08T14:47:32Z", "standardName": "ISO ...", "comments": "This is a comment" } }, "extensions": [ { "specVersion": "2.0.0", "dataSchema": "https://catalog.carbon-transparency.com/shipment/1.0.0/data-model.json", "data": { "shipmentId": "S1234567890", "consignmentId": "Cabc.def-ghi", "shipmentType": "PICKUP", "weight": 10, "transportChainElementId": "ABCDEFGHI" } } ] }請求欄位
- 特殊欄位
欄位名稱 描述 $.openData 填入資料是否開放讀取?
#開放資料所有人均可讀取。$.centerSn 填入要授權的公司代碼。
#經授權該公司即可讀取此筆資料。- 完整欄位
#M: 必填欄位;O: 選填欄位
欄位名稱 必填 描述 $.id M pfId 產品足跡識別碼 (uuid格式)
新增資料時由系統自動填入。$.specVersion M 對應 PCF Data Exchange 文件版號。
目前僅支援 "2.0.0"$.precedingPfIds O 前一個版本的 pfId
新增資料時由系統自動填入。$.version M 產品足跡版本
資料型態: Integer。$.created M 資料製造日期
新增資料時由系統自動填入。$.updated O 資料更新日期
修改資料時由系統自動填入。$.status M 使用狀態
系統自動填入代碼$.statusComment O 使用狀態說明 $.validityPeriodStart O 資料有限期限開始時間 $.validityPeriodEnd O 資料有限期限結束時間 $.companyName M 公司名稱 $.companyIds M 公司 Id
資料型態: Array。$.productDescription M 產品敘述 $.productIds M 產品 Id
資料型態: Array。$.productCategoryCpc M 聯合國產品分類代碼 (CPC) $.productNameCompany M 商品名稱 $.comment M 批注 $.pcf M 產品碳足跡資料
參閱 pcf 欄位解說。
資料型態: JSON。$.extensions O 擴充資料
資料型態: JSON。- pfp裡面 pcf的內容
#M: 必填欄位;O: 選填欄位
欄位名稱 必填 描述 $.declaredUnit M 產品分析單位 $.unitaryProductAmount M 產品包含的份量 $.pCfExcludingBiogenic M 產品碳足跡 (不包含生物排放) $.pCfIncludingBiogenic O* 產品碳足跡 (包含生物排放) $.fossilGhgEmissions M 化石源燃燒所產生的碳排 $.fossilCarbonContent M 產品包含的化石源碳含量 $.biogenicCarbonContent M 產品包含的生物碳含量 $.dLucGhgEmissions O* 土地轉化產生的碳排 $.landManagementGhgEmissions O* 土地管理變化產生的碳排 $.otherBiogenicGhgEmissions O* 與產品製造和運輸相關不包含土地轉化 (dLuc, iLud) 的碳排 $.iLucGhgEmissions O 產品造成的土地轉化產生的碳排(非公司土地) $.biogenicCarbonWithdrawal O* 產品過程生物成因產生的碳排 $.aircraftGhgEmissions O 使用飛機運輸造成的碳排 $.characterizationFactors M 計算 PCF 的 GWP 特徵因子的 IPCC (AR5, AR6) $.crossSectoralStandardsUsed M 計算溫室氣體排放量的跨部份標準
#資料型態: Array。$.productOrSectorSpecificRules O 用於計算或分配溫室氣體排放的特定規則
#資料型態: Array。$.biogenicAccountingMethodology O* 遵循的標準必須是以下之一 (PEF, ISO 14067, GHGP) $.boundaryProcessesDescription M 每個週期的過程敘述 $.referencePeriodStart M 週期時間開始 $.referencePeriodEnd M 週期時間結束 $.geographyCountrySubdivision 國家, 城市; ISO 3166-2 $.geographyCountry 國家, ISO3166-2 $.geographyRegionOrSubregion 區域 (ASIA) $.secondaryEmissionFactorSources O 使用輔助數據計算(使用輔助計算必須提供參考數據)。
#資料型態: Array。$.exemptedEmissionsPercent M 從 PCF 排除的排放比例,數字介於(0~5)%之間 $.exemptedEmissionsDescription M 排除 PCF 的理由 $.packagingEmissionsIncluded M 包裝碳排是否包含在 PCF 中 $.packagingGhgEmissions O 包裝產生的碳排 $.allocationRulesDescription O 對應規則描述 $.uncertaintyAssessmentDescription O 不確定因素的評估敘述 $.primaryDataShare O* 主要數據的百分比
#資料型態: Number。$.dqi O* 存在__primaryDataShare__不用填 dpi
#資料型態: JSON。$.assurance O 數據保證單位
#資料型態: JSON。回傳格式
{ "id" : "d9be4477-e351-45b3-acd9-e1da05e6f633" }回傳欄位
| 欄位名稱 | 描述 |
|---|---|
| $.id | 新增的產品碳足跡 id |
刪除產品碳足跡
Note: 此功能停用。
功能敘述 刪除產品碳足跡資料。
Note: 資料擁有公司及其資訊廠商可以執行此動作。
端點位置
Method URL DELETE {baseUrl}/PCF/{pfpId} Header
Key Value content-type application/json authorization Bearer {access_token} 路徑參數
參數名稱 描述 pfpId 碳足跡代碼 請求格式
無請求欄位
欄位名稱 描述 無 回傳格式
{ "id" : "d9be4477-e351-45b3-acd9-e1da05e6f633" }回傳欄位
欄位名稱 描述 $.id 刪除的產品碳足跡 id
修改產品碳足跡
功能敘述
修改產品碳足跡資料。
Note: 資料擁有公司及其資訊廠商可以執行此動作。。
端點位置
Method URL PATCH {baseUrl}/PCF/{pfpId} Header
Key Value content-type application/json authorization Bearer {access_token} 路徑參數
參數名稱 描述 pfpId 碳足跡代碼 請求格式
請參閱 新增產品碳足跡 - 請求格式請求欄位
請參閱 新增產品碳足跡 - 請求欄位回傳格式
{ "id" : "d9be4477-e351-45b3-acd9-e1da05e6f633" }回傳欄位
欄位名稱 描述 $.id 修改的產品碳足跡 id
取得產品碳足跡
功能敘述
查詢特定產品碳足跡資料。
Note: 資料擁有公司、資訊廠商及被授權公司才看得到資料。
端點位置
Method URL GET {baseUrl}/PCF/{pfpId} Header
Key Value content-type application/json authorization Bearer {access_token} 路徑參數
參數名稱 描述 pfpId 碳足跡代碼 請求格式
無請求欄位
欄位名稱 描述 無 回傳格式
{ "data": { "company": { "serial": 48, "companyName": "My Corp", "taxIDNumber": "05076416", "companyId": "urn:uuid:451204CF-B1E7-CA82-57AB-F6195B17BFD6" }, "PCF": { "id": "d9be4477-e351-45b3-acd9-e1da05e6f633", "specVersion": "2.0.0", "version": 1, "created": "", "status": "Active", "companyName": "My Corp", "companyIds": [ "urn:uuid:00000001-42A2-4267-A402-0ECFEFAD1619" ], "productDescription": "Cote'd Or Ethanol", "productIds": [ "urn:gtin:1300000000000" ], "productCategoryCpc": "123", "productNameCompany": "Green Ethanol", "comment": "xxx", "pcf": { "declaredUnit": "liter", "unitaryProductAmount": "12.0", "pCfExcludingBiogenic": "0.0", "fossilGhgEmissions": "0.123", "fossilCarbonContent": "0.0", "biogenicCarbonContent": "0.0", "landManagementGhgEmissions": "0.01", "characterizationFactors": "AR5", "crossSectoralStandardsUsed": [ "GHG Protocol Product standard" ], "productOrSectorSpecificRules": [ { "operator": "EPD International", "ruleNames": [ "ABC 2021" ] } ], "boundaryProcessesDescription": "End-of-life included", "referencePeriodStart": "2022-01-01T00:00:00Z", "referencePeriodEnd": "2023-01-01T00:00:00Z", "geographyCountry": "AC", "secondaryEmissionFactorSources": [ { "name": "Ecoinvent", "version": "1.2.3" } ], "exemptedEmissionsPercent": 3.1, "exemptedEmissionsDescription": "xxx", "packagingEmissionsIncluded": false, "primaryDataShare": 56.12, "assurance": { "coverage": "product line", "level": "reasonable", "boundary": "Cradle-to-Gate", "providerName": "My Auditor", "completedAt": "2022-12-08T14:47:32Z", "standardName": "ISO ...", "comments": "This is a comment" } }, "extensions": [ { "specVersion": "2.0.0", "dataSchema": "https://catalog.carbon-transparency.com/shipment/1.0.0/data-model.json", "data": { "shipmentId": "S1234567890", "consignmentId": "Cabc.def-ghi", "shipmentType": "PICKUP", "weight": 10, "transportChainElementId": "ABCDEFGHI" } } ] } } }回傳欄位
請參閱 新增產品碳足跡 - 請求欄位
查詢產品碳足跡
功能敘述
過濾特定產品碳足跡資料。
Note: 資料擁有公司、資訊廠商及被授權公司才看得到資料。
端點位置
Method URL GET {baseUrl}/PCF/{statusValue}/{item}/{value} Header
Key Value content-type application/json authorization Bearer {access_token} 路徑參數
參數名稱 描述 statusValue 碳足跡狀態值 (All, Active, Deprecated) item 可以查尋的欄位名稱 (id, companyName, companyIds, productIds, comment) value 欄位數值 Note: 使用這些屬性去篩選取得想要的公司資訊。
屬性名稱 描述 id 產品碳足跡 id companyName 公司名稱 companyIds 公司代碼 productIds 產品代碼 comment 備註 請求格式
無請求欄位
欄位名稱 描述 無 回傳格式
請參閱 產品碳足跡清單 - 回傳格式回傳欄位
請參閱 新增產品碳足跡 - 請求欄位
產品碳足跡過濾
功能敘述
產品碳足跡過濾。使用方式同產品碳足跡清單增設狀態值 (All, Active, Deprecated) 去過濾產品碳足跡。
Note: 資料擁有公司、資訊廠商及被授權公司才看得到資料。
端點位置
Method URL GET {baseUrl}/PCF/{statusValue} Header
Key Value content-type application/json authorization Bearer {access_token} 路徑參數
參數名稱 描述 statusValue 碳足跡狀態值 (All, Active, Deprecated) created
updated
productCategoryCpc
geographyCountry
referencePeriodStart
referencePeriodEnd可以使用 eq, lt, le, gt, ge companyIds
productIds僅適用 eq Note:
1. 搜尋聯合國產品分類代碼 (CPC):$filter=productCategoryCpc eq '3342'
2. 搜尋國家:$filter=pcf/geographyCountry eq 'DE'
3. 搜尋週期時間區間:$filter=(pcf/referencePeriodStart ge '2023-01-01T00:00:00.000Z') and (pcf/referencePeriodEnd lt '2024-01-01T00:00:00.000Z')
4. 搜尋產品 Id:$filter=productIds/any(productId:(productId eq 'urn:...'))
5. limit 使用說明:限制搜尋的筆數。請求格式
無請求欄位
欄位名稱 描述 無 回傳格式
{ "data": [ { "company": { "serial": 89, "companyName": "財團法人資訊工業策進會", "taxIDNumber": "05076416", "companyId": "urn:uuid:4210D0F6-D577-8490-A2E0-0C91F2FDC5AE" }, "PCF": { "id": "d9be4477-e351-45b3-acd9-e1da05e6f633", "specVersion": "2.0.0", "version": 1, "created": "", "status": "Active", "companyName": "My Corp", "companyIds": [ "urn:uuid:00000001-42A2-4267-A402-0ECFEFAD1619" ], "productDescription": "Cote'd Or Ethanol", "productIds": [ "urn:gtin:1300000000000" ], "productCategoryCpc": "123", "productNameCompany": "Green Ethanol", "comment": "xxx", "pcf": { "declaredUnit": "liter", "unitaryProductAmount": "12.0", "pCfExcludingBiogenic": "0.0", "fossilGhgEmissions": "0.123", "fossilCarbonContent": "0.0", "biogenicCarbonContent": "0.0", "landManagementGhgEmissions": "0.01", "characterizationFactors": "AR5", "crossSectoralStandardsUsed": [ "GHG Protocol Product standard" ], "productOrSectorSpecificRules": [ { "operator": "EPD International", "ruleNames": [ "ABC 2021" ] } ], "boundaryProcessesDescription": "End-of-life included", "referencePeriodStart": "2022-01-01T00:00:00Z", "referencePeriodEnd": "2023-01-01T00:00:00Z", "geographyCountry": "AC", "secondaryEmissionFactorSources": [ { "name": "Ecoinvent", "version": "1.2.3" } ], "exemptedEmissionsPercent": 3.1, "exemptedEmissionsDescription": "xxx", "packagingEmissionsIncluded": false, "primaryDataShare": 56.12, "assurance": { "coverage": "product line", "level": "reasonable", "boundary": "Cradle-to-Gate", "providerName": "My Auditor", "completedAt": "2022-12-08T14:47:32Z", "standardName": "ISO ...", "comments": "This is a comment" } }, "extensions": [ { "specVersion": "2.0.0", "dataSchema": "https://catalog.carbon-transparency.com/shipment/1.0.0/data-model.json", "data": { "shipmentId": "S1234567890", "consignmentId": "Cabc.def-ghi", "shipmentType": "PICKUP", "weight": 10, "transportChainElementId": "ABCDEFGHI" } } ] } } ] }回傳欄位
請參閱 新增產品碳足跡 - 請求欄位
產品碳足跡清單
功能敘述
產品碳足跡清單。
Note: 資料擁有公司、資訊廠商及被授權公司才看得到資料。
端點位置
Method URL GET {baseUrl}/PCF Header
Key Value content-type application/json authorization Bearer {access_token} 路徑參數
參數名稱 描述 created
updated
productCategoryCpc
geographyCountry
referencePeriodStart
referencePeriodEnd可以使用 eq, lt, le, gt, ge companyIds
productIds僅適用 eq Note:
1. 搜尋聯合國產品分類代碼 (CPC):$filter=productCategoryCpc eq '3342'
2. 搜尋國家:$filter=pcf/geographyCountry eq 'DE'
3. 搜尋週期時間區間:$filter=(pcf/referencePeriodStart ge '2023-01-01T00:00:00.000Z') and (pcf/referencePeriodEnd lt '2024-01-01T00:00:00.000Z')
4. 搜尋產品 Id:$filter=productIds/any(productId:(productId eq 'urn:...'))
5. limit 使用說明:限制搜尋的筆數。請求格式
無請求欄位
欄位名稱 描述 無 回傳格式
{ "data": [ { "company": { "serial": 48, "companyName": "My Corp", "taxIDNumber": "05076416", "companyId": "urn:uuid:451204CF-B1E7-CA82-57AB-F6195B17BFD6" }, "PCF": { "id": "d9be4477-e351-45b3-acd9-e1da05e6f633", "specVersion": "2.0.0", "version": 1, "created": "", "status": "Active", "companyName": "My Corp", "companyIds": [ "urn:uuid:00000001-42A2-4267-A402-0ECFEFAD1619" ], "productDescription": "Cote'd Or Ethanol", "productIds": [ "urn:gtin:1300000000000" ], "productCategoryCpc": "123", "productNameCompany": "Green Ethanol", "comment": "xxx", "pcf": { "declaredUnit": "liter", "unitaryProductAmount": "12.0", "pCfExcludingBiogenic": "0.0", "fossilGhgEmissions": "0.123", "fossilCarbonContent": "0.0", "biogenicCarbonContent": "0.0", "landManagementGhgEmissions": "0.01", "characterizationFactors": "AR5", "crossSectoralStandardsUsed": [ "GHG Protocol Product standard" ], "productOrSectorSpecificRules": [ { "operator": "EPD International", "ruleNames": [ "ABC 2021" ] } ], "boundaryProcessesDescription": "End-of-life included", "referencePeriodStart": "2022-01-01T00:00:00Z", "referencePeriodEnd": "2023-01-01T00:00:00Z", "geographyCountry": "AC", "secondaryEmissionFactorSources": [ { "name": "Ecoinvent", "version": "1.2.3" } ], "exemptedEmissionsPercent": 3.1, "exemptedEmissionsDescription": "xxx", "packagingEmissionsIncluded": false, "primaryDataShare": 56.12, "assurance": { "coverage": "product line", "level": "reasonable", "boundary": "Cradle-to-Gate", "providerName": "My Auditor", "completedAt": "2022-12-08T14:47:32Z", "standardName": "ISO ...", "comments": "This is a comment" } }, "extensions": [ { "specVersion": "2.0.0", "dataSchema": "https://catalog.carbon-transparency.com/shipment/1.0.0/data-model.json", "data": { "shipmentId": "S1234567890", "consignmentId": "Cabc.def-ghi", "shipmentType": "PICKUP", "weight": 10, "transportChainElementId": "ABCDEFGHI" } } ] } } ] }回傳欄位
請參閱 新增產品碳足跡 - 請求欄位
產品碳足跡 - PACT 專用格式
| 功能 | 端點位置 | Method | 驗證 |
|---|---|---|---|
| 取得使用 TOKEN | {pactUrl}/auth/token | POST | ● |
| 取得產品碳足跡 | {pactUrl}/2/footprint/{pfpId} | GET | ● |
| 產品碳足跡清單 | {pactUrl}/2/footprint | GET | ● |
Note: PACT API 端點: {pactUrl} 為 https://api.dsce.com.tw/app/api
取得使用 TOKEN
功能敘述
client_id, client_secret 在新建公司成功後即可以取得,使用它們來取得授權的 Token 使用其他 API。
Note: 透過 access_token 去使用需要經過驗證的 API。
端點位置
Method URL POST {pactUrl}/auth/token Header
Key Value content-type application/json 路徑參數
參數名稱 描述 無 請求格式
x-www-form-urlencoded請求欄位
欄位名稱 描述 client_id 公司識別碼 client_secret 公司密鑰 grant_type client_credentials 回傳格式
{ 'access_token': 'ttttt', 'expires_in': 1800, 'refresh_expires_in': 0, 'token_type': 'Bearer', 'not-before-policy': 0, 'scope': 'email profile' }回傳欄位
欄位名稱 描述 $.access_token 存取權杖 $.expires_in 過期時間(秒) $.refresh_expires_in 更新權杖過期時間(秒),0表示不採用更新權杖機制 $.token_type 權杖類型 $.not-before-policy 啟用前策略時間(秒) $.scope 權限範圍
取得產品碳足跡
功能敘述
查詢特定產品碳足跡資料。
Note: 資料擁有公司、資訊廠商及被授權公司才看得到資料。
端點位置
Method URL GET {pactUrl}/2/footprint/{pfpId} Header
Key Value content-type application/json authorization Bearer {access_token} 路徑參數
參數名稱 描述 pfpId 碳足跡代碼 請求格式
無請求欄位
欄位名稱 描述 無 回傳格式
{ "data": { "id": "d9be4477-e351-45b3-acd9-e1da05e6f633", "specVersion": "2.0.0", "version": 1, "created": "", "status": "Active", "companyName": "My Corp", "companyIds": [ "urn:uuid:00000001-42A2-4267-A402-0ECFEFAD1619" ], "productDescription": "Cote'd Or Ethanol", "productIds": [ "urn:gtin:1300000000000" ], "productCategoryCpc": "123", "productNameCompany": "Green Ethanol", "comment": "xxx", "pcf": { "declaredUnit": "liter", "unitaryProductAmount": "12.0", "pCfExcludingBiogenic": "0.0", "fossilGhgEmissions": "0.123", "fossilCarbonContent": "0.0", "biogenicCarbonContent": "0.0", "landManagementGhgEmissions": "0.01", "characterizationFactors": "AR5", "crossSectoralStandardsUsed": [ "GHG Protocol Product standard" ], "productOrSectorSpecificRules": [ { "operator": "EPD International", "ruleNames": [ "ABC 2021" ] } ], "boundaryProcessesDescription": "End-of-life included", "referencePeriodStart": "2022-01-01T00:00:00Z", "referencePeriodEnd": "2023-01-01T00:00:00Z", "geographyCountry": "AC", "secondaryEmissionFactorSources": [ { "name": "Ecoinvent", "version": "1.2.3" } ], "exemptedEmissionsPercent": 3.1, "exemptedEmissionsDescription": "xxx", "packagingEmissionsIncluded": false, "primaryDataShare": 56.12, "assurance": { "coverage": "product line", "level": "reasonable", "boundary": "Cradle-to-Gate", "providerName": "My Auditor", "completedAt": "2022-12-08T14:47:32Z", "standardName": "ISO ...", "comments": "This is a comment" } }, "extensions": [ { "specVersion": "2.0.0", "dataSchema": "https://catalog.carbon-transparency.com/shipment/1.0.0/data-model.json", "data": { "shipmentId": "S1234567890", "consignmentId": "Cabc.def-ghi", "shipmentType": "PICKUP", "weight": 10, "transportChainElementId": "ABCDEFGHI" } } ] } }回傳欄位
請參閱 新增產品碳足跡 - 請求欄位
產品碳足跡清單
功能敘述
產品碳足跡清單。
Note: 資料擁有公司、資訊廠商及被授權公司才看得到資料。
端點位置
Method URL GET {pactUrl}/2/footprint Header
Key Value content-type application/json authorization Bearer {access_token} 路徑參數
參數名稱 描述 created
updated
productCategoryCpc
geographyCountry
referencePeriodStart
referencePeriodEnd可以使用 eq, lt, le, gt, ge companyIds
productIds僅適用 eq Note:
1. 搜尋聯合國產品分類代碼 (CPC):$filter=productCategoryCpc eq '3342'
2. 搜尋國家:$filter=pcf/geographyCountry eq 'DE'
3. 搜尋週期時間區間:$filter=(pcf/referencePeriodStart ge '2023-01-01T00:00:00.000Z') and (pcf/referencePeriodEnd lt '2024-01-01T00:00:00.000Z')
4. 搜尋產品 Id:$filter=productIds/any(productId:(productId eq 'urn:...'))
5. limit 使用說明:限制搜尋的筆數。請求格式
無請求欄位
欄位名稱 描述 無 回傳格式
{ "data": [ { "id": "d9be4477-e351-45b3-acd9-e1da05e6f633", "specVersion": "2.0.0", "version": 1, "created": "", "status": "Active", "companyName": "My Corp", "companyIds": [ "urn:uuid:00000001-42A2-4267-A402-0ECFEFAD1619" ], "productDescription": "Cote'd Or Ethanol", "productIds": [ "urn:gtin:1300000000000" ], "productCategoryCpc": "123", "productNameCompany": "Green Ethanol", "comment": "xxx", "pcf": { "declaredUnit": "liter", "unitaryProductAmount": "12.0", "pCfExcludingBiogenic": "0.0", "fossilGhgEmissions": "0.123", "fossilCarbonContent": "0.0", "biogenicCarbonContent": "0.0", "landManagementGhgEmissions": "0.01", "characterizationFactors": "AR5", "crossSectoralStandardsUsed": [ "GHG Protocol Product standard" ], "productOrSectorSpecificRules": [ { "operator": "EPD International", "ruleNames": [ "ABC 2021" ] } ], "boundaryProcessesDescription": "End-of-life included", "referencePeriodStart": "2022-01-01T00:00:00Z", "referencePeriodEnd": "2023-01-01T00:00:00Z", "geographyCountry": "AC", "secondaryEmissionFactorSources": [ { "name": "Ecoinvent", "version": "1.2.3" } ], "exemptedEmissionsPercent": 3.1, "exemptedEmissionsDescription": "xxx", "packagingEmissionsIncluded": false, "primaryDataShare": 56.12, "assurance": { "coverage": "product line", "level": "reasonable", "boundary": "Cradle-to-Gate", "providerName": "My Auditor", "completedAt": "2022-12-08T14:47:32Z", "standardName": "ISO ...", "comments": "This is a comment" } }, "extensions": [ { "specVersion": "2.0.0", "dataSchema": "https://catalog.carbon-transparency.com/shipment/1.0.0/data-model.json", "data": { "shipmentId": "S1234567890", "consignmentId": "Cabc.def-ghi", "shipmentType": "PICKUP", "weight": 10, "transportChainElementId": "ABCDEFGHI" } } ] } ] }回傳欄位
請參閱 新增產品碳足跡 - 請求欄位
產品碳足跡權限設定
| 功能 | 端點位置 | Method | 驗證 |
|---|---|---|---|
| 新建產品碳足跡權限 | {baseUrl}/pfpaccess/{pfpId} | POST | ● |
| 刪除產品碳足跡權限 | {baseUrl}/pfpaccess/{pfpId} | DELETE | ● |
| 修改產品碳足跡權限 | {baseUrl}/pfpaccess/{pfpId} | PATCH | ● |
| 取得產品碳足跡權限 | {baseUrl}/pfpaccess/{pfpId} | GET | ● |
新建產品碳足跡權限
功能敘述
新建產品碳足跡權限。
Note:
1.新增產品碳足跡時會一併自動設定產品碳足跡權限;使用碳足跡權限設定 API 調整使用權限。
2.資料擁有公司、資訊廠商才能進行調整。端點位置
Method URL POST {baseUrl}/pfpaccess/{pfpId} Header
Key Value content-type application/json authorization Bearer {access_token} 路徑參數
參數名稱 描述 pfpId 碳足跡代碼 請求格式
{ "openData": "N", "centerSn": "13,17" }請求欄位
欄位名稱 描述 說明 openData 填入資料是否開放讀取?
#開放資料所有人均可讀取。Y/N centerSn 授權可使用的公司代碼 Note:
(1) openData 值為 'Y' 時,表示資料開放,為 'N' 時,表示資料不開放。
(2) centerSn 值以 , 區隔設定多筆資料。舉例來說:13, 17 表示授權公司代碼 13, 17 使用此筆資料。回傳格式
{ 'message': 'OK' }回傳欄位
欄位名稱 描述 message 設定結果 'OK' 表示設定成功
刪除產品碳足跡權限
功能敘述
刪除產品碳足跡權限。
Note: 資料擁有公司、資訊廠商才能進行調整。
端點位置
Method URL DELETE {baseUrl}/pfpaccess/{pfpId} Header
Key Value content-type application/json authorization Bearer {access_token} 路徑參數
參數名稱 描述 pfpId 碳足跡代碼 請求格式
無請求欄位
欄位名稱 描述 無 回傳格式
{ 'message': 'OK' }回傳欄位
欄位名稱 描述 message 設定結果 'OK' 表示設定成功
修改產品碳足跡權限
功能敘述
修改產品碳足跡權限。
Note: 資料擁有公司、資訊廠商才能進行調整。
端點位置
Method URL PATCH {baseUrl}/pfpaccess/{pfpId} Header
Key Value content-type application/json authorization Bearer {access_token} 路徑參數
參數名稱 描述 pfpId 碳足跡代碼 請求格式
{ "openData": "N", "centerSn": "13,17" }請求欄位
欄位名稱 描述 說明 openData 填入資料是否開放讀取?
#開放資料所有人均可讀取。Y/N centerSn 授權可使用的公司代碼 Note:
(1) openData 值為 'Y' 時,表示資料開放,為 'N' 時,表示資料不開放。
(2) centerSn 值以 , 區隔設定多筆資料。舉例來說:13, 17 表示授權公司代碼 13, 17 使用此筆資料。回傳格式
{ 'message': 'OK' }回傳欄位
欄位名稱 描述 message 設定結果 'OK' 表示設定成功
取得產品碳足跡權限
功能敘述
修改產品碳足跡權限。
Note: 資料擁有公司、資訊廠商才能進行調整。
端點位置
Method URL GET {baseUrl}/pfpaccess/{pfpId} Header
Key Value content-type application/json authorization Bearer {access_token} 路徑參數
參數名稱 描述 pfpId 碳足跡代碼 請求格式
無請求欄位
欄位名稱 描述 無 回傳格式
{ "data": { "openData": "N", "centerSn": "13,17" } }回傳欄位
欄位名稱 描述 openData 填入資料是否開放讀取?
#開放資料所有人均可讀取。centerSn 授權可使用的公司代碼
產品碳足跡使用記錄
| 功能 | 端點位置 | Method | 驗證 |
|---|---|---|---|
| 產品碳足跡使用清單 | {baseUrl}/accessevents | GET | ● |
| 產品碳足跡使用總量 | {baseUrl}/sumaccessevents | GET | ● |
| 產品碳足跡使用次數 | {baseUrl}/countaccessevents | GET | ● |
產品碳足跡使用清單
功能敘述
條列使用項目詳細內容。
Note: 僅列出自己使用記錄。
端點位置
Method URL GET {baseUrl}/accessevents Header
Key Value content-type application/json authorization Bearer {access_token} 路徑參數
參數名稱 描述 from 統計起始日期 to 統計結束日期 請求格式
無請求欄位
欄位名稱 描述 無 回傳格式
{ "data": [ { "serial": 30, "companySn": 9, "rw": "READ", "size": 1633, "filter": "4FF1707D-AE9F-3FB7-3522-DC68B2B5AE96", "created": "2023-09-13 08:44:25" }, { "serial": 30, "companySn": 9, "rw": "READ", "size": 1633, "filter": "4FF1707D-AE9F-3FB7-3522-DC68B2B5AE96", "created": "2023-09-13 08:44:25" } ] }回傳欄位
欄位名稱 描述 $.serial 序號 $.companySn 公司流水號 $.rw 動作 (CREATE/UPDATE/DELETE/DEPRECATED/
GET/FIND/LIST)$.size 使用量 $.filter 關鍵字句 $.created 使用時間
產品碳足跡使用總量
功能敘述
計算產品碳足跡使用總量。
Note: 僅計算自身的使用量。
端點位置
Method URL GET {baseUrl}/sumaccessevents Header
Key Value content-type application/json authorization Bearer {access_token} 路徑參數
參數名稱 描述 from 統計起始日期 to 統計結束日期 請求格式
無請求欄位
欄位名稱 描述 無 回傳格式
{ data: xxx }回傳欄位
欄位名稱 描述 $.data 區間用量
產品碳足跡使用次數
功能敘述
計算產品碳足跡使用次數。
Note: 僅計算自身的使用次數。
端點位置
Method URL GET {baseUrl}/countaccessevents Header
Key Value content-type application/json authorization Bearer {access_token} 路徑參數
參數名稱 描述 from 統計起始日期 to 統計結束日期 請求格式
無請求欄位
欄位名稱 描述 無 回傳格式
{ data: xxx }回傳欄位
欄位名稱 描述 $.data 使用次數
錯誤回應訊息
| 回應號碼 | 錯誤訊息 (message) |
|---|---|
| 200 | OK. |
| 202 | Accepted. |
| 400 | Bad Request. |
| 401 | The specified access token has expired. |
| 403 | AccessDenied |
| 404 | NoSuchFootprint |
| 500 | InternalError |