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

Generally internal APIs are developed alongside one or two apps. They don't need a pure, resource-oriented, API that perfectly represents the domain models but ignores how the API is used in practice.

A good example is the tip on PUT vs PATCH to update objects. That seems to be missing the point. Why are you forcing the clients to calculate the correct resource fields to PATCH to the server? This is supposed to be an API, not a database. Just expose methods that correspond to the actions that the users will perform.

Sure, HTTP only has 5 verbs, but that doesn't mean your API should solely consist of five possible interactions on a resource.



> Sure, HTTP only has 5 verbs

More like 40.

You can also just like...make up your own verbs, the HTTP police won't arrest you, though this rustles the jimmies of HTTP purists. No guarantees any middleware will support it, and this is probably a bad idea if you actually do this in public apis, it's more so "hey, these verbs aren't magic incantations, it's just a string which gets switch-cased".

Same with HTTP status codes. There's obviously some well known ones but you can just like...make up your own.

https://www.iana.org/assignments/http-methods/http-methods.x...


structured programming and rpc demonstrates you can get pretty far if your only verb is CALL




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

Search: