question

ThiagoLunardi avatar image
0 Votes"
ThiagoLunardi asked TariqAhmed-6428 answered

What is a RESTful service?

What's the difference between REST and RESTful service?

How are they useful?

Is it an architecture pattern or application style?

not-supported
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ThiagoLunardi avatar image
1 Vote"
ThiagoLunardi answered ThiagoLunardi published

REST


According to Wikipedia:

It is thought of how an image of the application design will behave.

That is, it would be something like, depending on how you consume the same feature - a feature that can be visually identified inclusive - your behavior will change.

Let's illustrate to facilitate:

About HTTP Requests


Every time we access something via browser, multiple requests are triggered. When you access any page, a request for the content of that page is created. When this content returns, the browser mounts (renders)the page, but this page requires other features such as images, fonts, stylesheets (css). For each feature, the browser will make a new request.

These requests are composed mainly of three information:

  • URL: Address that will receive the request;

  • Verb/Method: Command that is desired to be made;

  • Body: Information we send, such as data from a form, for example.

As many as the Verbs, there are 4 that are the most used:

  • GET: Used to bring information

  • POST: To create/add information

  • PUT: To tulize information

  • DELETE: To delete information

RESTful Service


They are services that have REST behavior. That is, using the same design, your behavior will change according to the way it is consumed

For example, we have the URL(endpoint)below:

http://www.contoso.com/students


If we want to bring the list of students, just make a request: GET


 Request:
 [GET] http://www.contoso.com/students
 Body: empty

The answer will be something like:

 Response:
 HTTP Code 200 OK
 [
     { id: 1, nome: "Thiago Lunardi" },
     { id: 2, nome: "Joe Satriani"}
 ]

