What is REST?

Share this & earn $10
Web Dev Simplified
Published at : 06 Dec 2020
50514 views
1676
12

If you have used any modern website, then chances are you have interacted with a website that uses REST. Even YouTube uses RESTful URLs on its site, but what exactly is REST? For starters, REST stands for Representation State Transfer and is just a fancy way of saying that a server responds to create, read, update, and delete requests in a standard way. The idea behind REST is to treat all server URLs as access points for the various resources on the server. For example in this URL, http://example.com/users, users represents the resource that the server is exposing. As mentioned earlier, REST needs a way to create, read, update, and delete these resources and it does so with the following five URLs.
http://example.com/users
http://example.com/users
http://example.com/users/1
http://example.com/users/1
http://example.com/users/1

The first two URLs do not have an ID so they act on the entire user's resource, while the last three URLs do have an ID in their URL and thus act on only a single user resource, but as you may notice there are only two distinct URLs. That is because REST uses the four basic HTTP actions, GET, POST, PUT, and DELETE to determine what to do with each URL. If we add in those actions to the URLs it is much easier to see what each of the URLs do.
[GET] http://example.com/users
[POST] http://example.com/users
[GET] http://example.com/users/1
[PUT] http://example.com/users/1
[DELETE] http://example.com/users/1

The first URL we have is the GET users URL, and it is used to get a list of all users. In REST when a GET URL does not have an ID it acts upon the entire resource and will always return a list of every item in that resource. The GET action in REST corresponds with reading data.

The second URL, which is almost identical to the first, is used to create a new user. In REST the POST action corresponds with creation, and should always be used on the entire resource by not using an ID in the URL.

The third URL is another GET URL, but this URL is for getting only a single user based on the id that is in the URL. The ID portion of the URL is used by REST to determine which resource from the collection of resources it should act upon. In the case of this URL it is used to return the user with that ID.

The fourth URL is the most confusing of them all, but it is used to update a user with the given ID. The PUT action in REST corresponds with update and works very similarly to POST, but instead of creating a new resource it updates an existing resource.

Lastly, we have the most straight forward URL of them all which is for deleting a user with a specific ID. The DELETE action in REST does exactly what you would think and deletes the resource with the given ID.


In order for a website to use REST, the URLs do not need to be formatted exactly the same as above. For example using these URLs would still be considered RESTful, but most applications will use the previously mentioned URLs.
[GET] http://example.com/users
[POST] http://example.com/users
[GET] http://example.com/users/details/1
[PUT] http://example.com/users/update/1
[DELETE] http://example.com/users/delete/1

The only thing that matters with REST is that the URLs used represent a resource, in this case a user, and that they support creating, reading, updating, and deleting from that resource using the HTTP actions GET, POST, PUT, and DELETE.

Previous Video:
https://youtu.be/4r6WdaY3SOA

Next Video:
https://youtu.be/DUg2SWWK18I

Playlist:
https://www.youtube.com/playlist?list=PLZlA0Gpn_vH8jbFkBjOuFjhxANC63OmXM


Twitter:
https://twitter.com/DevSimplified

GitHub:
https://github.com/WebDevSimplified

CodePen:
https://codepen.io/WebDevSimplified


#REST #WebDevelopment #RESTful
webdevsimplifiedwhat is restget post put delete

Occasional Router Table

Occasional Router Table

Entry Point - How to Kill Vault's Sensors for forever! + Guides For Operative Difficult (3 Stars)

Entry Point - How to Kill Vault's Sensors for forever! + Guides For Operative Difficult (3 Stars)

Correlation coefficient (r) & coefficient of determination (r^2) using the calculator (CASIO fx-991)

Correlation coefficient (r) & coefficient of determination (r^2) using the calculator (CASIO fx-991)

Difference between Drug and Medicine

Difference between Drug and Medicine

12 Ways to Protect Your Home While You’re Away

12 Ways to Protect Your Home While You’re Away

Fredo Bang - Top ft. Lil Durk (Official Music Video)

Fredo Bang - Top ft. Lil Durk (Official Music Video)

How to pronounce or say nine hundred forty five - 945 ? Pronunciation - English

How to pronounce or say nine hundred forty five - 945 ? Pronunciation - English

Sasha learn English Alphabet and looking for hidden letters

Sasha learn English Alphabet and looking for hidden letters

30+ MAGIC WATER MARKER ideas YOU can use everyday

30+ MAGIC WATER MARKER ideas YOU can use everyday

The FIRST Thing You Need To Do (If You Want To Get Anywhere In Life)

The FIRST Thing You Need To Do (If You Want To Get Anywhere In Life)

Father John Misty - I'm Writing a Novel [OFFICIAL VIDEO]

Father John Misty - I'm Writing a Novel [OFFICIAL VIDEO]

Paco - Through A Lot (Official Music Video)

Paco - Through A Lot (Official Music Video)

Cartoon - Be Attentive to Your Children | AmoMama

Cartoon - Be Attentive to Your Children | AmoMama

