ikeros / fortumapi Goto Github PK
View Code? Open in Web Editor NEWAPI to get data from Fortum Valpas service
API to get data from Fortum Valpas service
Hi,
I was looking into how to get my current consumption and found your library. I noticed that web.fortum.fi uses a bit different API to retrieve data. For example for consumption it uses https://web.fortum.fi/api/consumption?customerId={customer-id}&resolution=day&from=2019-11-01&to=2019-11-30&meteringPointNo={metering-point-no}&isDirectHeat=false endpoint and response looks like this:
{
"error": false,
"unit": "kWh",
"consumption": [
{
"fromTime": "2019-11-01 00:00",
"value": 3.24
},
{
"fromTime": "2019-11-02 00:00",
"value": 3.63
},
{
"fromTime": "2019-11-03 00:00",
"value": 4.91
},
{
"fromTime": "2019-11-04 00:00",
"value": 3.45
},
{
"fromTime": "2019-11-05 00:00",
"value": 3.74
},
{
"fromTime": "2019-11-06 00:00",
"value": 4.72
},
{
"fromTime": "2019-11-07 00:00",
"value": 6.85
},
{
"fromTime": "2019-11-08 00:00",
"value": 2.73
},
{
"fromTime": "2019-11-09 00:00",
"value": 2.31
},
{
"fromTime": "2019-11-10 00:00",
"value": 6.37
},
{
"fromTime": "2019-11-11 00:00",
"value": 3.58
},
{
"fromTime": "2019-11-12 00:00",
"value": 6.23
},
{
"fromTime": "2019-11-13 00:00",
"value": 3.38
},
{
"fromTime": "2019-11-14 00:00",
"value": 7.58
},
{
"fromTime": "2019-11-15 00:00",
"value": 3.66
},
{
"fromTime": "2019-11-16 00:00",
"value": 2.61
},
{
"fromTime": "2019-11-17 00:00",
"value": 6.87
},
{
"fromTime": "2019-11-18 00:00",
"value": 3.7
},
{
"fromTime": "2019-11-19 00:00",
"value": 3
},
{
"fromTime": "2019-11-20 00:00",
"value": 4.18
},
{
"fromTime": "2019-11-21 00:00",
"value": 4.98
},
{
"fromTime": "2019-11-22 00:00",
"value": 3.56
},
{
"fromTime": "2019-11-23 00:00",
"value": 3.03
},
{
"fromTime": "2019-11-24 00:00",
"value": 0
},
{
"fromTime": "2019-11-25 00:00",
"value": 0
},
{
"fromTime": "2019-11-26 00:00",
"value": 0
},
{
"fromTime": "2019-11-27 00:00",
"value": 0
},
{
"fromTime": "2019-11-28 00:00",
"value": 0
},
{
"fromTime": "2019-11-29 00:00",
"value": 0
},
{
"fromTime": "2019-11-30 00:00",
"value": 0
}
],
"totalConsumption": 98.31000000000002,
"avgDailyConsumption": 4.274347826086958
}
Do you know if there's any difference from the Fortum Valpas API that you use? The requests and response from consumption API seem much more simple than when using Valpas API.
Hi,
Thanks for making this.
I tried installing and running, but get the following error.
fortum.getConsumption('my details', moment().startOf('day').subtract(1, 'days'), moment().endOf('day').subtract(1, 'days'), (err, json) => {
^
ReferenceError: moment is not defined
at fortum.login (/fortumAPI-master/main.js:8:12)
at Request.request.get [as _callback] (/fortumAPI-master/fortum.api.js:188:8)
at Request.self.callback (/fortumAPI-master/node_modules/request/request.js:185:22)
at emitTwo (events.js:126:13)
at Request.emit (events.js:214:7)
at Request. (/fortumAPI-master/node_modules/request/request.js:1161:10)
at emitOne (events.js:116:13)
at Request.emit (events.js:211:7)
at IncomingMessage. (/fortumAPI-master/node_modules/request/request.js:1083:12)
at Object.onceWrapper (events.js:313:30)
Any suggestions very much appreciated
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.