Regarding having the REST backend itself retrieve the details from the external APIs, It can be done, but I thought it may not be appropriate due to the following reasons:
Later I may want to use this system for a different deployment(different set of devices), in that case, the external APIs, credentials to access them and the response fields would change. So, I thought it would be better not to have these set in the REST backend to keep it generic.
I haven't worked much with RESTful services or web services in general, I am not clear how/what would the flow be in case the REST backend is itself doing the fetching:
a. Meaning is it like whenever the client browser sends a request for example to get all the devices in London, then the REST Backend first gets all the devices from the database, then calls external APIs with the list of all device IDs to get the details, then filters the response where city is London and then provides the response to the web client.
b. If this is the case then should the external API call from the REST Backend be synchrnous or aysnchronous. If it is synchronous, then the response time for the web client to the request it sent will be high. Google App Engine I think has a time-limit of 60 seconds for HTTP requests.
c. If the calls to external APIs are asynchronous, then what does the REST Backend return to the web client when it makes the GET request.
d. Also, in this case, the REST Backend would in a way be acting both as a REST Server and a Client. Is that correct? I mean in whatever tutorials/examples I saw I didn't see any such usage?