This Isn't The Brexit We Voted For!  Ireland Facing Worst Pandemic Numbers In The World!  Trump?

This Isn't The Brexit We Voted For! Ireland Facing Worst Pandemic Numbers In The World! Trump?

14 Quotes That Will Make You Tear Up

14 Quotes That Will Make You Tear Up

Abraham Hicks - Living on the Leading Edge

Abraham Hicks - Living on the Leading Edge

This is why Lionel Messi is regarded as one of the best footballers of all time. Unbelievable!!

This is why Lionel Messi is regarded as one of the best footballers of all time. Unbelievable!!

THE BIGGEST SNAKES In The World

THE BIGGEST SNAKES In The World

Future Ground Combat Vehicle to Replace M2 Bradley

Future Ground Combat Vehicle to Replace M2 Bradley

Fifty Shades Of Grey - Drunk Ana

Fifty Shades Of Grey - Drunk Ana

Stricken by disturbed [hunter x hunter] fight since

Stricken by disturbed [hunter x hunter] fight since

Hopsin - I Need Help (lyrics)

Hopsin - I Need Help (lyrics)

In the House - 3x01 - The Real World (Part 1)

In the House - 3x01 - The Real World (Part 1)

Life Is a Dream, Realize It

Life Is a Dream, Realize It

Must and Mustn't - Classroom Rules

Must and Mustn't - Classroom Rules

REMAIN IN ENGLISH SPEAKING

REMAIN IN ENGLISH SPEAKING

The Sixty-Fifth A. W. Mellon Lectures in the Fine Arts: The Thief Who Stole My Heart: The Material L

The Sixty-Fifth A. W. Mellon Lectures in the Fine Arts: The Thief Who Stole My Heart: The Material L

“High School” - Mirrored Image (Official Video)

“High School” - Mirrored Image (Official Video)

Linux Mint 20.1 Cinnamon | New Features And Improvements

Linux Mint 20.1 Cinnamon | New Features And Improvements

BTS // Alpha 7S III // Cinematic Show Reel in 4K shot by Benn TK - Behind The Scenes

BTS // Alpha 7S III // Cinematic Show Reel in 4K shot by Benn TK - Behind The Scenes

ARK INVEST MIGHT BUY THIS MASSIVE STOCK! (HUGE POTENTIAL) | ROBINHOOD

ARK INVEST MIGHT BUY THIS MASSIVE STOCK! (HUGE POTENTIAL) | ROBINHOOD

I Spent 100 days in HARDCORE RLCraft.. Here's What Happened

I Spent 100 days in HARDCORE RLCraft.. Here's What Happened

스텔라장(Stella Jang) - Colors Official MV

스텔라장(Stella Jang) - Colors Official MV

How To Do a Perfect Sit-Up (5 EASY STEPS!)

How To Do a Perfect Sit-Up (5 EASY STEPS!)

"You really don't have interest in me" seulrene ft. the members' reactions

"You really don't have interest in me" seulrene ft. the members' reactions

How do I purchase a PRESTO ticket for use on the TTC?

How do I purchase a PRESTO ticket for use on the TTC?

Action Classification & SAR of Anti-Cholinergic Drugs  || L-6 Unit-3 Medicinal Chemistry -I

Action Classification & SAR of Anti-Cholinergic Drugs || L-6 Unit-3 Medicinal Chemistry -I

Luan Santana - Check-In (Videoclipe Oficial)

Luan Santana - Check-In (Videoclipe Oficial)

MY EVERY DAY MAKEUP ROUTINE! (WITH TINY CUTE ASSISTANT!)

MY EVERY DAY MAKEUP ROUTINE! (WITH TINY CUTE ASSISTANT!)

Unlike Pluto - Stay and Decay - Lyrics

Unlike Pluto - Stay and Decay - Lyrics

The Kinds  -  Fear is Nothing

The Kinds - Fear is Nothing

Tesla outlines new process to order a Model 3, which includes a $2,500 deposit

Tesla outlines new process to order a Model 3, which includes a $2,500 deposit

Impolite

Impolite

I SPEND ALL MY Diamond Locks For TACKLE BOX!! ( RIP DLS! )

I SPEND ALL MY Diamond Locks For TACKLE BOX!! ( RIP DLS! )

pungent stench - klyster boogie (live)

pungent stench - klyster boogie (live)

Cara Rose - Learn to Speak (Live at St Mark's Unitarian Church, Edinburgh)

Cara Rose - Learn to Speak (Live at St Mark's Unitarian Church, Edinburgh)

How to Create a Group Chat on Facebook

How to Create a Group Chat on Facebook

Idea how to make a gacha character(What I named the character:Amber)

Idea how to make a gacha character(What I named the character:Amber)

👭💖 Отомстила за издевательства над сестрой 💖 Клип к дораме "Все там / Everyone Is There 2020"

👭💖 Отомстила за издевательства над сестрой 💖 Клип к дораме "Все там / Everyone Is There 2020"