Sunday, December 31, 2017

How a RESTful API server reacts to requests

light-traces-2985871_1920-0b0b64dd0f932b

Learn how to properly design RESTful APIs communication with clients, accounting for request structure, authentication, and caching.

This series of articles shows you how to derive an easy-to-use, robust, efficient API to serve users on the web or on mobile devices. We are using the principles of RESTful architecture over HTTP. In the first piece, we started from a list of specs for a simple bike rental service, defining URLs and the HTTP methods to serve the app. In this second part, we will talk in more detail about how the server should react to incoming requests with status codes. We will also talk about how to identify who is the user performing a request (authentication), why Cross-Origin Resource Sharing (CORS) matters for APIs, how caching can improve performance, and how HTTP optimistic locking can prevent inconsistencies in resources.

Here is where we left off from the last post: we have the URLs (nouns) and the HTTP methods (actions) our API responds to. Each combination of URL and HTTP method corresponds to a functionality available in the bike rental app:

Continue reading How a RESTful API server reacts to requests.

http://ift.tt/2llTHYa
Related Posts Plugin for WordPress, Blogger...