Site Loader
Rock Street, San Francisco

REpresentational State Transfer, or REST, is a design pattern for interacting with resources stored in a server. Each resource has an identity, a data type, and supports a set of actions.The RESTful design pattern is normally used in combination with HTTP, the language of the internet. In this context the resource’s identity is its URI, the data type is its Media Type, and the actions are made up of the standard HTTP methods (GET, PUT, POST, and DELETE). The 5 basic design guidelines that make a RESTful API:Resources (URIs) HTTP Methods HTTP Headers Query Parameters  Status Code1. Resources (URIs) Each resource is identified by a Uniform Resource Identifier (URI) used throughout HTTP for identifying resources.Ex:  http://localhost:8081/data              2. HTTP MethodsHTTP Methods describe what actions are performed on the resources and facilitate the developer’s work handling recurrent CRUD operations.The four major HTTP methods define the four operations that are commonly implemented by RESTful Services. The HTTP POST method is used for creating a resource, GET is used to query it, PUT is used to change it, and DELETE is used to destroy it.The two very important properties of HTTP methods: idempotence and safety.An operation is idempotent if it will produce the same results when executed once or multiple times. For instance, the PUT and DELETE methods are defined to be idempotent.Safe HTTP methods don’t change the resource on the server side. For example using a GET or a HEAD request on a resource URL should NEVER change the resource. Safe methods can be cached and prefetched without any repercussions or side-effect to the resource.Adhering to the idempotency and safety contract helps make an API fault-tolerant and robust.3. HTTP HeadersHTTP header fields provide required information about the request or response, or about the object sent in the message body.Below is the headers of http://localhost:8081/data/newAccess-Control-Allow-Origin ?*Content-Length ?877Content-Type ?text/html; charset=UTF-8Date ?Wed, 24 Jan 2018 23:45:29 GMTServer ?WSGIServer/0.1 Python/2.7.144. Query ParametersQuery parameters allow you to pass optional parameters to a route such as pagination information.For example, on a route with a paginated list, the URL might look like the following to indicate that we’ve loaded the second page:ex) localhost:8080/phones-list?page=25.Status CodeThese kind of status code were used for catching errors. It’s important to use proper HTTP status to announce what caused the error.HTTP response status codes indicate whether a specific HTTP request has been successfully completed or notClient error responses204-NO CONTENT The resource was successfully deleted, no response body400-FORBIDDENThe server understood the request, but is refusing it or the access is not allowed.404-NOT FOUNDThere is no resource behind the URI.500-INTERNAL SERVER ERRORThis error should be avoided. If an error occurs in the global catch blog, the stack trace should be logged and not returned as response.

Post Author: admin


I'm Dora!

Would you like to get a custom essay? How about receiving a customized one?

Check it out