Re:Unofficial documentation of the Tesla Model S REST API
by sopooneo on Wednesday February 20, 2013 @01:04PM
(#5252049)
Thank you. That is very helpful. But what about if it was necessary to have one command that changed the state of more than one resource?
And as you say, since certain aspects of the API (like honk horn) are unfit for REST, does it make sense to have the other parts of the API in REST? And then you've have two API's at once?
Re:Unofficial documentation of the Tesla Model S REST API
by bct on Wednesday February 20, 2013 @01:55PM
(#5252434)
> But what about if it was necessary to have one command that changed the state of more than one resource?
Then you need to have another resource that encompasses the aspects that need to be changed. Sometimes resources have to be somewhat abstract.
> since certain aspects of the API (like honk horn) are unfit for REST, does it make sense to have the other parts of the API in REST?
If the application benefits from the constraints that REST provides then why wouldn't it make sense? It's still one API, "honk" and "flash" don't need to be walled off from the other elements of the API in any way.
You would GET the lock to see if it's locked, GET the battery to read its charging state.
You could PUT to the battery (or to some more abstract, finer-grained resources) to set the charge mode and turn charging on and off. The HVAC and thermostat would work the same way.
The only tricky stuff is "flash lights" and "honk horn"; they're inherently commands, so you might as well implement them in the RPC style that Tesla has used. They can't benefit from anything REST has to offer anyways.