Alexander Kononenko
Alexander Kononenko

Reputation: 91

Restful api structure

Simply, what's better?

API Methods:

GET videos/getall
GET videos/get?id=1

GET news/getall
GET news/get/?id=1

GET blogs/getall
GET blogs/get?id=1

OR

GET content/getall/?type=videos
GET content/getall/?type=news
GET content/get?id=1&type=blogs

First way isn't look like DRY. But it has some advatanges. So what way is better?

Upvotes: 0

Views: 226

Answers (1)

ioseb
ioseb

Reputation: 16951

All of these URIs are wrong. They include action information(i.e. getall and get) which turns your URIs into regular RPC calls.

You can choose simpler approach:

GET /videos
GET /videos/1

GET /news
GET /news/1

GET /blogs
GET /blogs/1

HTTP GET already means that you are retrieving data.

Upvotes: 1

Related Questions