Q:

Rest API design simplification

I want to do a Home controller API for different devices (air conditioning, lights, movement control, etc), so i have the next API definition, but each device has different properties and configurations, so i thought create some type endpoints.
GET /api/devices/
[{
  "deviceId": "1"
  "name": "Device 1",
}, {
  "deviceId": "2"
  "name": "Device 2",
}, {
  "deviceId": "3"
  "name": "Device 3"
}]

GET /api/device/1
{
  "deviceId": "1"
  "name": "Device 1",
}

GET /api/airconditioning/unit/1/status
{
  "deviceId": "1"
  "temperature: 22" 
  "state": 1"
}

GET /api/lighting/switch/2/status
{
  "deviceId": "2"
  "state": 1"
}

GET /api/lighting/dimmer/3/status
{
  "deviceId": "3"
  "state": 1"
  "dim": 70"
}

The examples i've seen people try to unify properties but i would like have strong defined properties for each device.
The problem is i don't know if this is correct because you have two endpoints pointing at the same resource
GET /api/device/1
GET /api/airconditioning/unit/1

A:

REST isn't going to tell you how finely grained your resources should be.
Coarsely grained resources reduce the number of round trips that you need to make - think Data Transfer Object.
Finely grained resources allow better control of caching policies.

i don't know if this is correct because you have two endpoints pointing at the same resource

It is fine if the caching behavior is satisfactory.  As far as general purpose components are concerned, two different URI means two different resources, and therefore the representations of those resources in the local cache will be independent of each other.
So how much of a problem is it if you have an old copy of one resource and a fresh copy of a different one?
For example: if you are using unsafe HTTP requests to control your house, then each successful POST/PUT/PATCH is going to invalidate the cached representations of the target URI, but leave the other representations unchanged.  So you'll potentially have brand new copy of one resource, and a stale copy of a different resource that refers to the same appliance in your home.

