I am developing a REST API where users can request data from one or more sensors, using the following scheme:
GET /sensors - returns a list of available sensors
GET /sensors/<sensor_ids>/data - returns data for one or more sensors, specified by sensor_ids
But the client also wants users to be able to send a request without a sensor_id
, which will return all available data for all sensors.
I was thinking there are two ways we could do this:
GET /sensors/all/data - specify sensor_id as "all"
GET /sensors/data - omit the sensor_id altogether
I am not sure which would be the better option and most consistent with REST best practices. Data and sensors are both resources, but data is always associated with a sensor.
Any suggestions would be appreciated.