What is REST?

Sdílet
Vložit
  • čas přidán 31. 05. 2024
  • If you have used any modern website, then chances are you have interacted with a website that uses REST. Even CZcams 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, 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.
    example.com/users
    example.com/users
    example.com/users/1
    example.com/users/1
    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] example.com/users
    [POST] example.com/users
    [GET] example.com/users/1
    [PUT] example.com/users/1
    [DELETE] 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] example.com/users
    [POST] example.com/users
    [GET] example.com/users/details/1
    [PUT] example.com/users/update/1
    [DELETE] 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:
    • How The Backend Works
    Next Video:
    • MVC Explained in 4 Min...
    Playlist:
    • Full Stack Web Develop...
    Twitter:
    / devsimplified
    GitHub:
    github.com/WebDevSimplified
    CodePen:
    codepen.io/WebDevSimplified
    #REST #WebDevelopment #RESTful

Komentáře • 108

  • @developedbyed
    @developedbyed Před 5 lety +316

    great one! now I'm gonna go rest... hehehe ( I know it's not funny).

  • @playboy6622
    @playboy6622 Před 2 lety +33

    You are just amazing. We didnt have a teacher like you in our school. We all mugged the code up and couldnt reproduce it as we didnt understand the logic. By looking at all your videos, I can say I am gaining the confidence to build a website

  • @javxa
    @javxa Před 3 lety +10

    The simplest and clearest explanation of REST. Thanks a lot!

  • @juvenalgonzalez5291
    @juvenalgonzalez5291 Před 2 lety

    I've read so many different explanations of REST and this is by far the clearest explanation. Thank You!

  • @mahrig1829
    @mahrig1829 Před 5 lety +32

    CZcams Search results about Web Dev, programming language tutorials usually shows old outdated videos which is hard to understand rather videos like this one. Your videos deserves definetely more likes. I would like to thank you for your hard work and effort. Im subscribed and looking forward for your next videos. Thank you again!

    • @WebDevSimplified
      @WebDevSimplified  Před 5 lety +4

      Thank you for the kind words. I am really glad that you enjoyed my video. Part of the reason I started my channel was because of all the outdated content on CZcams.

    • @Amberussianbeauty
      @Amberussianbeauty Před 3 lety +1

      This is the most used/amazing channel I’ve ever encountered!

  • @khandoor7228
    @khandoor7228 Před 5 lety +4

    Hey WebDev this series looks really cool, I'm really looking forward to it. I subscribed a couple weeks ago because I thought you really knew your stuff so I'm excited to track this series. Let's go brother!

    • @WebDevSimplified
      @WebDevSimplified  Před 5 lety

      Thanks! I really hope that you enjoy the series and future videos to come.

  • @ShafiqNazrin
    @ShafiqNazrin Před 6 měsíci

    This is probably the easiest way to explain REST. Definitely a genius to come up with this.

  • @jackfrost8969
    @jackfrost8969 Před 4 lety +23

    This guy is literally blessing🙏

  • @iconicbehaviour
    @iconicbehaviour Před 4 lety +10

    It's been about 10 minutes since I first came to your channel and I am on my second video already! Great job and really loving it :)))

    • @WebDevSimplified
      @WebDevSimplified  Před 4 lety +1

      Thank you so much! I really hope you love the rest of my videos as well.

  • @JM-tu8mg
    @JM-tu8mg Před 3 lety

    Great video! This is the best explanation of REST I have ever seen!

  • @karaokewaala9107
    @karaokewaala9107 Před 3 lety +4

    This was so simple, i was scratching my head reading all about it on the internet

  • @anthonytcool350
    @anthonytcool350 Před 3 lety

    Bro, this is a great. I can understand the difficulty and confusing of the REST in 3 mins. Keep doing your great work!

  • @rociodesantiago867
    @rociodesantiago867 Před 3 lety +2

    Thank you! That was such a simple and straight to the point explanation!

  • @tfilipow7
    @tfilipow7 Před 2 lety

    Thank you, no one has explained that to me in such an efficient way.

  • @Pareshbpatel
    @Pareshbpatel Před 3 lety

    Very clear and succinct introduction to RESTful APIs - Thank you, Kyle
    {2021-06-07}, {2021-09-08}

  • @nwobodogeorge5370
    @nwobodogeorge5370 Před 3 lety

    Thank you. The video is concise and straight to the point.

  • @albertoazinar1209
    @albertoazinar1209 Před 3 lety

    Found your channel today. I'm already learning alot. thankiu

  • @GaborNeogrady
    @GaborNeogrady Před 3 lety +1

    Lovely tutorials, really simple. Greetings from Hungary :)

  • @davidr.flores2043
    @davidr.flores2043 Před 2 lety

    Thank you my friend. I'm a beginner and your explanation was very clear. Best regards.

  • @STRIPPEDSTAR
    @STRIPPEDSTAR Před 3 lety

    Perfect, concise explaination!

  • @user-rg5tk3sw6v
    @user-rg5tk3sw6v Před 4 lety

    Thanks, Kyle. Your videos really helps me to understand different topics. Btw, don't you mind if I translate some of your videos to Russian?

  • @johongirrahimov2343
    @johongirrahimov2343 Před 2 lety

    I'm honored to learn from you. my sensei

  • @pavelvitov2773
    @pavelvitov2773 Před rokem

    Great video man, helps a lot as I have an exam tomorrow. :D

  • @nicolasesteban699
    @nicolasesteban699 Před rokem

    Perfectly explained, thanks!

  • @hashmatali4409
    @hashmatali4409 Před 5 lety +1

    i've been working on rest api for a year. But today i learnt what is REST.
    you simplify the complex things so beautifully.

  • @GAMINGWITHDESTRYER
    @GAMINGWITHDESTRYER Před 4 lety +1

    Sir, how the URL decide is this is a post req or a get req if the URL is same for both

  • @melzz
    @melzz Před 3 lety +1

    Am i do this wrong? I only use get and post....
    And even to retrieve data, sometime i use post.....eventhough it is using for create...
    Is it a bad practice?

  • @chickenjoy
    @chickenjoy Před 2 lety +2

    So in equivalent to SQL, is it:
    GET = Select *
    POST = Insert into
    PUT = Update
    DELETE = Delete

  • @Faxulous
    @Faxulous Před rokem

    thank you. SIMPLE AND CLEAR! Great.

  • @dubola5777
    @dubola5777 Před 2 lety

    Thanks. short and sweet!

  • @pixel690
    @pixel690 Před 3 lety

    is it bad that i have essentially been doing this all along by making web requests and even creating nodejs apis without understanding the meaning of REST

  • @pinkym6934
    @pinkym6934 Před 3 lety

    FFFFAAAAAAAAAANNNNNNNNNNNNNNTTTTTTTTTTTTTTTASTIC!!!!Crystal clear and precise....:)))

  • @genzee4567
    @genzee4567 Před rokem

    till date wondering what is REST AND REST API but u solved it. i have some doubt - how will server understand which request (GET/POST/DELETE/PUT) should be executed? Because the URLs r same

  • @sankharr
    @sankharr Před 2 lety

    Thanks for this video :)

  • @BullishBuddy
    @BullishBuddy Před 3 lety

    awesome! and subscribed

  • @RelaxingTomato
    @RelaxingTomato Před 5 lety

    Hey thanks a lot for this great explanation. Quick question: if I build a service that's sole purpose is to expose details about a specific ID using the rest format (i.e. GET /user/id) is this still considered a "REST API" or do I need to provide the full CRUD scope to be considered a REST API ? Hope this makes sense. Thanks

    • @WebDevSimplified
      @WebDevSimplified  Před 5 lety +1

      That would still be a REST API. As long as your API is built using resource routes and uses standard endpoints for CRUD then it is restful.

  • @I5starjordan
    @I5starjordan Před 2 lety

    Damn that was good and short

  • @unknowned1113
    @unknowned1113 Před rokem

    What's the point of the PUT and DELETE methods and routes if you can't even do the request using the standard HTML form?

  • @vaibhav_naik
    @vaibhav_naik Před 4 lety

    Well explained

  • @callmekaymusic
    @callmekaymusic Před 5 lety +5

    iam a south african and this content is helping me in my computer science degree

  • @stephenfoster9009
    @stephenfoster9009 Před 2 lety

    I did not see a difference in the URLs for [ GET ] and [ POST]?

  • @umaedu3097
    @umaedu3097 Před 7 měsíci

    could someone help me understand how to make a three different page website according top this model? thank you :)

  • @ms.newton2534
    @ms.newton2534 Před rokem

    Perfect for reviews

  • @alejandropoirier6493
    @alejandropoirier6493 Před rokem

    is there a difference between RESTful and REST APIs?

  • @dj1805
    @dj1805 Před 2 lety

    Greate, Thank you!!

  • @dev-playing-gt
    @dev-playing-gt Před 4 lety

    I heard it's better just use method with the same urls than representing the types in urls.
    like
    DELETE method-/user/ (O)
    /user/delete/id (X)
    how do you think?

    • @WebDevSimplified
      @WebDevSimplified  Před 4 lety

      I agree. I think it is easier to work with, but some people prefer the other way. In 90% of APIs you will see it with the same URL and just the method changing.

    • @dev-playing-gt
      @dev-playing-gt Před 4 lety

      Thank you for the quick and clear reply!

  • @warren1192
    @warren1192 Před 3 lety

    thank you!

  • @mr.webdev3700
    @mr.webdev3700 Před 5 lety +1

    Great Explanation! Good Job!

  • @inesborges4857
    @inesborges4857 Před 3 lety

    but aren't rest apis noy supposedto be modified. they are only supposed to use the get method because you can only get the details to use in your own application?

  • @sagyblecher9258
    @sagyblecher9258 Před 11 měsíci

    thanks kyle

  • @alibabarahaei2229
    @alibabarahaei2229 Před 10 dny

    Perfect❤

  • @Kessra
    @Kessra Před 3 lety +1

    In all honesty, this is NOT what REST is or should be. I understand that most people do think that this is REST, but no, this is definitely NOT what REST is. CRUD may be such a tiny portion of REST, which furthermore is just an oversimplification and circumsision of the actual HTTP operation definition. I.e. DELETE just removes the mapping of the URI to a resource but gives no promises or the like to a client that the resource is also removed. I.e. multiple URIs may be used to express the same state, which internally may point to the same database entry. On deleting one resource this would affect other resources as well as they litterally share the same data. Though RFC 7231 only states that the mapping of the URI to the resource is removed. Similar to resource creation which is not limited to POST only. Just read up in RFC 7231 on PUT what it should do when it created a resource. After all, its semantics are "replace the current state a resource has identified by a URI with the one provided in the received payload" and not simply update that resource. And if the server had no state for that resource yet, it will be created. HTTP at its heart is just a document management system and it's a side-effect of the document management we use to deduce some business logic of it. I'd recommend to search here on YT for a great talk Jim Webber held in 2011 talking about REST and DDD, or a talk given by Stefan Tilkov back in 2014 also on REST.
    Also, tooling such as Swagger or OpenAPI behave more like tradidional RPC IDLs, such as Corba, SOAP, Java's RMI, .NET COM+, ...) with further tooling that generate even stub-classes for such APIs. How much more does it take to realize that this is RPC through and through. Such things are tailor made for exactly that API and if the API ever introduces changes you have the same outcome as in traditional RPC environments. Further, often clients assume that resources represent a certain type and thus you will end up in typed resources (--> soabits.blogspot.com/2012/04/restful-resources-are-not-typed.html ) instead of relying on proper content-type negotiation or working on a "server teaches client what it needs to know to make furthre decisions/requests" principle.

  • @ctbram0627
    @ctbram0627 Před 3 lety

    I don't understand the first two urls you show as [GET] and [POST] are exactly the same??? How are you determining one is a [GET] and the other is a [POST]?

    • @rutger3188
      @rutger3188 Před 3 lety +1

      u define that within your call client, such as post man. Normally u use specific routes like GetUser and CreateUser to understand the difference in your code. But when making a request you define within your client if it is a post, get, patch or delete request ;)

  • @peppigue
    @peppigue Před 3 lety

    I use yt with chromecast a lot, and for some reason some vids are so choppy on the audio. Unfortunately I this is true for this and some other vids on this channel. Annoying, because this is a good source of the info I need...

  • @shitheegg9563
    @shitheegg9563 Před 3 lety +1

    ❤️

  • @Ada-zg2qb
    @Ada-zg2qb Před 4 lety

    🙏🙏🙏

  • @KeshavKumar-re1ls
    @KeshavKumar-re1ls Před 3 lety

    Hey Kyle. I think you should use a mic closer to your mouth. because the sound in some of the videos sounds hollow and it echoes.

  • @chinmayghule8272
    @chinmayghule8272 Před rokem

    There's no PATCH request in this video.

  • @sunnyboss3103
    @sunnyboss3103 Před 5 lety

    Sir what is restful web API ?? pls explain

    • @WebDevSimplified
      @WebDevSimplified  Před 5 lety +5

      A restful API is just an API that uses rest for its endpoints. Most APIs that you will see are restful.

    • @sunnyboss3103
      @sunnyboss3103 Před 5 lety +1

      @@WebDevSimplified thank you sir 🙏🙏 pls make more videos
      I watch every videos of yours channel and it's amazing job 💜

  • @smallzebra19
    @smallzebra19 Před 3 lety

    Only 60k?

  • @johnnyxp64
    @johnnyxp64 Před 5 lety +2

    unfortunately many if not 80% of the web devs don't use [put] or [delete] ... but instead they use [post] to achieve those results... 😒😒😒

    • @WebDevSimplified
      @WebDevSimplified  Před 5 lety +1

      That is very true. Hopefully videos like this will help new developers utilize all the HTTP actions.

  • @splitlang
    @splitlang Před 5 lety

    Like 100 thank you

  • @andriibilych4983
    @andriibilych4983 Před 3 lety

    Not gonna lie, I understood that rest has something to do with urls, after that it's like white noise to me, thank you nevertheless

  • @gosnooky
    @gosnooky Před 3 lety

    Updating a resource should use PATCH instead of PUT

  • @bryantgrimminger5481
    @bryantgrimminger5481 Před 5 lety +3

    It's what you get when you sleep.

  • @paoro814
    @paoro814 Před 2 lety

    Rest always been seems complicated to understand.

  • @himbary
    @himbary Před 4 lety

    Why didn't u include patch?

  • @code5829
    @code5829 Před 3 lety

    Recourses self taught backend engineers? Anyone reply to this

  • @hanesmitter1469
    @hanesmitter1469 Před 4 lety

    Patch for updating

  • @darkantoinevs
    @darkantoinevs Před 4 lety

    Even though it is a good overview of HTTP APIs, this is not what REST is about. Roy Fielding himself mentioned that REST is not about CRUD : roy.gbiv.com/untangled/2009/it-is-okay-to-use-post . You do not mention the use of hypermedia to navigate through the API at all.

  • @Runnable19
    @Runnable19 Před 3 lety

    So it's basically CRUD

  • @LLF1234
    @LLF1234 Před 5 lety +3

    Why they don't simply call it CRUD (Create, Read, Update and Delete) operations instead? So much easier to remember and it makes much more sense.

  • @fraterrr6560
    @fraterrr6560 Před 2 lety

    Terrible…. I don’t learn anything, I watched this entire video and I still don’t know what REST is…….

  • @neildutoit5177
    @neildutoit5177 Před 3 lety

    Jeez dude. This entire thing is wrong. Rest says nothing about http. http is one protocol that can be used to implement rest. Rest says nothing about CRUD. CRUD operations can be implemented over REST. So can other operations. The discussion of URLs is irrelevant because REST resources are identified by rels not URLS.. Most importantly, you say nothing about Hypermedia as the Engine of State Transfer, which is fundamental to REST. What you're describing here is a glorified RPC server. Not a REST endpoint.

  • @SuperLukiano
    @SuperLukiano Před 4 lety +1

    What the f...k? I didn't understand a thing. I use PHP and JS and all those methods mentioned above but I wanted to know the background of that fancy REST word and you haven't made it clear at all.