{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Search" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Table of contents**\n", "- Overview\n", "- Setup\n", " - Authentication Token\n", "- Query\n", " - Output Description\n", "- Related Links" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Overview" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This notebook demonstrates how to use the Search API to find and browse multiple emission factors that match specific criteria. It allows users to:\n", "\n", "- Search for emission factors using keywords (e.g., \"gas\", \"electricity\")\n", "- Filter results by location and date\n", "- Navigate through paginated results to explore all available options\n", "- Compare different emission factors before selecting one for calculations\n", "\n", "The Search API is valuable for exploration and discovery, helping users understand what emission factors are available before making calculations or when they need to compare multiple methodologies. This is particularly useful when exploring available emissions factors for a specific activity type or region. The results include detailed information about each factor, including its source, scope, unit of measurement, and emissions values, presented in a paginated format for easy navigation through large result sets." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setup" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "Ensure that you have Python installed in your system. Python 3+ is required.\n", "\n", "Note: To run this notebook, you must first add your credentials to `config.read('../../../auth/secrets.ini')` in the following format:\n", "\n", "\n", "```\n", "[EAPI]\n", "api.api_key = \n", "api.client_id = \n", "api.org_id = \n", "\n", "```" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Install the packages below using pip/pip3 based on your python version.\n", "%pip install pandas configparser IPython requests" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import configparser\n", "import requests\n", "import json\n", "from IPython.display import display as display_summary" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Authentication Token\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "Run the following code snippet to generate the Auth Bearer Token by using your api_key configured in secrets.ini." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Authentication Success\n" ] } ], "source": [ "config = configparser.RawConfigParser()\n", "config.read(['../../../auth/secrets.ini','../../../auth/config.ini'])\n", "\n", "EAPI_API_KEY = config.get('EAPI', 'api.api_key')\n", "EAPI_TENANT_ID = config.get('EAPI', 'api.tenant_id')\n", "EAPI_ORG_ID = config.get('EAPI', 'api.org_id') \n", "\n", "EAPI_AUTH_ENDPOINT = config.get('EAPI', 'api.auth_endpoint')\n", "EAPI_BASE_URL = config.get('EAPI', 'api.base_url')\n", "EAPI_ENDPOINT = f\"{EAPI_BASE_URL}/factor/search\"\n", "\n", "EAPI_AUTH_CLIENT_ID = 'saascore-' + EAPI_TENANT_ID\n", "EAPI_CLIENT_ID = 'ghgemissions-' + EAPI_TENANT_ID\n", "\n", "auth_request_headers: dict = {}\n", "auth_request_headers[\"X-IBM-CLIENT-ID\"] = EAPI_AUTH_CLIENT_ID\n", "auth_request_headers[\"X-API-KEY\"] = EAPI_API_KEY\n", "\n", "verify = True\n", "\n", "auth_url = f\"{EAPI_AUTH_ENDPOINT}?orgId={EAPI_ORG_ID}\"\n", " \n", "response = requests.get(url = auth_url,\n", " headers = auth_request_headers,\n", " verify = verify\n", " )\n", "if response.status_code == 200:\n", " jwt_token = response.text\n", " print(\"Authentication Success\")\n", "else: \n", " print(\"Authentication Failed\")\n", " print(response.text)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Query" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The example request payload demonstrates how to search for emission factors using IBM Envizi - Emissions API by specifying location (India), a keyword (\"gas\"), pagination parameters (page 1, 30 results), and a reference date (January 4, 2024)." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "payload = {\n", " \"location\": {\n", " \"country\": \"ind\"\n", " },\n", " \"activity\": {\n", " \"search\": \"gas\"\n", " },\n", " \"pagination\": {\n", " \"page\": 1,\n", " \"size\": 30\n", " },\n", " \"time\": {\n", " \"date\": \"2024-01-04\"\n", " }\n", "}" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "# Create the query headers\n", "request_headers: dict = {}\n", "request_headers[\"Content-Type\"] = \"application/json\"\n", "request_headers[\"x-ibm-client-id\"] = EAPI_CLIENT_ID\n", "request_headers[\"Authorization\"] = \"Bearer \" + jwt_token\n", "\n", "# Submit the request\n", "response = requests.post(EAPI_ENDPOINT, \n", " headers = request_headers, \n", " data = json.dumps(payload))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For more information about allowable parameters for the payload, please see [Emissions API Developer Guide]()." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Found 30 matching factors\n", "\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
factorSetsourceactivityTypeactivityUniteffectiveFrompublishedFromregionfactorId
0Managed - eGRID & US Climate LeadersSupply Chain Greenhouse Gas Emission Factors v1.3 by NAICS-6, Publisher: U.S. EPA Office of Research and Development (ORD). Published on: 10-July-2024Mining, except oil and gasUSD01/01/202401/01/2024Earth162166
1Managed - eGRID & US Climate LeadersSupply Chain Greenhouse Gas Emission Factors v1.3 by NAICS-6, Publisher: U.S. EPA Office of Research and Development (ORD). Published on: 10-July-2024Mining, except oil and gasUSD01/01/202401/01/2024Earth162167
2Managed - eGRID & US Climate LeadersSupply Chain Greenhouse Gas Emission Factors v1.3 by NAICS-6, Publisher: U.S. EPA Office of Research and Development (ORD). Published on: 10-July-2024Mining, except oil and gasUSD01/01/202401/01/2024Earth162168
3Managed - eGRID & US Climate LeadersSupply Chain Greenhouse Gas Emission Factors v1.3 by NAICS-6, Publisher: U.S. EPA Office of Research and Development (ORD). Published on: 10-July-2024Mining, except oil and gasUSD01/01/202401/01/2024Earth162169
4Managed - eGRID & US Climate LeadersSupply Chain Greenhouse Gas Emission Factors v1.3 by NAICS-6, Publisher: U.S. EPA Office of Research and Development (ORD). Published on: 10-July-2024Mining, except oil and gasUSD01/01/202401/01/2024Earth162170
5Managed - eGRID & US Climate LeadersSupply Chain Greenhouse Gas Emission Factors v1.3 by NAICS-6, Publisher: U.S. EPA Office of Research and Development (ORD). Published on: 10-July-2024Mining, except oil and gasUSD01/01/202401/01/2024Earth162171
6Managed - eGRID & US Climate LeadersUS EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hubNatural Gas100 cf01/01/202401/01/2024Earth162923
7Managed - eGRID & US Climate LeadersUS EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hubNatural Gas1000 cf01/01/202401/01/2024Earth162924
8Managed - eGRID & US Climate LeadersUS EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hubNatural Gasccf01/01/202401/01/2024Earth162925
9Managed - eGRID & US Climate LeadersUS EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hubNatural Gascf01/01/202401/01/2024Earth162926
10Managed - eGRID & US Climate LeadersUS EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hubNatural Gas - Scope 2cf01/01/202401/01/2024Earth169709
11Managed - eGRID & US Climate LeadersUS EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hubNatural Gas - Scope 3cf01/01/202401/01/2024Earth162927
12Managed - eGRID & US Climate LeadersUS EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hubNatural Gasdekatherms01/01/202401/01/2024Earth162928
13Managed - eGRID & US Climate LeadersUS EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hubNatural GasGJ01/01/202401/01/2024Earth162929
14Managed - eGRID & US Climate LeadersUS EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hubNatural GaskBtu01/01/202401/01/2024Earth162930
15Managed - eGRID & US Climate LeadersUS EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hubNatural GaskWh01/01/202401/01/2024Earth162931
16Managed - eGRID & US Climate LeadersUS EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hubNatural Gasm301/01/202401/01/2024Earth162933
17Managed - eGRID & US Climate LeadersUS EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hubNatural Gas - Scope 3m301/01/202401/01/2024Earth162934
18Managed - eGRID & US Climate LeadersUS EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hubNatural GasMJ01/01/202401/01/2024Earth162935
19Managed - eGRID & US Climate LeadersUS EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hubNatural GasMMBtu01/01/202401/01/2024Earth162936
20Managed - eGRID & US Climate LeadersUS EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hubNatural Gas - Scope 3MMBtu01/01/202401/01/2024Earth162937
21Managed - eGRID & US Climate LeadersUS EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hubNatural Gastherms01/01/202401/01/2024Earth162938
22Managed - eGRID & US Climate LeadersUS EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hubNatural Gas - CO2 Onlytherms01/01/202401/01/2024Earth162939
23Managed - eGRID & US Climate LeadersUS EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hubNatural Gas - Scope 2therms01/01/202401/01/2024Earth162940
24Managed - eGRID & US Climate LeadersUS EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hubNatural Gas - Scope 3therms01/01/202401/01/2024Earth162941
25Managed - eGRID & US Climate LeadersSupply Chain Factors Dataset v1.1.1, Tab: 2016_Detail_Commodity, Citation: Ingwersen, W. AND M. Li. Supply Chain Greenhouse Gas Emission Factors for US Industries and Commodities. U.S. Environmental Protection Agency, Washington, DC, EPA/600/R-20/001, 2020.Natural GasUSD01/01/202401/01/2024Earth164378
26Managed - eGRID & US Climate LeadersSupply Chain Greenhouse Gas Emission Factors v1.3 by NAICS-6, Publisher: U.S. EPA Office of Research and Development (ORD). Published on: 10-July-2024Oil and gas extractionUSD01/01/202401/01/2024Earth162285
27Managed - eGRID & US Climate LeadersSupply Chain Greenhouse Gas Emission Factors v1.3 by NAICS-6, Publisher: U.S. EPA Office of Research and Development (ORD). Published on: 10-July-2024Oil and gas extractionUSD01/01/202401/01/2024Earth162286
28Managed - eGRID & US Climate LeadersSupply Chain Factors Dataset v1.1.1, Tab: 2016_Summary_Commodity, Citation: Ingwersen, W. AND M. Li. Supply Chain Greenhouse Gas Emission Factors for US Industries and Commodities. U.S. Environmental Protection Agency, Washington, DC, EPA/600/R-20/001, 2020.Oil and gas extractionUSD01/01/202401/01/2024Earth164065
29Managed - eGRID & US Climate LeadersSupply Chain Factors Dataset v1.1.1, Tab: 2016_Summary_Commodity, Citation: Ingwersen, W. AND M. Li. Supply Chain Greenhouse Gas Emission Factors for US Industries and Commodities. U.S. Environmental Protection Agency, Washington, DC, EPA/600/R-20/001, 2020.Oil and gas extractionUSD01/01/202401/01/2024Earth164131
\n", "
" ], "text/plain": [ " factorSet \\\n", "0 Managed - eGRID & US Climate Leaders \n", "1 Managed - eGRID & US Climate Leaders \n", "2 Managed - eGRID & US Climate Leaders \n", "3 Managed - eGRID & US Climate Leaders \n", "4 Managed - eGRID & US Climate Leaders \n", "5 Managed - eGRID & US Climate Leaders \n", "6 Managed - eGRID & US Climate Leaders \n", "7 Managed - eGRID & US Climate Leaders \n", "8 Managed - eGRID & US Climate Leaders \n", "9 Managed - eGRID & US Climate Leaders \n", "10 Managed - eGRID & US Climate Leaders \n", "11 Managed - eGRID & US Climate Leaders \n", "12 Managed - eGRID & US Climate Leaders \n", "13 Managed - eGRID & US Climate Leaders \n", "14 Managed - eGRID & US Climate Leaders \n", "15 Managed - eGRID & US Climate Leaders \n", "16 Managed - eGRID & US Climate Leaders \n", "17 Managed - eGRID & US Climate Leaders \n", "18 Managed - eGRID & US Climate Leaders \n", "19 Managed - eGRID & US Climate Leaders \n", "20 Managed - eGRID & US Climate Leaders \n", "21 Managed - eGRID & US Climate Leaders \n", "22 Managed - eGRID & US Climate Leaders \n", "23 Managed - eGRID & US Climate Leaders \n", "24 Managed - eGRID & US Climate Leaders \n", "25 Managed - eGRID & US Climate Leaders \n", "26 Managed - eGRID & US Climate Leaders \n", "27 Managed - eGRID & US Climate Leaders \n", "28 Managed - eGRID & US Climate Leaders \n", "29 Managed - eGRID & US Climate Leaders \n", "\n", " source \\\n", "0 Supply Chain Greenhouse Gas Emission Factors v1.3 by NAICS-6, Publisher: U.S. EPA Office of Research and Development (ORD). Published on: 10-July-2024 \n", "1 Supply Chain Greenhouse Gas Emission Factors v1.3 by NAICS-6, Publisher: U.S. EPA Office of Research and Development (ORD). Published on: 10-July-2024 \n", "2 Supply Chain Greenhouse Gas Emission Factors v1.3 by NAICS-6, Publisher: U.S. EPA Office of Research and Development (ORD). Published on: 10-July-2024 \n", "3 Supply Chain Greenhouse Gas Emission Factors v1.3 by NAICS-6, Publisher: U.S. EPA Office of Research and Development (ORD). Published on: 10-July-2024 \n", "4 Supply Chain Greenhouse Gas Emission Factors v1.3 by NAICS-6, Publisher: U.S. EPA Office of Research and Development (ORD). Published on: 10-July-2024 \n", "5 Supply Chain Greenhouse Gas Emission Factors v1.3 by NAICS-6, Publisher: U.S. EPA Office of Research and Development (ORD). Published on: 10-July-2024 \n", "6 US EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hub \n", "7 US EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hub \n", "8 US EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hub \n", "9 US EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hub \n", "10 US EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hub \n", "11 US EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hub \n", "12 US EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hub \n", "13 US EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hub \n", "14 US EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hub \n", "15 US EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hub \n", "16 US EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hub \n", "17 US EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hub \n", "18 US EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hub \n", "19 US EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hub \n", "20 US EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hub \n", "21 US EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hub \n", "22 US EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hub \n", "23 US EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hub \n", "24 US EPA. Feb 2024. EPA Centre for Climate Leadership. Emission Factors for Greenhouse Gas Inventories - https://www.epa.gov/climateleadership/ghg-emission-factors-hub \n", "25 Supply Chain Factors Dataset v1.1.1, Tab: 2016_Detail_Commodity, Citation: Ingwersen, W. AND M. Li. Supply Chain Greenhouse Gas Emission Factors for US Industries and Commodities. U.S. Environmental Protection Agency, Washington, DC, EPA/600/R-20/001, 2020. \n", "26 Supply Chain Greenhouse Gas Emission Factors v1.3 by NAICS-6, Publisher: U.S. EPA Office of Research and Development (ORD). Published on: 10-July-2024 \n", "27 Supply Chain Greenhouse Gas Emission Factors v1.3 by NAICS-6, Publisher: U.S. EPA Office of Research and Development (ORD). Published on: 10-July-2024 \n", "28 Supply Chain Factors Dataset v1.1.1, Tab: 2016_Summary_Commodity, Citation: Ingwersen, W. AND M. Li. Supply Chain Greenhouse Gas Emission Factors for US Industries and Commodities. U.S. Environmental Protection Agency, Washington, DC, EPA/600/R-20/001, 2020. \n", "29 Supply Chain Factors Dataset v1.1.1, Tab: 2016_Summary_Commodity, Citation: Ingwersen, W. AND M. Li. Supply Chain Greenhouse Gas Emission Factors for US Industries and Commodities. U.S. Environmental Protection Agency, Washington, DC, EPA/600/R-20/001, 2020. \n", "\n", " activityType activityUnit effectiveFrom publishedFrom \\\n", "0 Mining, except oil and gas USD 01/01/2024 01/01/2024 \n", "1 Mining, except oil and gas USD 01/01/2024 01/01/2024 \n", "2 Mining, except oil and gas USD 01/01/2024 01/01/2024 \n", "3 Mining, except oil and gas USD 01/01/2024 01/01/2024 \n", "4 Mining, except oil and gas USD 01/01/2024 01/01/2024 \n", "5 Mining, except oil and gas USD 01/01/2024 01/01/2024 \n", "6 Natural Gas 100 cf 01/01/2024 01/01/2024 \n", "7 Natural Gas 1000 cf 01/01/2024 01/01/2024 \n", "8 Natural Gas ccf 01/01/2024 01/01/2024 \n", "9 Natural Gas cf 01/01/2024 01/01/2024 \n", "10 Natural Gas - Scope 2 cf 01/01/2024 01/01/2024 \n", "11 Natural Gas - Scope 3 cf 01/01/2024 01/01/2024 \n", "12 Natural Gas dekatherms 01/01/2024 01/01/2024 \n", "13 Natural Gas GJ 01/01/2024 01/01/2024 \n", "14 Natural Gas kBtu 01/01/2024 01/01/2024 \n", "15 Natural Gas kWh 01/01/2024 01/01/2024 \n", "16 Natural Gas m3 01/01/2024 01/01/2024 \n", "17 Natural Gas - Scope 3 m3 01/01/2024 01/01/2024 \n", "18 Natural Gas MJ 01/01/2024 01/01/2024 \n", "19 Natural Gas MMBtu 01/01/2024 01/01/2024 \n", "20 Natural Gas - Scope 3 MMBtu 01/01/2024 01/01/2024 \n", "21 Natural Gas therms 01/01/2024 01/01/2024 \n", "22 Natural Gas - CO2 Only therms 01/01/2024 01/01/2024 \n", "23 Natural Gas - Scope 2 therms 01/01/2024 01/01/2024 \n", "24 Natural Gas - Scope 3 therms 01/01/2024 01/01/2024 \n", "25 Natural Gas USD 01/01/2024 01/01/2024 \n", "26 Oil and gas extraction USD 01/01/2024 01/01/2024 \n", "27 Oil and gas extraction USD 01/01/2024 01/01/2024 \n", "28 Oil and gas extraction USD 01/01/2024 01/01/2024 \n", "29 Oil and gas extraction USD 01/01/2024 01/01/2024 \n", "\n", " region factorId \n", "0 Earth 162166 \n", "1 Earth 162167 \n", "2 Earth 162168 \n", "3 Earth 162169 \n", "4 Earth 162170 \n", "5 Earth 162171 \n", "6 Earth 162923 \n", "7 Earth 162924 \n", "8 Earth 162925 \n", "9 Earth 162926 \n", "10 Earth 169709 \n", "11 Earth 162927 \n", "12 Earth 162928 \n", "13 Earth 162929 \n", "14 Earth 162930 \n", "15 Earth 162931 \n", "16 Earth 162933 \n", "17 Earth 162934 \n", "18 Earth 162935 \n", "19 Earth 162936 \n", "20 Earth 162937 \n", "21 Earth 162938 \n", "22 Earth 162939 \n", "23 Earth 162940 \n", "24 Earth 162941 \n", "25 Earth 164378 \n", "26 Earth 162285 \n", "27 Earth 162286 \n", "28 Earth 164065 \n", "29 Earth 164131 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "if response.status_code == 200 and response.text:\n", " # Parse the JSON response\n", " response_json = response.json()\n", " \n", " # Extract the factors list\n", " factors_list = response_json.get('factors', [])\n", " \n", " # Create dataframe from factors list\n", " df_factors = pd.json_normalize(factors_list)\n", " \n", " # Display settings and results\n", " print(f\"\\nFound {len(factors_list)} matching factors\\n\")\n", " pd.set_option('display.max_colwidth', None)\n", " display_summary(df_factors)\n", "else:\n", " print(f\"Error: {response.status_code}\")\n", " print(f\"Response: {response.text}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Output Description" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "transactionId - An Emissions API transaction id.\n", "\n", "totalCO2e - The total emissions as CO2 equivalent (CO2e)\n", "\n", "CO2 - The amount of CO2 (Carbon Dioxide) in the CO2e value.\n", "\n", "CH4 - The amount of CH4 (Methane) in the CO2e value.\n", "\n", "N2O - The amount of N2O (Nitrous Oxide) in the CO2e value.\n", "\n", "HFC - The amount of HFCs (Hydrofluorocarbons) in the CO2e value.\n", "\n", "PFC - The amount of PFCs (Perfluorocarbons) in the CO2e value.\n", "\n", "SF6 - The amount of SF6 (Sulphur Hexafluoride) in the CO2e value.\n", "\n", "NF3 - The amount of NF3 (Nitrogen Trifluoride) in the CO2e value.\n", "\n", "bioCo2 - The amount of bio CO2 in the CO2 value.\n", "\n", "indirectCo2e - The amount of CO2e that is indirect in the CO2e value.\n", "\n", "unit - The unit of measure of the values.\n", "\n", "description - A description of the source factor set of the factor used in the calculation." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Related Links" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[GHG Emissions API Developer Guide](https://developer.ibm.com/apis/catalog/envintelsuite--ibm-environmental-intelligence/GHG+Emissions+API)" ] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.1" } }, "nbformat": 4, "nbformat_minor": 4 }