Given an understanding of APIs and their importance, let's explore REST - REpresentational State Transfer. REST is a software architecture style for designing scalable networked applications, specifically web services. By providing a coordinated set of constraints applied to component design in distributed systems, REST facilitates higher levels of performance and more maintainable architectures.
RESTful constraints are described as follows:
- Client server - clients and servers are fully separated and communicate only via the RESTful interface.
- Stateless - no client context or state is stored on the server between requests, and each client request must contain all of the information needed for the server to service the request.
- Cacheable - clients can cache responses, and servers must define the cacheability of the response.
- Layered - a client should not be able to tell whether it is connected to a server or to an intermediate that provides functionality such as security, caching, or load-balancing.
- Code on Demand (Optional) - servers can at times extend the capabilities of a client through the transfer of executable code or scripts.
- Uniform Interface - both client and server must adhere to a uniform interface that allows for the independent development of functionality.
- Resource Identification - individual resources are identified using URIs in requests. Representations of resources are distinct from the actual resources and may be provided in formats such as HTML, XML, or JSON.
REST relies on standards protocols HTTP or HTTPS to transmit calls between entities, and within that leverages unique URL identifiers, either a verb or a noun. The specified HTTP methods or verbs for REST are as follows:
- GET - List the URI's in a collection, or a representation of an individual member
- POST - Create a new entry in a collection. The new entry's URI is assigned automatically and returned by the operation
- PUT - Replace an entire collection with a collection, or individual member with another. If a member does not exist, create one
- DELETE - Delete an entire collection or an individual member
The two behaviors of REST operations are:
- Idempotent - the operation has the same effect no matter how many times it is performed (PUT and DELETE)
- Nullipotent - the operation does not affect the resource (GET)
REST Communication Flow
URI
The URI is a string of characters used to identify the name of a resource. Two types of URI's exist:
- Uniform Resource Locator (URL) - what we often refer to as a web address
- Uniform Resource Name (URN) - less frequently utilized, but intended to compliment URLs by offering a way to identify specific namespace resources
A REST URL contains:
- Protocol/schema
- Resource IP or hostname
- Path and filename
An important distinction and concept to understand is the difference between absolute and relative. In absolute we provide the exact path, whereas in relative there is a layer of indirection where we give the path to the actual location. The following is a sample URI:
URI Model
API Security
REST uses HTTPS for encrypted transport. Several widely-accepted industry practices to provide API security are utilized today, including OAuth, BasicAuth, and API Keys.
Data Formats
Data formats represent different ways we render output information to the user or application. Two primary data formats we'll cover here are JavaScript Object Notification (JSON) and eXtensible Markup Language (XML).
XML is similar to HTML, but designed to encode structured data. Tags are self-defined rather than standardized.
Data formats represent different ways we render output information to the user or application. Two primary data formats we'll cover here are JavaS>cript Object Notification (JSON) and eX>tensible Markup Language (XML).
XML is similar to HTML, but designed to encode structured data. Tags are self-defined rather than standardized.

XML Request and Response Format
JSON is focused on being more human readable and uses attribute-value pairs. The encoding format utilizes:
- a collection of name/value pairs
- an ordered list of values

JSON Request and Response Format
The REST API structure is one of the most prevalent API design types available. It provides a language-independent easy-to-structure interface based on well known HTTP web concepts that are familiar to most users.