# Sustainable IoT Sensing Applications Development through GraphQL-Based Abstraction Layer
## 3 Application Models for Cloud-based IoT  
### REST Architecture and Cloud-based IoT  
REST (Representational State Transfer) is a web architectural style, which is built around Uniform Resource Identifier (URI), HyperText Markup Language (HTML) and HyperText Transfer Protocol (HTTP). It defines some constraints for web services and properties. It presents principles for server to expose resources to its clients. However, in the modern age of agile technologies, REST APIs are lacking the flexibility needed for the clients with dynamic requirements.  
REST architecture is bound with HTTP protocol for data transport and it requires a separate API endpoint for each server resource. For requirement of flexibility and maintainability, APIs may need re-writing, when the domain data structure, components or users requirements are changed, because endpoint definition in advance for every data request cannot be provided. An application has to address multiple resources, if the data requested are of the complex nature from multiple entities involving different types. Thus, it results in multiple round trips to collect the data.  
REST being prevalent web architectural style is still used for accessing variety of data and even for hierarchical nature data. However, for cloud-based IoT networks, it becomes draining because of the limitations of the resources of involved constrained devices. It may become more worrying in case of applications needing continuous large amount of data sending. Such type of applications need communication efficiency, with less number of round trip times for data collection. Hence, IoT sensing applications desire new solutions for cloud-based scenarios.  
Figure 3 shows a scenario to the illustrate inefficiency of REST architecture in IoT sensing applications submitting data to the cloud. Here, we have an IoT device attached to a smart car containing two sensors, which is posting data to a cloud server. Each sensor needs to send its data to a separate resource at server through its exposed endpoint. By using the REST architecture, multiple requests are needed to submit data to each resource. Many examples of more complex scenarios can be easily found in real-world IoT applications, e.g., a smart car having multiple sensors such as speed sensor,  
acceleration sensor, location sensor, engine and fuel status sensors. Here, for the sake of clarity in the example scenario, only two sensors are being considered, i.e., location sensor and speed sensor. Data collected from these two sensors need to be sent to a cloud server where each sensor node has a separate resource defined for its data, with a unique REST endpoint, i.e., /Car/Loc and /Car/Speed. Each sensor datum will require a separate POST request and, therefore, in a smart city having thousands of smart cars and other IoT devices, we can easily imagine the explosion in the network traffic. As a result, IoT applications can suffer network congestion, resulting in packet losses and energy wastage.  
To avoid such situations and improve the lifetime of the sensor nodes, as well as of the overall IoT network, a suitable approach is used to decrease the number of data transactions communicated by the application. One way to achieve this minimisation can be using data fusion at IoT node level or through in-network data aggregation, but the constrained nature of IoT devices poses challenges for adopting such complex data reducing algorithms. The other solution to control network traffic in cloud-based IoT networks can be reducing the number of round trips needed for data posting from sensor nodes, and we adopt this approach in our work.