But if I want to add a new student, I use the same design, but consuming otherwise, with a request: POST

 Request:
 [POST] http://www.contoso.com/students
 Body: { "nome: "Slash" }
    
 HTTP Code 201 Created
 { id: 3, nome: "Slash" }


Continuing, to learn more about a student:


 Request:
 [GET] http://www.contoso.com/students/1
 Body: empty
    
 Response:
 HTTP Code 200 OK
 { 
     id: 1, 
     nome: "Thiago Lunardi",
     github: "https://github.com/ThiagoLunardi",
     website: "http://thiagolunardi.net",
     blog: "https://medium.com/@thiagolunardi",
 }

To update one-year information, in the same way, we use the same design, and we just change the way we consume the resource, and it will behave differently:

 Request:
 [PUT] http://www.contoso.com/alunos/1
 Body: { "twitter": "@thiagolunardi13" }
    
 Response:
 HTTP Code 200 OK
 { 
     id: 1, 
     nome: "Thiago Lunardi",
     github: "https://github.com/ThiagoLunardi",
     website: "http://thiagolunardi.net",
     blog: "https://medium.com/@thiagolunardi",
     twitter: "@thiagolunardi13"
 }

To delete:

 Request:
 [DELETE] http://www.contoso.com/alunos/1
 Body: empty
    
 Response:
 HTTP Code 204 No Content

PS: Translated from StackOverflow.



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ThiagoLunardi avatar image
0 Votes"
ThiagoLunardi answered ThiagoLunardi published

REST


According to Wikipedia:

It is thought of as a image of the application design will behave.

That is, it would be something like, depending on how you consume the same feature - a feature that can be visually identified inclusive - your behavior will change.

Let's illustrate to facilitate:

About HTTP Requests


Every time we access something via browser (browser), several requisitions are triggered. When you access any page, a request for the content of that page is created. When this content returns, browser mounts (render) the page, but this page requires other features such as images, fonts, style sheets (css). For each feature, the browser will make a new request.

These requests are composed mainly of three information:

  • URL: Address that will receive the request;

  • Verb/Method: Command that is desired to be made;

  • Body: Information we send, such as data from a form, for example.

As many as the Verbs, there are 4 that are the most used:

  • GET: Used to bring information

  • POST: To create/add information

  • PUT: To store information

  • DELETE: To delete information

RESTful Service


They are services that have REST behavior. That is, using the same design, your behavior will change according to the way it is consumed

For example, we have the URL (endpoint) below:

http://www.contoso.com/students


If we want to bring the list of students, just make a request GET:

 Request:
 [GET] http://www.contoso.com/students
 Body: empty

The answer will be something like:

 Response:
 HTTP Code 200 OK
 [
     { id: 1, name: "Thiago Lunardi" },
     { id: 2, name: "Joe Satriani"}
 ]

But if I want to add a new student, I use the same design, but consuming otherwise, with POST request:

 Request:
 [POST] http://www.contoso.com/students
 Body: { "name: "Slash" }
    
 HTTP Code 201 Created
 { id: 3, name: "Slash" }

Continuing, to learn more about a student:

 Request:
 [GET] http://www.contoso.com/students/1
 Body: empty
    
 Response:
 HTTP Code 200 OK
 {
     id: 1,
     name: "Thiago Lunardi",
     github: "https://github.com/ThiagoLunardi",
     website: "http://thiagolunardi.net",
     blog: "https://medium.com/@thiagolunardi",
 }

To update one-year information, in the same way, we use the same design, and we just change the way we consume the resource, now using PUT, and it will behave differently:

 Request:
 [PUT] http://www.contoso.com/alunos/1
 Body: { "twitter": "@thiagolunardi13" }
    
 Response:
 HTTP Code 200 OK
 {
     id: 1,
     name: "Thiago Lunardi",
     github: "https://github.com/ThiagoLunardi",
     website: "http://thiagolunardi.net",
     blog: "https://medium.com/@thiagolunardi",
     twitter: "@thiagolunardi13"
 }

To delete, using the DELETE:

 Request:
 [DELETE] http://www.contoso.com/alunos/1
 Body: empty

 Response:
 HTTP Code 204 No Content

Translated from StackOverflow.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RobertHorvick-0990 avatar image
2 Votes"
RobertHorvick-0990 answered RobertHorvick-0990 published

"Web services that conform to the REST architectural style" are called "RESTful Web services". So when you ask what the difference is the answer is that it's just a syntax difference.

You could say:

"I wrote a web service that conforms to the REST architectural style"

Or you could say:

"I wrote a RESTful web service"

And they mean the same thing.

Is REST useful? Sure. It's proven itself to be pretty useful. It's not the only option but it's a popular one.



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

davidhollowell avatar image
2 Votes"
davidhollowell answered

Hi ThiagoLunardi,
I hope you're doing well. There's no difference between REST and RESTful. If a service follows REST principles it is said to be a RESTful service. See https://docs.microsoft.com/en-us/azure/architecture/best-practices/api-design for more information about REST principles.



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

EricGruss avatar image
3 Votes"
EricGruss answered

A RESTful service is an implementation that follows the patterns of REST. GET, POST, UPDATE, DELETE.
If you are using a POST statement to do a delete, I would not call it RESTful even though it is a REST endpoint.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

KennethOrwigIII-6138 avatar image
0 Votes"
KennethOrwigIII-6138 answered KennethOrwigIII-6138 published

Hi @ThiagoLunardi

There is no technical difference between the terms – you may as well have asked about “Color” vs. “Colorful”.

REST is an architectural style with well defined constraints. That is, if your system does not conform to them, then it is not a RESTful system.

Here are the constraints:

• Statelessness – session-state is maintained by the client and the server never stores any client context between requests.

• Uniform Interface – ultimately, clients should be able to enter, understand, and use a RESTful system knowing nothing more than the entry point.

• Client-Server Architecture – This shouldn’t really need much explanation: decoupling a UI from the application and storage allows for simpler interactions and reusability of component application segments.

• Cacheability – Can be implemented on the client or server side and must be declared in every case.

• Layered System – APIs may be deployed to one server although the processing, storage, authentication, and other concerns may happen elsewhere.

• OPTIONAL: code on demand – when returning static representations pf resources in JSON or XML won’t do, just go ahead and return executable code – you are allowed.

Here are a few other useful points:

• REST is often compared to SOAP but this is like comparing apples to oranges. SOAP is a protocol – REST is not.

• REST is protocol independent. We often use it with HTTP but we could just as easily use a different protocol for a different purpose.

• A good understanding of hypermedia and HATEOAS is crucial to getting the Uniform Interface constraint satisfied effectively.

• No one is going to grade you on how well your system conforms to REST and occasional deviations are encountered in even the most sophisticated systems. Just know that the closer you get to pure REST, the longer you can expect your application to remain relevant to your organization.

Hope this helps!

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TariqAhmed-6428 avatar image
0 Votes"
TariqAhmed-6428 answered

REST is a client-server architecture which (among other things) leverages the full capacity of the HTTP protocol.

Some relevant points in REST:

Each URL on the server represents a resource; either a collection resource or an element resource.
A collection resource would be available at a URL like http://restful.ex/items/ which would be a representation of a list of items.
A element resource would be available at a URL like http://restful.ex/items/2 which would be a representation of a single item, identified by 2.
Different HTTP methods are used for different CRUD operations:
a GET is a read operation
a PUT is a write/modify operation
a POST is a create/new operation
a DELETE is a... ok, that one is kind of self-explanatory.
State (or rather, client context) is not stored on the server-side; all state is in the representations passed back and forth by the client's requests and the server's responses.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.