tidy
tidy

Reputation: 5057

Must a RESTful service always be based on HTTP?

Lots of websites (e.g. twitter, stackexchange) provide RESTful OPEN APIs based on the HTTP protocol. Can I design a RESTful service based on some other protocol (such as raw TCP)?

Upvotes: 14

Views: 5488

Answers (3)

Ross Bush
Ross Bush

Reputation: 15175

If you adhere to the true tenants of the architecture where every operation is ignorant of historical operations you could probably drum up something a bit different. Currently the easy Put, get, post and delete operations lend well to http based service calls.

Upvotes: 1

Aurélien Bénel
Aurélien Bénel

Reputation: 3842

If you look at Roy Fielding's PhD thesis, you'll see that REST is defined in chapter 5, while it's applied to HTTP in chapter 6.

"Representational state transfer" is indeed quite abstract. There's no reason you couldn't apply it to your own adhoc protocol. The aim is to make it stateless, to have safe read methods (that are cacheable), and if possible idempotent write methods.

Upvotes: 5

Dave S.
Dave S.

Reputation: 6419

The short answer is that a RESTful service does generally imply HTTP, but it's not strictly necessary. The wikipedia entry includes a section on implementations outside the web, though it's pretty brief and really only talks about Common Management Information Protocol (CMIP).

Realistically, to most developers, RESTful services operate over HTTP.

You could surely take inspiration from RESTful protocols on the web and build your own similar protocol over raw TCP, but you may well finding yourself implementing it in the language of HTTP. At that point you may want to ask yourself why you didn't just use HTTP in the first place.

Upvotes: 11

Related Questions