Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I find the "/actions" slug a bit goofy and unnecessary. Why not just put it at e.g. "/repositories/1/archive"? Additionally, why not maintain restful semantics by using PUT (or more likely, PATCH) instead of POST (which implies creating a new resource)? And "/customers/1/actions/credit-score-with-bank-of-xyz" sounds a lot like a GET request.


Because there could be related resources, e.g. "/repositories/1/users", or "/users/1/comments".

I agree it's not necessary, but having /actions just makes it more clear. For example:

"/repositories/1/bans" shows me all bans

"/repositories/1/ban" ban action

I know it's a bad example, but you could end up with other similar related resource and action names that could increase chances of silly mistakes.


I agree about /actions, it is unnecessary. However, for these kinds of "action resources", POST is definitely the best-matching request method. It does not mean "create a resource" (although this is one case it is often used for), but "process this request in your custom resource-specific way". The HTTP RFC formulates it like this [1]:

> The POST method requests that the target resource process the representation enclosed in the request according to the resource's own specific semantics.

Given that what an action resource does is, by definition, resource-specific, POST fits perfectly.

[1]: https://tools.ietf.org/html/rfc7231#section-4.3.3




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: