Commands

You can interact with a vehicle to produce an effect on it through an API call.

Each vehicle supports different commands.


🚧

Warning

Interactions with a vehicle may take some time.
For this reason, we have a timeout of 45 seconds on the requests handled by our system.
We suggest you set a timeout equal to or greater than 50 seconds.


Generic commands

2hire defines three generic commands on every compatible vehicle.

We choose these three commands to compose our generic set because we consider them essential to interact with a vehicle.

We abstract the idea of command taken from various use cases to obtain a single behaviour on all the compatible vehicles, regardless of the specific implementation on the vehicle.


Execute a generic command

POST
/api/v1/vehicle/:uuid/command/generic/:command
Requires authorization

Request

The url parameters should consist of the following:

ParameterTypeDescription
uuidstringThe UUID of the vehicle where the command should be executed.
commandstringIdentifier of the command to be executed.

Successful Response

The successful response will consist of the following:

ParameterTypeDescription
successbooleanThe result of the execution of the command. Returns true if the command was correctly executed by the vehicle, false otherwise.
{
  "success": true
}

Error Response

The error responses are detailed in the Errors guide.


  • Start

Regardless of the use case, you'll be able to access a vehicle to drive it.

e.g.

​- Moped sharing: open topcase + engine on

​- Scooter sharing: disable lock + engine on

​- Car sharing: disable immobilizer + door unlock

POST
/api/v1/vehicle/:uuid/command/generic/start


  • Stop

Regardless of the use case, you'll be able to release a vehicle to finish driving it.

e.g.

​- Moped sharing: engine off + close topcase

​- Scooter sharing: engine off + disable lock

​- Car sharing: door lock + enable immobilizer

POST
/api/v1/vehicle/:uuid/command/generic/stop


  • Locate

Regardless of the use case, you'll be able to identify a vehicle among others.

e.g. Scooter: beep

POST
/api/v1/vehicle/:uuid/command/generic/locate


Specific commands

A set of specific commands based on a vehicle's configuration.

You'll need 2hire support to use them.

e.g. Car: open trunk


Execute a specific command

POST
/api/v1/vehicle/:uuid/command/specific/:command
Requires authorization

Request

The url parameters should consist of the following:

ParameterTypeDescription
uuidstringThe UUID of the vehicle where the command should be executed.
commandstringIdentifier of the command to be executed.

Successful Response

The successful response will consist of the following:

ParameterTypeDescription
successbooleanThe result of the execution of the command. Returns true if the command was correctly executed by the vehicle, false otherwise.
{
  "success": true
}

Error Response

The error responses are detailed in the Errors guide.


📘

Info

If you want to test the contents of this guide, please refer to our testing environment.


Did this page help you?