DEV Community

Cover image for REST APIs & HTTP Requests
Connor Dillon
Connor Dillon

Posted on

REST APIs & HTTP Requests

What is an API?

  • API stands for "Application Programming Interface"
  • Contract provided by one piece of software to another
  • Structured request and response

What is REST?

  • REST stands for "Representational State Transfer"
  • Architectural style for designing networked applications
  • Relies on a stateless, client-server protocol, almost always HTTP
  • Treats server objects as resources that can be created or destroyed
  • Can be used by virtually any programming language
  • All APIs have their own rules and structure

Types of Requests

  • GET: Retrieve data from a specified resource
  • POST: Submit data to be process to a specified resource
  • PUT: Update a specified resource
  • DELETE: Delete a specified resource
  • HEAD: Same as get but does not return a body (only returns header)
  • OPTIONS: Returns the supported HTTP methods
  • PATCH: Update partial resources (similar to PUT)

API Endpoints

Endpoints are URLs that you can access to do certain things:

Method URL Function
GET https://website.com/api/users Get all users
GET https://website.com/api/users/1 Get single user
POST https://website.com/api/users Add user
PUT https://website.com/api/users/1 Update user
DELETE https://website.com/api/users/1 Delete user

Top comments (0)