SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,777
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    What is RESTful??

    Can someone explain to me - in plain terms - what "RESTful" is??

    (I looked online and my eyes glazed over after the first paragraph...)

    Thanks,


    Debbie

  2. #2
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,633
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    The short, short, short version would be "embracing HTTP as a messaging layer." Beyond that it means lots of different things to different people. Perhaps you've got a more pointed question here . . .

  3. #3
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,777
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by wwb_99 View Post
    The short, short, short version would be "embracing HTTP as a messaging layer." Beyond that it means lots of different things to different people. Perhaps you've got a more pointed question here . . .
    I was looking for Streaming Video Web Hosts and I saw that term a couple of times...

    I've heard developers at work use it too.

    Never really knew what it meant, and was hoping to get a better understanding so when it comes up again I'll know what it is.


    Debbie

  4. #4
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    Usually it's a type of web service or API, which you can interface with to get data from external systems into your system.

    RESTful is opposed to something like SOAP. They're both usually web services, but they work differently. The big key with RESTful web services is they are "stateless", which means each transaction between it is a complete entity all on it's own. (As opposed to SOAP where you may do something like login, then have a persisting connection).

    The other big thing is it usually uses the HTTP layer as it's meant to be used. A lot of APIs have you do something like get your info from a URL:
    Code:
    api.php?info=books&name=fun&page=10
    A RESTful API would have you put this as a URL usually
    Code:
    api/books/fun/10
    Which translates into a HTTP GET request:
    Code:
    HTTP 1.1 GET /api/books/fun/10
    That's not much different. But say you want to create a new user. A non-RESTful API may have you do something like:
    Code:
    makeuser.php?name=bob&password=tooth
    which translates to:
    Code:
    HTTP 1.1 GET /makeuser.php?name=bob&password=tooth
    However, that's not using HTTP GET properly, since GET should only get info and never change it.

    A proper RESTful API would likely have you use PUT instead. Something like:
    Code:
    HTTP 1.1 PUT /makeuser/bob/tooth
    Making proper use of the HTTP protocol.

  5. #5
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,777
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    samanime,

    Interesting explanation!

    Thanks,


    Debbie

  6. #6
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,083
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    @samanime ; minor point, but IIRC POST is used to create entities whereas PUT is used for updating existing ones.

    Other than that I completely agree with what you said
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  7. #7
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    Completely correct, thanks for the correction. =p

  8. #8
    SitePoint Wizard
    Join Date
    Apr 2007
    Posts
    1,399
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I've heard of many variations. Some developers suggest that if you're querying or doing any kind of CRUD database operations that RESTful service is the way to go. If you're doing any actions through HTTP, like login/logout/search/verbs than you should use Web Service. Then to make things more confusing, they throw the term RESTful Web Service. Anyways, I look at RESTful service as a nice URL pattern service and nothing more.

    http://horicky.blogspot.com/2009/05/...-patterns.html

  9. #9
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    Here is a great write-up of the various types of web service APIs: http://blog.steveklabnik.com/posts/2...n-api-ontology

  10. #10
    SitePoint Wizard TheRedDevil's Avatar
    Join Date
    Sep 2004
    Location
    Norway
    Posts
    1,196
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ScallioXTX View Post
    @samanime ; minor point, but IIRC POST is used to create entities whereas PUT is used for updating existing ones.

    Other than that I completely agree with what you said
    That is wrong when considering a true REST approach.

    PUT is used both to create and replace entities.

    POST is used to create records under another entity.

    Example:
    -To create/update a user account we would use PUT.
    -To add another chapter to a book we would use POST (in this case book would be an entity already created by PUT).

    That is a very simple example, but I hope it is sufficient to describe the difference.

    Personally I don't like a pure/true REST approach to an API, as it does limit you somewhat in what the API can and cannot do.

    The benefit of a pure REST approach is speed, if you can use this you will see that it is a lot faster than other options if the web server that host the API is configured properly.

    With other words, don't be afraid to go for a "*******" (hybrid) API, taking the best part from the different architecture that is out there.

    EDIT: Well, I guess the "bad word" system is tuned a little too high when it remove valid words like b a s t a r d...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •