emissions-api-sdk 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -2
- package/dist/Constants.js +23 -1
- package/dist/api/Calculation.js +77 -14
- package/dist/api/Factor.js +97 -16
- package/dist/api/Fugitive.js +75 -12
- package/dist/api/Location.js +75 -14
- package/dist/api/Mobile.js +66 -0
- package/dist/api/Stationary.js +77 -14
- package/dist/api/TransportationAndDistribution.js +75 -12
- package/dist/types/Constants.d.ts +22 -0
- package/dist/types/api/Calculation.d.ts +52 -14
- package/dist/types/api/Factor.d.ts +64 -16
- package/dist/types/api/Fugitive.d.ts +50 -12
- package/dist/types/api/Location.d.ts +50 -14
- package/dist/types/api/Mobile.d.ts +41 -0
- package/dist/types/api/Stationary.d.ts +52 -14
- package/dist/types/api/TransportationAndDistribution.d.ts +50 -12
- package/docs/.nojekyll +0 -0
- package/docs/_sources/authentication.rst.txt +164 -0
- package/docs/_sources/client.rst.txt +137 -0
- package/docs/_sources/getting_started.rst.txt +164 -0
- package/docs/_sources/index.rst.txt +29 -0
- package/docs/_sources/reference.rst.txt +129 -0
- package/docs/_sources/sdk.rst.txt +13 -0
- package/docs/_static/basic.css +906 -0
- package/docs/_static/custom.css +16 -0
- package/docs/_static/debug.css +69 -0
- package/docs/_static/doctools.js +149 -0
- package/docs/_static/documentation_options.js +13 -0
- package/docs/_static/file.png +0 -0
- package/docs/_static/language_data.js +192 -0
- package/docs/_static/minus.png +0 -0
- package/docs/_static/plus.png +0 -0
- package/docs/_static/pygments.css +250 -0
- package/docs/_static/scripts/furo-extensions.js +0 -0
- package/docs/_static/scripts/furo.js +3 -0
- package/docs/_static/scripts/furo.js.LICENSE.txt +7 -0
- package/docs/_static/scripts/furo.js.map +1 -0
- package/docs/_static/searchtools.js +635 -0
- package/docs/_static/skeleton.css +296 -0
- package/docs/_static/sphinx_highlight.js +154 -0
- package/docs/_static/sphinx_js.css +0 -0
- package/docs/_static/styles/furo-extensions.css +2 -0
- package/docs/_static/styles/furo-extensions.css.map +1 -0
- package/docs/_static/styles/furo.css +2 -0
- package/docs/_static/styles/furo.css.map +1 -0
- package/docs/authentication.html +513 -0
- package/docs/client.html +467 -0
- package/docs/genindex.html +482 -0
- package/docs/getting_started.html +481 -0
- package/docs/index.html +334 -0
- package/docs/objects.inv +0 -0
- package/docs/reference.html +1568 -0
- package/docs/sdk.html +324 -0
- package/docs/search.html +287 -0
- package/docs/searchindex.js +1 -0
- package/package.json +1 -1
- package/sphinx-build/Makefile +49 -0
- package/sphinx-build/source/_static/custom.css +16 -0
- package/sphinx-build/source/authentication.rst +164 -0
- package/sphinx-build/source/client.rst +137 -0
- package/sphinx-build/source/conf.py +56 -0
- package/sphinx-build/source/getting_started.rst +164 -0
- package/sphinx-build/source/index.rst +29 -0
- package/sphinx-build/source/reference.rst +129 -0
- package/sphinx-build/source/sdk.rst +13 -0
- package/src/Constants.ts +26 -0
- package/src/api/Calculation.ts +84 -15
- package/src/api/Factor.ts +108 -19
- package/src/api/Fugitive.ts +83 -13
- package/src/api/Location.ts +84 -15
- package/src/api/Mobile.ts +75 -1
- package/src/api/Stationary.ts +85 -15
- package/src/api/TransportationAndDistribution.ts +84 -13
- package/test/apiTest.test.ts +172 -5
- package/dist/api/Factors.js +0 -98
- package/dist/api/FugitiveEmission.js +0 -40
- package/dist/api/GenericCalculation.js +0 -41
- package/dist/api/LocationEmission.js +0 -41
- package/dist/api/MobileEmission.js +0 -41
- package/dist/api/StationaryEmission.js +0 -41
- package/dist/api/TransportationDistributionEmission.js +0 -40
- package/dist/coverage/clover.xml +0 -225
- package/dist/coverage/coverage-final.json +0 -19
- package/dist/coverage/lcov-report/base.css +0 -224
- package/dist/coverage/lcov-report/block-navigation.js +0 -87
- package/dist/coverage/lcov-report/favicon.png +0 -0
- package/dist/coverage/lcov-report/index.html +0 -161
- package/dist/coverage/lcov-report/prettify.css +0 -1
- package/dist/coverage/lcov-report/prettify.js +0 -2
- package/dist/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/dist/coverage/lcov-report/sorter.js +0 -210
- package/dist/coverage/lcov-report/src/Client.ts.html +0 -838
- package/dist/coverage/lcov-report/src/Constants.ts.html +0 -130
- package/dist/coverage/lcov-report/src/api/Calculation.ts.html +0 -217
- package/dist/coverage/lcov-report/src/api/Factor.ts.html +0 -343
- package/dist/coverage/lcov-report/src/api/FactorSets.ts.html +0 -154
- package/dist/coverage/lcov-report/src/api/Factors.ts.html +0 -403
- package/dist/coverage/lcov-report/src/api/Fugitive.ts.html +0 -214
- package/dist/coverage/lcov-report/src/api/FugitiveEmission.ts.html +0 -214
- package/dist/coverage/lcov-report/src/api/GenericCalculation.ts.html +0 -217
- package/dist/coverage/lcov-report/src/api/Location.ts.html +0 -214
- package/dist/coverage/lcov-report/src/api/LocationEmission.ts.html +0 -214
- package/dist/coverage/lcov-report/src/api/Mobile.ts.html +0 -220
- package/dist/coverage/lcov-report/src/api/MobileEmission.ts.html +0 -220
- package/dist/coverage/lcov-report/src/api/Stationary.ts.html +0 -220
- package/dist/coverage/lcov-report/src/api/StationaryEmission.ts.html +0 -220
- package/dist/coverage/lcov-report/src/api/TransportationAndDistribution.ts.html +0 -211
- package/dist/coverage/lcov-report/src/api/TransportationDistributionEmission.ts.html +0 -211
- package/dist/coverage/lcov-report/src/api/index.html +0 -221
- package/dist/coverage/lcov-report/src/index.html +0 -161
- package/dist/coverage/lcov-report/src/request.ts.html +0 -235
- package/dist/coverage/lcov-report/src/utils.ts.html +0 -139
- package/dist/coverage/lcov-report/test/index.html +0 -116
- package/dist/coverage/lcov-report/test/mocks/CommonRequest.ts.html +0 -142
- package/dist/coverage/lcov-report/test/mocks/FactorRequest.ts.html +0 -133
- package/dist/coverage/lcov-report/test/mocks/GenericCalculationRequest.ts.html +0 -142
- package/dist/coverage/lcov-report/test/mocks/LocationRequest.ts.html +0 -139
- package/dist/coverage/lcov-report/test/mocks/SearchRequest.ts.html +0 -142
- package/dist/coverage/lcov-report/test/mocks/index.html +0 -176
- package/dist/coverage/lcov-report/test/testUtils.ts.html +0 -97
- package/dist/coverage/lcov.info +0 -404
- package/dist/types/api/Factors.d.ts +0 -68
- package/dist/types/api/FugitiveEmission.d.ts +0 -27
- package/dist/types/api/GenericCalculation.d.ts +0 -28
- package/dist/types/api/LocationEmission.d.ts +0 -28
- package/dist/types/api/MobileEmission.d.ts +0 -28
- package/dist/types/api/StationaryEmission.d.ts +0 -28
- package/dist/types/api/TransportationDistributionEmission.d.ts +0 -27
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Search.setIndex({"alltitles":{"API":[[4,"api"]],"API Key Authentication (Recommended)":[[0,"api-key-authentication-recommended"]],"Architecture Diagram":[[0,"architecture-diagram"]],"Authentication":[[0,null],[2,"authentication"]],"Authentication Flow":[[0,"authentication-flow"]],"Authentication Headers":[[0,"authentication-headers"]],"Authentication Integration":[[1,"authentication-integration"]],"Authentication Methods":[[0,"authentication-methods"]],"Basic Import":[[2,"basic-import"]],"Best Practices":[[1,"best-practices"]],"Client":[[1,null]],"Client Initialization":[[1,"client-initialization"]],"Client Responsibilities":[[1,"client-responsibilities"]],"Configuration Options":[[1,"configuration-options"]],"Contents:":[[3,null]],"Error Handling":[[1,"error-handling"]],"Example":[[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null],[4,null]],"Example Response":[[2,"example-response"]],"First API Call":[[2,"first-api-call"]],"Getting Started":[[2,null]],"IBM Envizi - Emissions API Node.js SDK":[[3,null]],"Installation":[[2,"installation"]],"Interfaces":[[4,"interfaces"]],"Introduction":[[3,"introduction"]],"Metadata APIs":[[4,"metadata-apis"]],"Overview":[[0,"overview"],[1,"overview"]],"Pre-generated Token Authentication":[[0,"pre-generated-token-authentication"]],"Prerequisites":[[2,"prerequisites"]],"Reference":[[4,null]],"SDK":[[5,null]],"Security Best Practices":[[0,"security-best-practices"]],"Supported Emission Types":[[3,"supported-emission-types"]],"Token lifetime & refresh":[[0,"token-lifetime-refresh"]],"Token retrieval":[[0,"token-retrieval"]],"Using API Key (Recommended)":[[2,"using-api-key-recommended"]],"Using Pre-generated Token":[[2,"using-pre-generated-token"]],"getArea":[[4,"getarea"]],"getTypes":[[4,"gettypes"]],"getUnits":[[4,"getunits"]]},"docnames":["authentication","client","getting_started","index","reference","sdk"],"envversion":{"sphinx":65,"sphinx.domains.c":3,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":9,"sphinx.domains.index":1,"sphinx.domains.javascript":3,"sphinx.domains.math":2,"sphinx.domains.python":4,"sphinx.domains.rst":2,"sphinx.domains.std":2,"sphinx.ext.viewcode":1},"filenames":["authentication.rst","client.rst","getting_started.rst","index.rst","reference.rst","sdk.rst"],"indexentries":{"api.commonrequestwithfactorid() (interface)":[[4,"Api.CommonRequestWithFactorId",false]],"api.commonrequestwithoutfactorid() (interface)":[[4,"Api.CommonRequestWithoutFactorId",false]],"api.factorrequestwithfactorid() (interface)":[[4,"Api.FactorRequestWithFactorId",false]],"api.factorrequestwithoutfactorid() (interface)":[[4,"Api.FactorRequestWithoutFactorId",false]],"api.genericcalculationrequestwithfactorid() (interface)":[[4,"Api.GenericCalculationRequestWithFactorId",false]],"api.genericcalculationrequestwithoutfactorid() (interface)":[[4,"Api.GenericCalculationRequestWithoutFactorId",false]],"api.locationrequestwithfactorid() (interface)":[[4,"Api.LocationRequestWithFactorId",false]],"api.locationrequestwithoutfactorid() (interface)":[[4,"Api.LocationRequestWithoutFactorId",false]],"api.searchrequest() (interface)":[[4,"Api.SearchRequest",false]],"calculation.calculate() (calculation method)":[[4,"Calculation.calculate",false]],"calculation.getarea() (calculation method)":[[4,"Calculation.getArea",false]],"calculation.gettypes() (calculation method)":[[4,"Calculation.getTypes",false]],"calculation.getunits() (calculation method)":[[4,"Calculation.getUnits",false]],"client() (class)":[[4,"Client",false]],"client.getauthheader() (client method)":[[4,"Client.getAuthHeader",false]],"client.getclient() (client method)":[[4,"Client.getClient",false]],"client.getclientid() (client method)":[[4,"Client.getClientId",false]],"client.getclientsource() (client method)":[[4,"Client.getClientSource",false]],"client.getdomain() (client method)":[[4,"Client.getDomain",false]],"client.getinstance() (client method)":[[4,"Client.getInstance",false]],"client.refreshtoken() (client method)":[[4,"Client.refreshToken",false]],"common.activity() (interface)":[[4,"common.Activity",false]],"common.activitywithfactorid() (interface)":[[4,"common.ActivityWithFactorId",false]],"common.combinedunitsactivity() (interface)":[[4,"common.CombinedUnitsActivity",false]],"common.combinedunitsactivitywithfactorid() (interface)":[[4,"common.CombinedUnitsActivityWithFactorId",false]],"common.factoractivity() (interface)":[[4,"common.FactorActivity",false]],"common.factoractivitywithfactorid() (interface)":[[4,"common.FactorActivityWithFactorId",false]],"common.location() (interface)":[[4,"common.Location",false]],"common.pagination() (interface)":[[4,"common.Pagination",false]],"common.searchactivity() (interface)":[[4,"common.SearchActivity",false]],"common.time() (interface)":[[4,"common.Time",false]],"config.clientconfig() (interface)":[[4,"Config.ClientConfig",false]],"config.requestconfig() (interface)":[[4,"Config.RequestConfig",false]],"factor.getarea() (factor method)":[[4,"Factor.getArea",false]],"factor.getsearcharea() (factor method)":[[4,"Factor.getSearchArea",false]],"factor.gettypes() (factor method)":[[4,"Factor.getTypes",false]],"factor.getunits() (factor method)":[[4,"Factor.getUnits",false]],"factor.retrievefactor() (factor method)":[[4,"Factor.retrieveFactor",false]],"fugitive.calculate() (fugitive method)":[[4,"Fugitive.calculate",false]],"fugitive.getarea() (fugitive method)":[[4,"Fugitive.getArea",false]],"fugitive.gettypes() (fugitive method)":[[4,"Fugitive.getTypes",false]],"fugitive.getunits() (fugitive method)":[[4,"Fugitive.getUnits",false]],"location.calculate() (location method)":[[4,"Location.calculate",false]],"location.getarea() (location method)":[[4,"Location.getArea",false]],"location.gettypes() (location method)":[[4,"Location.getTypes",false]],"location.getunits() (location method)":[[4,"Location.getUnits",false]],"mobile.calculate() (mobile method)":[[4,"Mobile.calculate",false]],"mobile.getarea() (mobile method)":[[4,"Mobile.getArea",false]],"mobile.gettypes() (mobile method)":[[4,"Mobile.getTypes",false]],"mobile.getunits() (mobile method)":[[4,"Mobile.getUnits",false]],"request.makeapirequest() (request method)":[[4,"request.makeApiRequest",false]],"stationary.calculate() (stationary method)":[[4,"Stationary.calculate",false]],"stationary.getarea() (stationary method)":[[4,"Stationary.getArea",false]],"stationary.gettypes() (stationary method)":[[4,"Stationary.getTypes",false]],"stationary.getunits() (stationary method)":[[4,"Stationary.getUnits",false]],"transportationanddistribution.calculate() (transportationanddistribution method)":[[4,"TransportationAndDistribution.calculate",false]],"transportationanddistribution.getarea() (transportationanddistribution method)":[[4,"TransportationAndDistribution.getArea",false]],"transportationanddistribution.gettypes() (transportationanddistribution method)":[[4,"TransportationAndDistribution.getTypes",false]],"transportationanddistribution.getunits() (transportationanddistribution method)":[[4,"TransportationAndDistribution.getUnits",false]],"utils.findexpirytime() (utils method)":[[4,"utils.findExpiryTime",false]]},"objects":{"":[[4,2,1,"","Client"]],"Api":[[4,0,1,"","CommonRequestWithFactorId"],[4,0,1,"","CommonRequestWithoutFactorId"],[4,0,1,"","FactorRequestWithFactorId"],[4,0,1,"","FactorRequestWithoutFactorId"],[4,0,1,"","GenericCalculationRequestWithFactorId"],[4,0,1,"","GenericCalculationRequestWithoutFactorId"],[4,0,1,"","LocationRequestWithFactorId"],[4,0,1,"","LocationRequestWithoutFactorId"],[4,0,1,"","SearchRequest"]],"Calculation":[[4,1,1,"","calculate"],[4,1,1,"","getArea"],[4,1,1,"","getTypes"],[4,1,1,"","getUnits"]],"Client":[[4,1,1,"","getAuthHeader"],[4,1,1,"","getClient"],[4,1,1,"","getClientId"],[4,1,1,"","getClientSource"],[4,1,1,"","getDomain"],[4,1,1,"","getInstance"],[4,1,1,"","refreshToken"]],"Config":[[4,0,1,"","ClientConfig"],[4,0,1,"","RequestConfig"]],"Factor":[[4,1,1,"","getArea"],[4,1,1,"","getSearchArea"],[4,1,1,"","getTypes"],[4,1,1,"","getUnits"],[4,1,1,"","retrieveFactor"]],"Fugitive":[[4,1,1,"","calculate"],[4,1,1,"","getArea"],[4,1,1,"","getTypes"],[4,1,1,"","getUnits"]],"Location":[[4,1,1,"","calculate"],[4,1,1,"","getArea"],[4,1,1,"","getTypes"],[4,1,1,"","getUnits"]],"Mobile":[[4,1,1,"","calculate"],[4,1,1,"","getArea"],[4,1,1,"","getTypes"],[4,1,1,"","getUnits"]],"Stationary":[[4,1,1,"","calculate"],[4,1,1,"","getArea"],[4,1,1,"","getTypes"],[4,1,1,"","getUnits"]],"TransportationAndDistribution":[[4,1,1,"","calculate"],[4,1,1,"","getArea"],[4,1,1,"","getTypes"],[4,1,1,"","getUnits"]],"common":[[4,0,1,"","Activity"],[4,0,1,"","ActivityWithFactorId"],[4,0,1,"","CombinedUnitsActivity"],[4,0,1,"","CombinedUnitsActivityWithFactorId"],[4,0,1,"","FactorActivity"],[4,0,1,"","FactorActivityWithFactorId"],[4,0,1,"","Location"],[4,0,1,"","Pagination"],[4,0,1,"","SearchActivity"],[4,0,1,"","Time"]],"request":[[4,1,1,"","makeApiRequest"]],"utils":[[4,1,1,"","findExpiryTime"]]},"objnames":{"0":["js","interface","JavaScript interface"],"1":["js","function","JavaScript function"],"2":["js","class","JavaScript class"]},"objtypes":{"0":"js:interface","1":"js:function","2":"js:class"},"terms":{"":[0,2,4],"0":[0,2,4],"00033022":2,"00036061":2,"01":4,"01115131":2,"02ae":2,"04":4,"1":[2,4],"1000":4,"121":4,"1223123":4,"123":4,"12345":4,"14123143":4,"150":4,"1500000":4,"2":[0,4],"2022":[2,4],"2025":4,"20681091":2,"20750174":2,"263fb":4,"3":4,"426a":4,"47a3":2,"60":4,"831bfca7cecd":2,"95a7efe7":2,"9999":4,"A":[0,4],"For":[0,1],"If":[0,2],"In":0,"It":1,"No":1,"OR":[1,4],"Or":2,"The":[0,1,2,3,4,5],"Then":4,"a7fd":2,"aaa":4,"about":[0,1,4],"accept":[0,1,2],"access":[0,1,4],"across":1,"activ":[2,3,4],"activitywithfactorid":4,"add":[0,1],"after":2,"all":[1,4],"alreadi":[2,4],"an":[2,4],"ani":4,"api":[1,5],"apidomain":4,"apikei":[0,1,2,4],"applic":[0,1,2,3,4],"approach":[0,5],"appropri":[1,4],"ar":2,"architectur":5,"area":[2,4],"argument":4,"async":[2,4],"auth":4,"authent":[3,4,5],"author":[0,4],"authurl":[0,1,4],"autom":3,"automat":[0,1],"avail":[2,4],"await":[0,1,2,4],"axio":0,"b20":4,"base":[2,4],"bearer":[0,4],"befor":[0,1,2,4],"best":5,"boolean":4,"build":3,"bulk":4,"busi":4,"cach":0,"calcul":[2,3,4],"calculateemiss":2,"calculationrequest":4,"california":2,"call":[0,3],"can":[2,4],"car":4,"carbon":3,"cargo":4,"carrier":4,"catch":[1,2],"central":1,"ch4":2,"chain":3,"check":0,"class":4,"client":[0,2,3,4,5],"client123":4,"clientconfig":4,"clientid":[0,1,2,4],"climat":2,"close":1,"co2":2,"coal":4,"code":0,"com":[0,2,4],"combinedunitsact":4,"combinedunitsactivitywithfactorid":4,"combust":4,"common":4,"commonrequest":4,"commonrequestwithfactorid":4,"commonrequestwithoutfactorid":4,"complet":4,"complex":4,"compon":[1,5],"config":4,"configur":[4,5],"connect":[1,2],"consist":1,"consol":[1,2,4],"const":[2,4],"consumpt":3,"contain":4,"content":4,"control":0,"convert":4,"countri":[2,4],"cover":5,"credenti":[0,1,2],"criteria":4,"custom":[1,3,4],"dashboard":3,"data":[1,4],"databas":3,"dataset":3,"date":4,"decis":3,"decod":0,"default":[0,1,4],"deploy":0,"descript":[1,2],"design":[1,3],"detail":[0,1,4],"detect":0,"determin":4,"diagram":5,"diesel":4,"directli":2,"distribut":[3,4],"doesn":4,"domain":[0,4],"dwt":4,"e":[2,4],"each":0,"egrid":2,"either":1,"electr":[2,4],"email":4,"embed":3,"emiss":[0,1,2,4,5],"endpoint":[0,1,2,4],"energi":4,"engin":3,"ensur":[1,2,4],"entir":2,"env":[0,1],"environ":[0,1],"envizi":[0,1,5],"envizi_api_kei":[0,1],"envizi_client_id":[0,1],"envizi_org_id":[0,1],"envizisdk":2,"equip":3,"error":[2,5],"exact":4,"exampl":3,"excel":0,"exist":[1,4],"exp":0,"expect":4,"expir":[0,1,4],"expiri":[0,4],"expirytim":4,"explain":0,"export":4,"extern":0,"extract":4,"factor":[2,3,4],"factoract":4,"factoractivitywithfactorid":4,"factorid":4,"factorrequest":4,"factorrequestwithfactorid":4,"factorrequestwithoutfactorid":4,"fail":2,"failur":1,"fals":4,"fetch":1,"find":4,"findexpirytim":[3,4],"first":[3,4],"fix":3,"flow":5,"follow":[0,1,2],"footprint":3,"format":[0,2],"freight":4,"fresh":[0,4],"from":[0,1,2,3,4],"fuel":[3,4],"fugit":[3,4],"fugitv":4,"function":2,"futur":0,"g":4,"ga":[3,4],"gener":[1,3,4],"genericcalculationrequestwithfactorid":4,"genericcalculationrequestwithoutfactorid":4,"geograph":4,"get":[0,3,4],"getauthhead":4,"getclient":[0,1,2,4],"getclientid":4,"getclientsourc":4,"getdomain":4,"getinst":4,"getsearcharea":4,"ghg":3,"ghgemiss":0,"give":4,"gracefulli":1,"greas":4,"greenhous":3,"handl":[0,5],"hardcod":0,"have":[2,4],"header":[1,2,4,5],"here":2,"hfc":4,"host":[0,1,4],"http":[0,1,2,4],"hybrid":4,"i":[0,1,3,4],"ibm":[0,1,2,5],"ibmid":2,"id":[0,1,2,4],"identifi":[0,4],"implement":[0,1],"import":[0,1],"includ":[0,4],"includedetail":4,"indirectco2":2,"inform":[0,1,4],"init":0,"initi":[0,2,4,5],"instal":3,"instanc":[1,4],"instead":4,"integr":5,"interact":5,"interfac":[1,3],"internet":2,"involv":4,"isuserprovidedtoken":4,"j":[0,1,2,5],"jet":4,"json":[0,2,4],"jwt":[0,4],"jwt_token":0,"jwttoken":4,"kei":[1,4,5],"kerosen":4,"kg":4,"kgco2e":2,"kj":4,"km":4,"known":4,"kwh":[2,4],"l":4,"larg":[3,4],"layer":0,"leader":2,"leak":3,"least":0,"let":1,"lignit":4,"locat":[2,3,4],"locationemiss":2,"locationrequest":4,"locationrequestwithfactorid":4,"locationrequestwithoutfactorid":4,"log":[2,4],"logist":3,"look":4,"mai":4,"maintain":1,"make":[2,3,4],"makeapirequest":[0,3,4],"manag":[0,1,2,3],"measur":4,"messag":1,"metadata":3,"method":[1,2,4,5],"metric":4,"mobil":[3,4],"mode":0,"modul":[1,2],"more":0,"multipl":4,"n2o":2,"name":4,"natur":4,"nc":4,"ne":4,"necessari":0,"need":[0,4],"never":0,"new":[0,4],"node":[0,1,2,5],"npm":2,"oauth":0,"object":4,"obtain":[1,2],"occur":0,"old":0,"onc":[0,1],"one":[0,1],"onli":[0,1,4],"oper":[1,3,4],"optim":1,"option":[0,4,5],"org":2,"org456":4,"organ":[0,1],"orgid":[0,1,2,4],"other":4,"overview":[2,5],"page":[0,1,2],"pagin":4,"param":[0,4],"paramet":[0,1,4],"pars":4,"pattern":5,"payload":4,"perform":4,"petroleum":4,"point":4,"post":4,"practic":5,"pre":1,"prerequisit":3,"preview":2,"principl":0,"privileg":0,"proce":4,"process":[0,1],"product":[0,1],"project":[2,3],"promis":4,"proper":[0,1],"provid":[0,1,2,4,5],"purchas":4,"purpos":4,"queri":[0,4],"r":4,"r134a":4,"re":0,"record":4,"refer":3,"refresh":[1,4],"refreshtoken":4,"region":[2,3],"relat":4,"relev":4,"replac":0,"repres":4,"request":[0,1,3,4],"requestconfig":4,"requir":[0,1,2],"resolv":4,"respons":[0,3,4,5],"result":[2,4],"retriev":[2,4],"retrievefactor":4,"return":[0,2,4],"reus":1,"run":[0,2],"saascor":[0,2],"scale":3,"scenario":0,"scope":4,"sdk":[0,1,2,4],"search":4,"searchact":4,"searchrequest":4,"second":4,"section":5,"secur":[1,5],"see":[0,1],"send":0,"sent":4,"servic":[0,1],"set":2,"sever":1,"ship":4,"sign":2,"singl":4,"singleton":[0,1,4],"size":4,"small":4,"sourc":[0,3,4],"specif":[1,3,4],"specifi":4,"standard":4,"start":3,"startup":1,"state":2,"stateprovinc":[2,4],"static":4,"stationari":[3,4],"statu":1,"steel":4,"step":0,"store":[0,1],"string":[0,4],"structur":5,"subtyp":4,"successfulli":2,"suppli":3,"support":[1,4],"sustain":3,"t":4,"tenantid":2,"thi":[0,2,4,5],"time":[0,4],"timestamp":4,"toisostr":4,"token":[1,4],"totalco2":2,"track":3,"transactionid":2,"transport":[3,4],"transportationanddistribut":4,"travel":4,"trim":0,"true":4,"try":[1,2],"two":[0,2],"type":[2,4],"typesdata":4,"u":2,"unifi":1,"unit":[2,4],"unix":4,"unless":1,"up":[2,4],"url":[0,4],"us":[0,1,3,4],"usa":[2,4],"usag":[1,5],"user":[0,1,4],"userdata":4,"util":[3,4],"v":[0,1],"valid":[0,1],"valu":[2,4],"variabl":[0,1],"vehicl":3,"verifi":1,"void":4,"wa":[2,4],"waitlist":2,"wast":4,"web":4,"when":[0,4],"where":[0,4],"which":0,"within":4,"without":4,"work":1,"x":[0,2,4],"yarn":2,"ye":1,"year":2,"york":4,"you":[0,2],"your":[0,1,2,3,4]},"titles":["Authentication","Client","Getting Started","IBM Envizi - Emissions API Node.js SDK","Reference","SDK"],"titleterms":{"api":[0,2,3,4],"architectur":0,"authent":[0,1,2],"basic":2,"best":[0,1],"call":2,"client":1,"configur":1,"content":3,"diagram":0,"emiss":3,"envizi":3,"error":1,"exampl":[2,4],"first":2,"flow":0,"gener":[0,2],"get":2,"getarea":4,"gettyp":4,"getunit":4,"handl":1,"header":0,"ibm":3,"import":2,"initi":1,"instal":2,"integr":1,"interfac":4,"introduct":3,"j":3,"kei":[0,2],"lifetim":0,"metadata":4,"method":0,"node":3,"option":1,"overview":[0,1],"practic":[0,1],"pre":[0,2],"prerequisit":2,"recommend":[0,2],"refer":4,"refresh":0,"respons":[1,2],"retriev":0,"sdk":[3,5],"secur":0,"start":2,"support":3,"token":[0,2],"type":3,"us":2}})
|
package/package.json
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Minimal makefile for Sphinx documentation
|
|
2
|
+
#
|
|
3
|
+
|
|
4
|
+
# You can set these variables from the command line, and also
|
|
5
|
+
# from the environment for the first two.
|
|
6
|
+
SPHINXOPTS ?=
|
|
7
|
+
SPHINXBUILD := sphinx-build
|
|
8
|
+
SOURCEDIR := source
|
|
9
|
+
BUILDDIR := build
|
|
10
|
+
DOCS_DIR := ../docs
|
|
11
|
+
|
|
12
|
+
# Put it first so that "make" without argument is like "make help".
|
|
13
|
+
help:
|
|
14
|
+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
15
|
+
|
|
16
|
+
.PHONY: help Makefile
|
|
17
|
+
|
|
18
|
+
# Catch-all target: route all unknown targets to Sphinx using the new
|
|
19
|
+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
|
20
|
+
%: Makefile
|
|
21
|
+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
22
|
+
|
|
23
|
+
# Clean build directory
|
|
24
|
+
.PHONY: clean
|
|
25
|
+
clean:
|
|
26
|
+
@echo "Cleaning build directory..."
|
|
27
|
+
@rm -rf $(BUILDDIR)
|
|
28
|
+
@echo "Done."
|
|
29
|
+
|
|
30
|
+
# Build HTML documentation
|
|
31
|
+
.PHONY: html
|
|
32
|
+
html:
|
|
33
|
+
@echo "Building HTML documentation..."
|
|
34
|
+
@$(SPHINXBUILD) -b html $(SOURCEDIR) $(BUILDDIR)/html
|
|
35
|
+
@echo "Done. Output is in $(BUILDDIR)/html"
|
|
36
|
+
|
|
37
|
+
# Clean and build HTML
|
|
38
|
+
.PHONY: all
|
|
39
|
+
all: clean html
|
|
40
|
+
@echo "Documentation build complete."
|
|
41
|
+
|
|
42
|
+
# Copy built HTML to docs directory for GitHub Pages
|
|
43
|
+
.PHONY: pages
|
|
44
|
+
pages: all
|
|
45
|
+
@echo "Copying documentation to docs directory..."
|
|
46
|
+
@rm -rf $(DOCS_DIR)/*
|
|
47
|
+
@mkdir -p $(DOCS_DIR)
|
|
48
|
+
@cp -r $(BUILDDIR)/html/* $(DOCS_DIR)/
|
|
49
|
+
@echo "Done. GitHub Pages content is in $(DOCS_DIR)"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
div.nbinput.container div.input_area {
|
|
2
|
+
border: 1px solid #e0e0e0;
|
|
3
|
+
border-radius: 4px;
|
|
4
|
+
background: #f8f8f8;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
div.nboutput.container div.output_area {
|
|
8
|
+
border: 1px solid #e0e0e0;
|
|
9
|
+
border-radius: 4px;
|
|
10
|
+
background: #fcfcfc;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* Make code cells more readable */
|
|
14
|
+
.highlight {
|
|
15
|
+
background: #f8f8f8;
|
|
16
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
==============
|
|
2
|
+
Authentication
|
|
3
|
+
==============
|
|
4
|
+
|
|
5
|
+
Overview
|
|
6
|
+
--------
|
|
7
|
+
|
|
8
|
+
The IBM Envizi - Emissions API Node.js SDK uses OAuth 2.0 Bearer Tokens for authentication. This page explains the authentication process, options, and security best practices in detail.
|
|
9
|
+
|
|
10
|
+
Authentication Methods
|
|
11
|
+
----------------------
|
|
12
|
+
|
|
13
|
+
The SDK provides two authentication methods:
|
|
14
|
+
|
|
15
|
+
API Key Authentication (Recommended)
|
|
16
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
17
|
+
|
|
18
|
+
This method automatically handles token generation and refreshing:
|
|
19
|
+
|
|
20
|
+
.. code-block:: javascript
|
|
21
|
+
|
|
22
|
+
import { Client } from 'emissions-api-sdk';
|
|
23
|
+
|
|
24
|
+
await Client.getClient({
|
|
25
|
+
apiKey: process.env.ENVIZI_API_KEY,
|
|
26
|
+
clientId: process.env.ENVIZI_CLIENT_ID,
|
|
27
|
+
orgId: process.env.ENVIZI_ORG_ID
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
**Required parameters:**
|
|
31
|
+
- ``apiKey``: Your API key for authentication
|
|
32
|
+
- ``clientId``: Your client identifier
|
|
33
|
+
- ``orgId``: Your organization identifier
|
|
34
|
+
|
|
35
|
+
Token retrieval
|
|
36
|
+
^^^^^^^^^^^^^^^
|
|
37
|
+
When you call ``Client.getClient()`` with ``apiKey``:
|
|
38
|
+
|
|
39
|
+
- **Method**: ``GET`` to the token endpoint (default: ``https://api.ibm.com/saascore/run/authentication-retrieve/api-key``)
|
|
40
|
+
- **Headers**:
|
|
41
|
+
- ``X-Api-Key: <apiKey>``
|
|
42
|
+
- ``X-IBM-Client-Id: saascore-<clientId>``
|
|
43
|
+
- ``Accept: application/json``
|
|
44
|
+
- **Query param**: ``orgId=<orgId>``
|
|
45
|
+
- **Response**: a bearer token (string) which the SDK trims, caches, and uses for API calls.
|
|
46
|
+
|
|
47
|
+
Pre-generated Token Authentication
|
|
48
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
49
|
+
|
|
50
|
+
For scenarios where token generation is handled externally:
|
|
51
|
+
|
|
52
|
+
.. code-block:: javascript
|
|
53
|
+
|
|
54
|
+
import { Client } from 'emissions-api-sdk';
|
|
55
|
+
|
|
56
|
+
await Client.getClient({
|
|
57
|
+
token: process.env.JWT_TOKEN,
|
|
58
|
+
clientId: process.env.ENVIZI_CLIENT_ID
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
**Required parameters:**
|
|
62
|
+
- ``token``: A pre-generated authentication token
|
|
63
|
+
- ``clientId``: Your client identifier
|
|
64
|
+
|
|
65
|
+
Token lifetime & refresh
|
|
66
|
+
^^^^^^^^^^^^^^^^^^^^^^^^
|
|
67
|
+
- The SDK decodes the JWT’s ``exp`` and stores it.
|
|
68
|
+
- In user-provided token mode, no refresh occurs; re-initialize with a fresh token when needed.
|
|
69
|
+
|
|
70
|
+
Authentication Flow
|
|
71
|
+
-------------------
|
|
72
|
+
|
|
73
|
+
The authentication process follows these steps:
|
|
74
|
+
|
|
75
|
+
1. **Initialization**:
|
|
76
|
+
- User provides authentication credentials
|
|
77
|
+
- Client validates the credentials format
|
|
78
|
+
|
|
79
|
+
2. **Token Generation** (API Key method):
|
|
80
|
+
- Client sends API key to authentication service
|
|
81
|
+
- Authentication service validates credentials
|
|
82
|
+
- Authentication service returns a token with expiration time
|
|
83
|
+
- Client stores the token securely
|
|
84
|
+
|
|
85
|
+
3. **Token Validation**:
|
|
86
|
+
- Before each API request, token validity is checked
|
|
87
|
+
- If valid, the token is included in the request
|
|
88
|
+
- If expired or near expiration, token is refreshed
|
|
89
|
+
|
|
90
|
+
4. **Token Refreshing**:
|
|
91
|
+
- Client detects when token is approaching expiration
|
|
92
|
+
- Client automatically requests a new token
|
|
93
|
+
- New token replaces the old one for future requests
|
|
94
|
+
|
|
95
|
+
Authentication Headers
|
|
96
|
+
----------------------
|
|
97
|
+
|
|
98
|
+
The SDK automatically includes the necessary headers for authentication:
|
|
99
|
+
|
|
100
|
+
For token generation:
|
|
101
|
+
- ``X-Api-Key``: Your API key
|
|
102
|
+
- ``X-IBM-Client-Id``: saascore-{your-client-id}
|
|
103
|
+
|
|
104
|
+
For API requests:
|
|
105
|
+
- ``Authorization``: Bearer {token}
|
|
106
|
+
- ``X-IBM-Client-Id``: ghgemissions-{your-client-id}
|
|
107
|
+
- ``X-Client-Source``: node-sdk
|
|
108
|
+
|
|
109
|
+
Architecture Diagram
|
|
110
|
+
--------------------
|
|
111
|
+
|
|
112
|
+
::
|
|
113
|
+
|
|
114
|
+
+-----------------+ +-------------------------+
|
|
115
|
+
| Your application| | Token Service (GET) |
|
|
116
|
+
| (init once) | | authUrl / default URL |
|
|
117
|
+
+--------+--------+ +-----------+-------------+
|
|
118
|
+
| ^
|
|
119
|
+
| getClient({apiKey, clientId, | (managed mode only:
|
|
120
|
+
| orgId, [authUrl], [host]}) | X-Api-Key, saascore-Client-Id,
|
|
121
|
+
v | orgId => returns JWT)
|
|
122
|
+
+--------+--------------------------------+-------------+
|
|
123
|
+
| Client (singleton) |
|
|
124
|
+
| - token, exp, domain, clientId |
|
|
125
|
+
| - refresh before expiry (managed mode) |
|
|
126
|
+
+--------+--------------------------------+-------------+
|
|
127
|
+
| ^
|
|
128
|
+
| makeApiRequest(...) |
|
|
129
|
+
v |
|
|
130
|
+
+--------+--------------------------------+-------------+
|
|
131
|
+
| Request layer (axios) |
|
|
132
|
+
| Adds headers: |
|
|
133
|
+
| - Authorization: Bearer <token> |
|
|
134
|
+
| - X-IBM-Client-Id: ghgemissions-<clientId> |
|
|
135
|
+
| - X-Client-Source: excel | node-sdk |
|
|
136
|
+
+--------+--------------------------------+-------------+
|
|
137
|
+
|
|
|
138
|
+
v
|
|
139
|
+
+--------+--------------------------------+-------------+
|
|
140
|
+
| Emissions API (host/domain) |
|
|
141
|
+
+-------------------------------------------------------+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
Security Best Practices
|
|
145
|
+
-----------------------
|
|
146
|
+
|
|
147
|
+
1. **Use environment variables** for credentials:
|
|
148
|
+
|
|
149
|
+
.. code-block:: javascript
|
|
150
|
+
|
|
151
|
+
await Client.getClient({
|
|
152
|
+
apiKey: process.env.ENVIZI_API_KEY,
|
|
153
|
+
clientId: process.env.ENVIZI_CLIENT_ID,
|
|
154
|
+
orgId: process.env.ENVIZI_ORG_ID
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
2. **Never hardcode** credentials in your application code
|
|
158
|
+
3. **Implement proper access controls** for API keys
|
|
159
|
+
4. **Use secure environment variables** for production deployments
|
|
160
|
+
5. **Implement least privilege** principles for API access
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
For more information about the Client that manages authentication, see the :doc:`client` page.
|
|
164
|
+
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
======
|
|
2
|
+
Client
|
|
3
|
+
======
|
|
4
|
+
|
|
5
|
+
Overview
|
|
6
|
+
--------
|
|
7
|
+
|
|
8
|
+
The Client is the central component of the IBM Envizi - Emissions API Node.js SDK. It handles authentication, maintains connections to the API, and provides a unified interface for all API operations.
|
|
9
|
+
|
|
10
|
+
.. code-block:: none
|
|
11
|
+
|
|
12
|
+
+----------------------+
|
|
13
|
+
| Application |<-----------+
|
|
14
|
+
+----------------------+ |
|
|
15
|
+
| |
|
|
16
|
+
v |
|
|
17
|
+
+----------------------+ |
|
|
18
|
+
| Client |<-----------+
|
|
19
|
+
+----------------------+ |
|
|
20
|
+
| |
|
|
21
|
+
v |
|
|
22
|
+
+----------------------+ +----------------------+
|
|
23
|
+
| Authentication |---->| API Module Requests |
|
|
24
|
+
+----------------------+ +----------------------+
|
|
25
|
+
|
|
26
|
+
Client Initialization
|
|
27
|
+
---------------------
|
|
28
|
+
|
|
29
|
+
The Client is designed as a singleton to ensure consistent authentication across your application. Initialize it once at application startup:
|
|
30
|
+
|
|
31
|
+
1. Managed token (SDK fetches & refreshes)
|
|
32
|
+
|
|
33
|
+
.. code-block:: javascript
|
|
34
|
+
|
|
35
|
+
import { Client } from 'emissions-api-sdk';
|
|
36
|
+
|
|
37
|
+
await Client.getClient({
|
|
38
|
+
apiKey: process.env.ENVIZI_API_KEY,
|
|
39
|
+
clientId: process.env.ENVIZI_CLIENT_ID,
|
|
40
|
+
orgId: process.env.ENVIZI_ORG_ID
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
2. User-provided token (SDK will **not** refresh it)
|
|
44
|
+
|
|
45
|
+
.. code-block:: javascript
|
|
46
|
+
|
|
47
|
+
import { Client } from "emissions-api-sdk";
|
|
48
|
+
|
|
49
|
+
await Client.getClient({
|
|
50
|
+
clientId: process.env.ENVIZI_CLIENT_ID,
|
|
51
|
+
token: process.env.TOKEN
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
Configuration Options
|
|
55
|
+
---------------------
|
|
56
|
+
|
|
57
|
+
The Client accepts the following configuration parameters:
|
|
58
|
+
|
|
59
|
+
.. list-table::
|
|
60
|
+
:header-rows: 1
|
|
61
|
+
:widths: 20 15 65
|
|
62
|
+
|
|
63
|
+
* - Parameter
|
|
64
|
+
- Required
|
|
65
|
+
- Description
|
|
66
|
+
* - apiKey
|
|
67
|
+
- Yes*
|
|
68
|
+
- API key for authentication (required unless using token)
|
|
69
|
+
* - clientId
|
|
70
|
+
- Yes
|
|
71
|
+
- Client ID for API access
|
|
72
|
+
* - orgId
|
|
73
|
+
- Yes*
|
|
74
|
+
- Organization ID (required with apiKey)
|
|
75
|
+
* - token
|
|
76
|
+
- Yes*
|
|
77
|
+
- Pre-generated token (required if not using apiKey)
|
|
78
|
+
* - host
|
|
79
|
+
- No
|
|
80
|
+
- Custom API endpoint (defaults to production)
|
|
81
|
+
* - authUrl
|
|
82
|
+
- No
|
|
83
|
+
- Custom authentication endpoint (defaults to production)
|
|
84
|
+
|
|
85
|
+
.. note::
|
|
86
|
+
Either ``apiKey+orgId`` OR ``token`` is required
|
|
87
|
+
|
|
88
|
+
Client Responsibilities
|
|
89
|
+
-----------------------
|
|
90
|
+
|
|
91
|
+
The Client handles several key responsibilities:
|
|
92
|
+
|
|
93
|
+
1. **Singleton Management**: Ensures only one Client instance exists
|
|
94
|
+
2. **Configuration Validation**: Verifies required parameters
|
|
95
|
+
3. **Token Generation**: Obtains tokens from the authentication service
|
|
96
|
+
4. **Token Refreshing**: Automatically refreshes tokens before expiration
|
|
97
|
+
5. **Request Authentication**: Adds proper headers to all API requests
|
|
98
|
+
|
|
99
|
+
Error Handling
|
|
100
|
+
--------------
|
|
101
|
+
|
|
102
|
+
Handle authentication errors gracefully:
|
|
103
|
+
|
|
104
|
+
.. code-block:: javascript
|
|
105
|
+
|
|
106
|
+
try {
|
|
107
|
+
await Client.getClient({
|
|
108
|
+
apiKey: process.env.ENVIZI_API_KEY,
|
|
109
|
+
clientId: process.env.ENVIZI_CLIENT_ID,
|
|
110
|
+
orgId: process.env.ENVIZI_ORG_ID
|
|
111
|
+
});
|
|
112
|
+
} catch (error) {
|
|
113
|
+
console.error("Authentication error:", error.message);
|
|
114
|
+
// Implement appropriate error handling
|
|
115
|
+
if (error.response) {
|
|
116
|
+
// Handle specific HTTP error responses
|
|
117
|
+
console.error("Status:", error.response.status);
|
|
118
|
+
console.error("Details:", error.response.data);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
Best Practices
|
|
124
|
+
--------------
|
|
125
|
+
|
|
126
|
+
For optimal Client usage:
|
|
127
|
+
|
|
128
|
+
1. **Initialize once** at application startup
|
|
129
|
+
2. **Store credentials securely** using environment variables
|
|
130
|
+
3. **Implement proper error handling** for authentication failures
|
|
131
|
+
4. **Let the SDK handle** token refreshing automatically
|
|
132
|
+
5. **Reuse the Client instance** across your application
|
|
133
|
+
|
|
134
|
+
Authentication Integration
|
|
135
|
+
--------------------------
|
|
136
|
+
|
|
137
|
+
The Client works closely with the Authentication module to manage tokens. For detailed information about the authentication process, supported methods, and security best practices, see the :doc:`authentication` page.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Configuration file for the Sphinx documentation builder.
|
|
2
|
+
#
|
|
3
|
+
# For the full list of built-in configuration values, see the documentation:
|
|
4
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
|
5
|
+
|
|
6
|
+
# -- Project information -----------------------------------------------------
|
|
7
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
|
8
|
+
|
|
9
|
+
project = 'IBM Envizi - Emissions API Node.js SDK'
|
|
10
|
+
copyright = '2025, IBM Corporation'
|
|
11
|
+
author = 'Ridham Thumar'
|
|
12
|
+
|
|
13
|
+
# -- General configuration ---------------------------------------------------
|
|
14
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
|
15
|
+
import os
|
|
16
|
+
import sys
|
|
17
|
+
sys.path.insert(0, os.path.abspath('../..'))
|
|
18
|
+
|
|
19
|
+
# Language used for content
|
|
20
|
+
language = 'en'
|
|
21
|
+
|
|
22
|
+
# Source file suffix
|
|
23
|
+
source_suffix = {
|
|
24
|
+
'.rst': 'restructuredtext',
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# The master document
|
|
28
|
+
master_doc = 'index'
|
|
29
|
+
|
|
30
|
+
extensions = [
|
|
31
|
+
'sphinx.ext.autodoc',
|
|
32
|
+
'sphinx.ext.viewcode',
|
|
33
|
+
'sphinx_js'
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
js_language = 'typescript'
|
|
37
|
+
|
|
38
|
+
js_source_path = '../../src'
|
|
39
|
+
|
|
40
|
+
primary_domain = 'js'
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
templates_path = ['_templates']
|
|
44
|
+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# -- Options for HTML output -------------------------------------------------
|
|
48
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
|
49
|
+
|
|
50
|
+
html_theme = 'furo'
|
|
51
|
+
html_static_path = ['_static']
|
|
52
|
+
|
|
53
|
+
# Add CSS to improve notebook appearance
|
|
54
|
+
html_css_files = [
|
|
55
|
+
'custom.css',
|
|
56
|
+
]
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
===============
|
|
2
|
+
Getting Started
|
|
3
|
+
===============
|
|
4
|
+
|
|
5
|
+
Prerequisites
|
|
6
|
+
-------------
|
|
7
|
+
|
|
8
|
+
Before using the SDK, ensure you have:
|
|
9
|
+
|
|
10
|
+
- **Node.js** installed
|
|
11
|
+
- Active internet connection
|
|
12
|
+
- Sign up for the preview waitlist `IBMid sign up <https://www.ibm.com/account/reg/us-en/signup?formid=urx-53659>`_ page.
|
|
13
|
+
- API credentials (``apiKey``, ``tenantId``, ``orgId``), are available on the Emissions API `Overview Page <https://www-dev.supply-chain.ibm.com/envizi/emissions-api-home/overview?cuiURL=%2Femissions-api-home%2Foverview>`_ after sign up
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
Installation
|
|
17
|
+
------------
|
|
18
|
+
|
|
19
|
+
You can install the SDK using `npm <https://www.npmjs.com/package/emissions-api-sdk>`_ or `yarn <https://yarnpkg.com/package?q=emissions-api-sdk&name=emissions-api-sdk>`_:
|
|
20
|
+
|
|
21
|
+
Using npm:
|
|
22
|
+
|
|
23
|
+
.. code-block:: bash
|
|
24
|
+
|
|
25
|
+
npm install emissions-api-sdk
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
Using yarn:
|
|
29
|
+
|
|
30
|
+
.. code-block:: bash
|
|
31
|
+
|
|
32
|
+
yarn install emissions-api-sdk
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
Basic Import
|
|
36
|
+
~~~~~~~~~~~~
|
|
37
|
+
|
|
38
|
+
After installation, you can import the SDK in your project:
|
|
39
|
+
|
|
40
|
+
.. code-block:: javascript
|
|
41
|
+
|
|
42
|
+
// Import the entire SDK
|
|
43
|
+
const enviziSDK = require('emissions-api-sdk');
|
|
44
|
+
|
|
45
|
+
// Or using ES modules
|
|
46
|
+
import { Client, LocationEmission } from 'emissions-api-sdk';
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
Authentication
|
|
50
|
+
--------------
|
|
51
|
+
|
|
52
|
+
Initialize the client with your API credentials:
|
|
53
|
+
|
|
54
|
+
The SDK provides two authentication methods:
|
|
55
|
+
|
|
56
|
+
- Using an **API key** with following required Headers:
|
|
57
|
+
- ``X-Api-Key``: Your API key
|
|
58
|
+
- ``X-IBM-Client-Id``: saascore-{your-client-id}
|
|
59
|
+
- ``accept``: application/json
|
|
60
|
+
|
|
61
|
+
- Using a **Pre-generated token**
|
|
62
|
+
- Token Generation Endpoint: https://api.ibm.com/saascore/run/authentication-retrieve/api-key
|
|
63
|
+
|
|
64
|
+
Using API Key (Recommended)
|
|
65
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
66
|
+
|
|
67
|
+
.. code-block:: javascript
|
|
68
|
+
|
|
69
|
+
import { Client } from 'emissions-api-sdk';
|
|
70
|
+
|
|
71
|
+
async function initialize() {
|
|
72
|
+
try {
|
|
73
|
+
await Client.getClient({
|
|
74
|
+
apiKey: "your-api-key",
|
|
75
|
+
clientId: "your-client-id",
|
|
76
|
+
orgId: "your-org-id"
|
|
77
|
+
});
|
|
78
|
+
console.log("Client initialized successfully");
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.error("Failed to initialize client:", error);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
initialize();
|
|
85
|
+
|
|
86
|
+
Using Pre-generated Token
|
|
87
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
88
|
+
|
|
89
|
+
If you already have a token, you can use it directly:
|
|
90
|
+
|
|
91
|
+
.. code-block:: javascript
|
|
92
|
+
|
|
93
|
+
import { Client } from 'emissions-api-sdk';
|
|
94
|
+
|
|
95
|
+
async function initialize() {
|
|
96
|
+
try {
|
|
97
|
+
await Client.getClient({
|
|
98
|
+
token: "your-pre-generated-token",
|
|
99
|
+
clientId: "your-client-id"
|
|
100
|
+
});
|
|
101
|
+
console.log("Client initialized successfully");
|
|
102
|
+
} catch (error) {
|
|
103
|
+
console.error("Failed to initialize client:", error);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
initialize();
|
|
108
|
+
|
|
109
|
+
First API Call
|
|
110
|
+
--------------
|
|
111
|
+
|
|
112
|
+
After initializing the client, you can make your first API call. Here's an example of calculating location-based emissions:
|
|
113
|
+
|
|
114
|
+
.. code-block:: javascript
|
|
115
|
+
|
|
116
|
+
import { Client, LocationEmission } from 'emissions-api-sdk';
|
|
117
|
+
|
|
118
|
+
async function calculateEmissions() {
|
|
119
|
+
try {
|
|
120
|
+
// Initialize client
|
|
121
|
+
await Client.getClient({
|
|
122
|
+
apiKey: "your-api-key",
|
|
123
|
+
clientId: "your-client-id",
|
|
124
|
+
orgId: "your-org-id"
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// Make API call
|
|
128
|
+
const result = await LocationEmission.calculate({
|
|
129
|
+
"location": {
|
|
130
|
+
"country": "USA",
|
|
131
|
+
"stateProvince": "california"
|
|
132
|
+
},
|
|
133
|
+
"activity": {
|
|
134
|
+
"type": "electricity",
|
|
135
|
+
"value": 1,
|
|
136
|
+
"unit": "kWh"
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
console.log("Emission calculation result:", result);
|
|
141
|
+
} catch (error) {
|
|
142
|
+
console.error("Error calculating emissions:", error);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
calculateEmissions();
|
|
147
|
+
|
|
148
|
+
Example Response
|
|
149
|
+
----------------
|
|
150
|
+
|
|
151
|
+
The API returns emission calculation results in JSON format. Here's an example response:
|
|
152
|
+
|
|
153
|
+
.. code-block:: json
|
|
154
|
+
|
|
155
|
+
{
|
|
156
|
+
"transactionId": "95a7efe7-02ae-47a3-a7fd-831bfca7cecd",
|
|
157
|
+
"totalCO2e": 0.20750174,
|
|
158
|
+
"CO2": 0.20681091,
|
|
159
|
+
"CH4": 0.00033022,
|
|
160
|
+
"N2O": 0.00036061,
|
|
161
|
+
"indirectCO2e": 0.01115131,
|
|
162
|
+
"unit": "kgCO2e",
|
|
163
|
+
"description": "The electricity emissions factor used to calculate this result was obtained from the year 2022 Managed - eGRID & US Climate Leaders factor set for the area United States and the region California."
|
|
164
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
IBM Envizi - Emissions API Node.js SDK
|
|
2
|
+
======================================
|
|
3
|
+
|
|
4
|
+
.. toctree::
|
|
5
|
+
:maxdepth: 2
|
|
6
|
+
:caption: Contents:
|
|
7
|
+
|
|
8
|
+
getting_started
|
|
9
|
+
sdk
|
|
10
|
+
reference
|
|
11
|
+
|
|
12
|
+
Introduction
|
|
13
|
+
============
|
|
14
|
+
|
|
15
|
+
IBM Envizi - Emissions API (Emissions API) is a managed factor database and calculation engine for embedding greenhouse gas (GHG) emissions calculations into operational decision making.
|
|
16
|
+
|
|
17
|
+
The **emissions-api-sdk** is a Node.js SDK for using Emissions API in your projects.
|
|
18
|
+
|
|
19
|
+
Supported Emission Types
|
|
20
|
+
------------------------
|
|
21
|
+
|
|
22
|
+
* **Location** – emissions from region-specific factors
|
|
23
|
+
* **Fugitive** – emissions from leaks or fugitive sources
|
|
24
|
+
* **Mobile** – emissions from vehicles and mobile equipment
|
|
25
|
+
* **Stationary** – emissions from fixed fuel consumption
|
|
26
|
+
* **Transportation & distribution** – logistics and supply chain activities
|
|
27
|
+
* **Generic** – custom emission calculations
|
|
28
|
+
|
|
29
|
+
The SDK is designed for embedding emission calculations in applications, building sustainability dashboards, automating large-scale datasets, and tracking carbon footprints.
|