timdorr / tesla-api

🚘 A Ruby gem and unofficial documentation of Tesla's JSON API for the Model S, 3, X, and Y.
https://tesla-api.timdorr.com/
MIT License
2k stars 534 forks source link

vehicle_id versus id #32

Closed benhannel closed 6 years ago

benhannel commented 8 years ago

In the apiary documentation, almost all the methods require a "vehicle_id" parameter, however it actually seems this must be the value labeled "id" in the list of all vehicles.

timdorr commented 8 years ago

Could you submit a PR with changes?

Vortec4800 commented 8 years ago

In the vehicles list API there is a vehicle_id param and an id/id_s param and they are different values. Does anyone know what the difference is?

timdorr commented 8 years ago

The vehicle_id is a GUID of some sort for the vehicle. There are a few different APIs (info/command JSON API, the streaming telematics, the autopark system), so it's used as a unique identifier for the vehicle everywhere. It may come from some internal ERP system.

The id is because the JSON API runs on a Rails application. Rails' ORM (ActiveRecord) always adds an auto-incrementing id field to every model. It also makes it easy to look up a model by this id (Vehicle.find(params[:id])), so it's passed around as a convenience.

When you need to hop systems, the vehicle_id is used. When you are sticking to just the JSON API, then you can use id.

Vortec4800 commented 8 years ago

Great info. Thanks!

rstegg commented 8 years ago

I agree there are a few starved areas that could be improved in the api. I have not written any down yet, but from what I remember:

I'll open an issue for these

timdorr commented 6 years ago

Finally added a blurb on this! https://tesla-api.timdorr.com/api-basics/vehicles

I'm cleaning up the other usages as I go too.