Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.

Calculating kWh from Tesla API for a drive


New Member
Nov 1, 2020
Hello all, new member here. I’ve searched a bunch so forgive me if it has already been answered.

Basically, I’m trying to calculate kWh used from the Tesla API while driving. I think I see how to calculate kWh while charging (there’s energy added, there’s current, phases, and voltage) but the only “state” information while driving is battery level and estimated range in all it’s variations. To base it off of battery level % you have to assume a top end energy available (ie ~72kWh for 75) which seems highly inaccurate and/or uncertain. To use estimated range you have to assume a nominal energy rate (ie 333 Wh/mi) this doesn’t seem particularly accurate either.

I don’t want to assume energy used based upon energy added because that would presume you are always adding to the same point and sometimes I stop early or might change the stop point, and this seems like really low quality data.

I’m not looking to create an app or anything I’m just writing my own software for my own purposes. Yes, I know there’s TeslaFi et al but how do they calculate it?

Thanks for any assistance.

Products we're discussing on TMC...

About Us

Formed in 2006, Tesla Motors Club (TMC) was the first independent online Tesla community. Today it remains the largest and most dynamic community of Tesla enthusiasts. Learn more.

Do you value your experience at TMC? Consider becoming a Supporting Member of Tesla Motors Club. As a thank you for your contribution, you'll get nearly no ads in the Community and Groups sections. Additional perks are available depending on the level of contribution. Please visit the Account Upgrades page for more details.