Do REST API URLs have to look like this?

Gorge picture Gorge · Oct 30, 2010 · Viewed 53.1k times · Source

Is it true that to implement a RESTful API, one has to implement a URL structure that looks like this

http://example.com/post/
http://example.com/post/123

where the /123 would be used for edit, delete

Another way to ask the question is: can a URL that looks like this be called RESTful?

http://example.com/script.php?method=get_title&blogid=123

Answer

joschi picture joschi · Oct 30, 2010

You don't have to design your URI structure like that. It could also be /some_obscure_string/base64_encoded_title/unique_id. This could also be RESTful, depending on several other factors.

But there are several best practices on how to design URIs in a RESTful web application and being as simple and as human readable as possible is one of them.

Your example http://example.com/script.php?method=get_title&blogid=123 could also be RESTful, but the query parameters indicate that some kind of RPC- or RMI-over-HTTP is used instead.

To sum it up: Don't put too much thought into your URI design. This will come automatically with a good and proper RESTful design of your application.