Let's make life easier by documenting everything, one step at a time.

What Are RESTful Services?

REST (Representational State Transfer) is an architectural style for building web services that communicate over the web. In simpler terms, RESTful services allow applications (clients) to interact with servers using standard HTTP methods like:

  • GET – retrieve data
  • POST – create new data
  • PUT – update existing data
  • PATCH – partial modification to existing data
  • DELETE – remove data

RESTful service are built around resources, which are usually represented by URLs. For example:

https://www.urljockey.com/students

This URL could represent all students, and sending different HTTP requests to it lets clients view, create, update, or delete user data.

How RESTful Services Work With the Web?

Every time a web app or mobile app communicates with a server, it typically does so through a REST API:

Client (browser or app) → HTTP request → Server → Response (data in JSON or XML)

This request-response pattern is at the heart of almost every modern web application. Frontend developers, testers, and educators often need to interact with these APIs while building features, running experiments, or teaching concepts.

HTTP Methods (GET, POST, PUT, PATCH, DELETE)

RESTful APIs rely on HTTP methods (also called verbs) to indicate the type of action a client wants to perform on a resource. Each method has a specific purpose:

GET

  • Purpose: Retrieve data from the server.
  • Characteristics: Safe (doesn’t change data), idempotent (multiple calls have the same effect).
  • Example: Fetching a list of students:
GET /students HTTP/1.1
Host: api.urljockey.com

POST

  • Purpose: Create a new resource on the server.
  • Characteristics: Not idempotent (multiple calls may create multiple resources).
  • Example: Creating a new student:
POST /students HTTP/1.1
Host: api.urljockey.com
Content-Type: application/json

{
  "name": "Alice",
  "email": "alice@example.com"
}
                

PUT

  • Purpose: Update an existing resource on the server (or create it if it doesn’t exist at the specified URI).
  • Characteristics: Idempotent (multiple identical calls result in the same state).
  • Example: Updating an existing student:
PUT /students/123 HTTP/1.1
Host: api.urljockey.com
Content-Type: application/json

{
  "name": "Alice Johnson",
  "email": "alice.johnson@example.com"
}
                

PATCH

  • Purpose: Update part of a resource.
  • Characteristics: Usually idempotent, only changes the specified fields.
  • Example: Updating just the email:
PATCH /students/123 HTTP/1.1
Host: api.urljockey.com
Content-Type: application/json

{
  "email": "alice.new@example.com"
}
                

DELETE

  • Purpose: Remove a resource from the server.
  • Characteristics: Idempotent (deleting a non-existent resource usually returns the same result).
  • Example: Delete a student:
DELETE /students/123 HTTP/1.1
Host: api.urljockey.com
                

HTTP Verbs: GET, POST, PUT, PATCH, DELETE

HTTP verbs are used to interact with resources on a web server. They define the action to be taken on the resources.

In this section, we will explore the five main HTTP verbs: GET, POST, PUT, PATCH, and DELETE, their use cases, and how they differ from each other.

GET Method

Subheader: Fetching Data

The GET method is used to retrieve data from a server. It does not alter the data on the server, making it a safe and idempotent method.

GET requests can be sent via a web browser or an API call, and they are often used to load web pages, search results, and more.

GET /api/users HTTP/1.1

POST Method

Subheader: Creating Data

POST is used to send data to the server, usually to create a new resource. The data sent via POST is often included in the request body.


                    POST /api/users HTTP/1.1
                    Content-Type: application/json
                    {
                        "name": "John",
                        "age": 30
                    }

PUT Method

Subheader: Replacing Data

PUT is used to update or replace an existing resource. It is idempotent, meaning that making the same request multiple times will have the same result.


                    PUT /api/users/1 HTTP/1.1
                    Content-Type: application/json
                    {
                        "name": "John",
                        "age": 31
                    }

DELETE Method

Subheader: Deleting Data

DELETE is used to remove a resource from the server. Once a resource is deleted, it can no longer be accessed via its previous URL.

DELETE /api/users/1 HTTP/1.1

Visualizing HTTP Requests

Below is an illustration showing how different HTTP methods interact with resources.

HTTP Methods Illustration