flying227
flying227

Reputation: 1321

Correct REST URI Syntax

I've seen some people say that this is the only way to do REST:

/car

Displays all cars

/car/123

Displays information about the car with ID of 123

I have also seen others that prefer to do this with REST:

/car

Displays all cars

/car?id=123

Displays information about the car with ID of 123

Which is correct for REST?

Please note that I am only posting this question to get a real answer, I am not trolling. If REST is not defined enough for a definitive answer, or it is not clear which option above is "correct" for REST, then that would be a fine answer for me. I am simply trying to understand REST.

Thank you.

Upvotes: 3

Views: 6639

Answers (1)

jbeale
jbeale

Reputation: 78

REST was originally designed based on a purely path-driven architecture, although different implementations of REST APIs in software like Flickr and JIRA have clouded this a bit. In the end what is most important is that the standards used within the entirety of your own API are consistent (i.e. don't use /api/user/21 for getting a user and then /api/group?id=3 for another). Ideally, use paths to locate a resource and then use different HTTP verbs to determine what you're doing with that resource (GETing it, POSTing a new one, PUTting an update, etc).

Wikipedia has a very informative article on it.. http://en.wikipedia.org/wiki/Representational_state_transfer

Upvotes: 3

Related Questions