JS-151-API
  • JavaScript Library
  • 02-DOM-Manipulation
    • Overview
    • DOM Explained
    • Example Setup
    • Selecting Elements
    • Events
    • Complete Example
  • 03-API Fundamentals
    • 0-Getting Started
      • Welcome
    • 1-Intro-To-APIs
      • Intro
      • Client
      • Requests
      • JSON
      • API Endpoints
      • Server
      • Response
      • Statelessness
      • REST
    • 2-Asynchronous-Programming
      • Intro
      • Callbacks
      • Promises
      • Promises Continued
      • Chaining Promises
    • 3-Fetch
      • Fetch Intro
      • Star Wars
        • Star Wars API
        • Star Wars Setup
        • Star Wars JS
      • Random Photo
        • Unsplash
        • Unsplash Setup
        • Unsplash JS
    • 4-Apps
      • 01-New York Times
        • 00-App Intro
        • 01-HTML/CSS/API Key
        • 02-Variables
        • 03-Event Listeners
        • 04-fetchResults
          • 01-fetchResults()
          • 02-preventDefault()
          • 03-fetch() method
          • 04-Dates
        • 05-displayResults
          • 01-Logging JSON
          • 02-Working with JSON
          • 03-Link Display
          • 04-Results Navigation
          • 05-Results Update
          • 06-Keywords
          • 07-Images
        • 06-Pagination
          • 01-Pagination Intro
          • 02-Pagination Functions
        • 07-Next Steps
      • 02-YouTube
        • html
        • youtube.css
        • youtube.js
      • 03-GoogleMaps
        • Setup
        • HTML and CSS files
        • API Key
        • JS Setup
        • Adding Your Location
        • Listeners
        • Custom Options
Powered by GitBook
On this page
  1. 03-API Fundamentals
  2. 1-Intro-To-APIs

Statelessness

One of the most important reasons HTTP is used throughout web programming is the fact that it is a Stateless language, in that the server does not store any data from the request. This is important for several reasons:

  • It helps to prevent secure information from being compromised. If nothing is stored, nothing can be accessed.

  • It allows an API to be deployed to multiple servers to spread out user traffic. Nothing is dependant on certain information that is only stored in one place.

  • It allows an API to focus only on client-side logic. No server-side logic means less code, and therefore fewer things to take up time for each search.

Essentially, as soon as a response is sent back to the client, the request is deleted and disappears like it never existed. If the information is requested again, the server has no knowledge of any prior request, nor does it know that it sent a response previously. This means that any important information needs to be provided with every request, such as a key to allow access into the API.

The important thing to remember is that the client must provide all required information in every request, and that no information from a request must ever be stored on the server. This concept is critical to understanding the relationship between the client and the server, as well as understanding how to create your own API in the future.

PreviousResponseNextREST

Last updated 7 years ago