REST - Wendy's 4 for 4

From Coder Merlin
Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder


Brief Overview[edit]

API in action

REST API or RESTful API stands for REpresentational State Transfer

An API is a means of communication with a server. Whenever you browse something on the internet, your browser will ask the server for data. The server will then present the data; an API handles the data transfer between your device and the server.

The rest API works with the client and server. The client will send data through a request, and the server will send the data back in the form of a response.

To view, an image of how RESTAPI works click here[[1]]

Components[edit]

  • Resource Path

Resource path is the “request target” or the desired destination for the object. For example, a resource path could be “codermerlin.com/wiki/database/grades” where the object would be sent to the grades directory of the host.

  • HTTP Verb

With an HTTP Verb, the actions of the resource could be easily defined. A handy acronym to remember the available HTTP Verbs is “C R U D” or Creation (creates a resource), Retrieval (retrieves a resource), Update (updates a resource), and Deletion (deletes a resource).

  • Body

The body is the contents of the resource, and conveniently uses the JSON (JavaScript Object Notation) as the format. Both Creation operations and Update operations contain a body, but a Retrieval operation does not contain a body. In addition, the Deletion operation would also not contain a body.

  • Header

A header in short is simply a description of the resource, essentially acting as metadata for the resource.

Usage[edit]

REST has become increasingly popular due to its data structure requiring less bandwidth (Maximum amount of data transferred over time), making it much more efficient at transferring data. As a result, REST is often used on many web services and more recently, cloud services.

Endpoint Consistency - The path to an endpoint should remain consistent, which can prove to be a challenge.

Long Response times and too much Data - The number of resources and information returned can increase in size and the increase in time, which could lead to long response times, causing possible inconveniences.

Navigation paths and user input locations - Due to the nature of REST using URL paths as the input parameters, determining URL space may be a challenge.

Security - Aspects include - HTTPS, denying access from unknown IP Addresses, Validating URLs, Blocking overly large payloads, and investigating failures

Authentication - recommended using standard authentication methods, like HTTP basic authentication.

Requests and Data- data requests may have more data than necessary, or multiple requests may have to be used to receive all the data wanted.

Adittional concepts and challenges[edit]

Endpoint Consistency - The path to an endpoint should remain consistent, which can prove to be a challenge.

Long Response times and too much Data - The number of resources and information returned can increase in size and the increase in time, which could lead to long response times, causing possible inconveniences.

Navigation paths and user input locations - Due to the nature of REST using URL paths as the input parameters, determining URL space may be a challenge.

Security - Aspects include - HTTPS, denying access from unknown IP Addresses, Validating URLs, Blocking overly large payloads, and investigating failures

Authentication - recommended using standard authentication methods, like HTTP basic authentication.

Requests and Data- data requests may have more data than necessary, or multiple requests may have to be used to receive all the data wanted.

Sources[edit]