# Command Service APIs

Content

* Command service's purpose
* REST APIs outline
* Reference

## Command Service's Purpose

It enables the issuance of commands or actions to devices and sensors on behalf of other microservices withing EdgeX or other applications.

It also exposes the commands in a common, normalized to simplify communications with the devices

Command service doesn't act alone

* It gets its knowledge about the devices and sensors from the Metadata service.
* it relays commands and actions to the devices and sensors through the Device service.
* It never communicates directly to a device or a sensor.

## REST API Outline

* Get all devices (and commands)
  * /api/v1/device/name/{name}
* Get Commands by&#x20;
  * Device ID: /api/v1/device/{id}
  * Device name: /api/v1/device/name/{name}
* Issue command
  * /api/v1/device/{id}/command/{command id}
  * GET & PUT&#x20;

### Some API Examples

#### Get all Devices & Commands

```
http://localhost:48082/api/v1/device
```

It retrieves a list of (all) devices and their command offerings.

#### Get commands by device

```
http://localhost:48082/api/v1/device/{id}
```

It retrieves a device (by database generated id) and its command offerings.

#### Issue command

```
http://localhost:48082/api/v1/device/{id}/command/{commandid}
```

Issue the get or put command referenced by the command id to the device/sensor (also referenced by database generated id) it is associated to via the device service.

## Reference

* Core Command APIs: <https://docs.edgexfoundry.org/Ch-APICoreCommand.html>
