remoshock > Development > REST API

REST API

/remoshock/command

This REST service performances an action ("BEEP", "VIBRATE", "SHOCK", "BEEPSHOCK") for the specified duration with the specified power level.

Curl example

curl -X POST \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer $authenticationToken' \
  -d '{"receiver": 1, "action": "BEEP", "power": 5, "duration": 500}' \
  http://localhost:7777/remoshock/command

Replace $authenticationToken with the value from .config/remoshock.ini

JavaScript example

async function command(authenticationToken, receiverNo, action,
                       powerInPercent, durationInMs) {

	let url = "/remoshock/command"
	let command = {
		"receiver": receiverNo,
		"action": action,
		"power": powerInPercent,
		"duration": durationInMs
	}
	return await fetch(url, {
		method: "POST",
		headers: {
			"Authorization": "Bearer " + authenticationToken,
			"Content-Type": "application/json"
		},
		body: JSON.stringify(data)
	});
}

command(authenticationToken, 1, "BEEP", 5, 500);

/remoshock/config

This REST service will provide configuration and receiver information. For example:
{
   "applications": {
      "randomizer": {
         "beep_probability_percent": "100",
         "shock_probability_percent": "100",
         "shock_min_duration_ms": "250",
         "shock_max_duration_ms": "250",
         "shock_min_power_percent": "5",
         "shock_max_power_percent": "10",
         "pause_min_s": "300",
         "pause_max_s": "900",
         "start_delay_min_minutes": "0",
         "start_delay_max_minutes": "0",
         "runtime_min_minutes": "1440",
         "runtime_max_minutes": "1440"
      }
   },
   "receivers": [
      {
         "receiver_type": "PAC",
         "name": "PAC1",
         "color": "#FFD",
         "action_light": false,
         "action_beep": true,
         "action_vibrate": false,
         "action_shock": true,
         "duration_min_ms": 250,
         "duration_increment_ms": 250,
         "awake_time_s": 0
      },
      {
         "receiver_type": "wodondog",
         "name": "Wodondog1",
         "color": "#DDF",
         "action_light": true,
         "action_beep": true,
         "action_vibrate": true,
         "action_shock": true,
         "duration_min_ms": 500,
         "duration_increment_ms": 500,
         "awake_time_s": 300
      },
   ]
}