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
  • Example Requests
  • HTTP Verbs
  • POST
  • GET
  • PUT
  • DELETE
  1. 03-API Fundamentals
  2. 1-Intro-To-APIs

Requests

Whenever the client (web browser or mobile app) fetches a file or sends data (a page, a picture, a username and password, etc) to or from a web server, it does so using HTTP (Hypertext Transfer Protocol).

Example Requests

Most modern applications make multiple types of requests. Here are some examples of requests made using Facebook:

  1. A user writes a post and presses Post.

  2. A user goes to Instant Messenger to access a friends message.

  3. A user goes into their profile and updates their favorite bands.

  4. A user deletes their profile.

HTTP Verbs

Each one of these requests is done using HTTP. In coding terminology, these are known as HTTP verbs. They are used in most modern programming languages, including Java, C#, Python, etc. There are over 20 HTTP verbs, but there are only 4 that are most commonly used. These verbs are as follows:

  • POST

  • GET

  • PUT

  • DELETE

Let's break each one down a little bit.

POST

Any time a user is creating new information, that is usually a POST request. So, in the above example, when they make a write a new post and hit post.

GET

Any time a user is retrieving existing information, that is usually a GET request. So, in the above example, when a user goes to messenger and can see all their friends messages.

PUT

Any time a user is overwriting existing information or updating information, that is usually a PUT request. So, in the above example, when a user updates their favorite brands they are doing a PUT request.

DELETE

Any time a user is deleting existing information, that is usually a DELETE request. So, in the above example, when a user would delete their profile, they would be doing a DELETE request.

PreviousClientNextJSON

Last updated 7 years ago