Questions tagged [rest]

REST (Representational State Transfer) is a style of software architecture for distributed hypermedia systems such as the World Wide Web. It has increased in popularity relative to RPC architectures such as SOAP due to the intrinsic de-coupling of client from server that comes from having a uniform interface between heterogeneous systems.

(Not to be confused with or reST)

REST (REpresentational State Transfer) is an architectural style that uses identification of resources; manipulation of resources through representations; self-descriptive messages, and hypermedia as the engine of application state, to build distributed systems that are scalable and resilient to change.

The term was introduced and defined in 2000 by Roy Fielding in his doctoral dissertation. Fielding is one of the principal authors of the Hypertext Transfer Protocol (HTTP) specification versions 1.0 and 1.1.

In simple language, REST is an alternative to SOAP based web services. Where SOAP tries to model the exchange between client and server as calls to objects, REST tries to be faithful to the web domain.

Resources


Examples

A website's RESTful API is queried to find out information on a user, specified by a numerical ID.

Request Type: GET
http://www.api.website.com/users/12345

Returns, in a format for this example:

{"username" : "theuser",
 "userid"   :  12345,
 "first"    : "George",
 "last"     : "Washington"}

Question Index

Searching

REST search interface and the idempotency of GET
RESTful URL design for search
Best practice for implementing long-running searches with REST
Querystring in REST Resource url
What is the best way to create RESTful complex queries?
Question on REST conventions: retrieving information where lots of params are needed

Resource Design

How to design a RESTful collection resource?
RESTful design of a resource with binary states
RESTFful/Resource Oriented Design
RESTful resource - accepts a list of objects
RESTful API creates a globally unique resource
REST's 'resource communication mechanisms' and 'on-the-fly' improvement of a client's knowledge of them
How to move a REST resource?

Media Types

REST Media type explosion
Creating hypermedia links in a custom media-type
Custom content types: XLink vs. Atom

Books

Related tags

92665 questions
787
votes
27 answers

Should I use Singular or Plural name convention for REST resources?

Some RESTful services use different resource URIs for update/get/delete and Create. Such as Create - using /resources with POST method (observe plural) at some places using /resource (singular) Update - using /resource/123 with PUT method Get -…
JPReddy
  • 63,233
  • 16
  • 64
  • 93
734
votes
14 answers

Representational state transfer (REST) and Simple Object Access Protocol (SOAP)

Can somebody explain what is REST and what is SOAP in plain english? And how Web Services work?
Vicky
  • 11,077
  • 11
  • 35
  • 29
724
votes
9 answers

Hyphen, underscore, or camelCase as word delimiter in URIs?

I'm designing an HTTP-based API for an intranet app. I realize it's a pretty small concern in the grand scheme of things, but: should I use hyphens, underscores, or camelCase to delimit words in the URIs? Here are my initial…
Josh Johnson
  • 8,832
  • 4
  • 25
  • 31
675
votes
16 answers

What's the difference between REST & RESTful

What's the difference between a REST system and a system that is RESTful? From a few things I've read most so called REST services are actually RESTful services. So what is the difference between the two.
AwkwardCoder
  • 24,893
  • 27
  • 82
  • 152
657
votes
12 answers

What are REST API error handling best practices?

I'm looking for guidance on good practices when it comes to return errors from a REST API. I'm working on a new API so I can take it any direction right now. My content type is XML at the moment, but I plan to support JSON in future. I am now adding…
Remus Rusanu
  • 288,378
  • 40
  • 442
  • 569
641
votes
10 answers

Understanding REST: Verbs, error codes, and authentication

I am looking for a way to wrap APIs around default functions in my PHP-based web applications, databases and CMSs. I have looked around and found several "skeleton" frameworks. In addition to the answers in my question, there is Tonic, a REST…
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
630
votes
15 answers

If REST applications are supposed to be stateless, how do you manage sessions?

I'm in need of some clarification. I've been reading about REST, and building RESTful applications. According to wikipedia, REST itself is defined to be Representational State Transfer. I therefore don't understand all this stateless gobbledeygook…
Zak
  • 24,947
  • 11
  • 38
  • 68
628
votes
7 answers

HTTP POST with URL query parameters -- good idea or not?

I'm designing an API to go over HTTP and I am wondering if using the HTTP POST command, but with URL query parameters only and no request body, is a good way to go. Considerations: "Good Web design" requires non-idempotent actions to be sent via…
Steven Huwig
  • 20,015
  • 9
  • 55
  • 79
621
votes
18 answers

Capturing URL parameters in request.GET

I am currently defining regular expressions in order to capture parameters in a URL, as described in the tutorial. How do I access parameters from the URL as part the HttpRequest object? My HttpRequest.GET currently returns an empty QueryDict…
sutee
  • 12,568
  • 13
  • 49
  • 61
588
votes
5 answers

What's the difference between text/xml vs application/xml for webservice response

This is more of a general question about the difference between text/xml and application/xml. I am fairly new to writing webservices (REST - Jersey). I have been producing application/xml since it is what shows up in most tutorials / code examples…
Mike
  • 8,137
  • 6
  • 28
  • 46
585
votes
10 answers

Logout: GET or POST?

This question is not about when to use GET or POST in general; it is about which is the recommended one for handling logging out of a web application. I have found plenty of information on the differences between GET and POST in the general sense,…
Daniel Liuzzi
  • 16,807
  • 8
  • 52
  • 57
569
votes
7 answers

How to design RESTful search/filtering?

I'm currently designing and implementing a RESTful API in PHP. However, I have been unsuccessful implementing my initial design. GET /users # list of users GET /user/1 # get user with id 1 POST /user # create new user PUT /user/1 # modify user with…
Erik B
  • 40,889
  • 25
  • 119
  • 135
568
votes
14 answers

Should a RESTful 'PUT' operation return something....

I was wondering what people's opinions are of a RESTful PUT operation that returns nothing (null) in the response body.
AwkwardCoder
  • 24,893
  • 27
  • 82
  • 152
557
votes
9 answers

Do sessions really violate RESTfulness?

Is using sessions in a RESTful API really violating RESTfulness? I have seen many opinions going either direction, but I'm not convinced that sessions are RESTless. From my point of view: authentication is not prohibited for RESTfulness (otherwise…
deceze
  • 510,633
  • 85
  • 743
  • 889
541
votes
29 answers

What is the proper REST response code for a valid request but an empty data?

For example you run a GET request for users/9 but there is no user with id #9. Which is the best response code? 200 OK 202 Accepted 204 No Content 400 Bad Request 404 Not Found
IMB
  • 15,163
  • 19
  • 82
  • 140