News for hackers. Stuff that matters.
Re:How to Design Better APIs by pmontra on Saturday March 12, 2022 @04:47AM (#30650279)
I used some API recently that returns URLs in the response body. It's really useful because they maintain those URLs and we don't have to rewrite our URL building code whenever the server side rules change. Actually we don't even have to write that code. It saves time, bugs, money.

I don't remember which API was that, I'll update the comment if I do.

Re:How to Design Better APIs by berkes on Saturday March 12, 2022 @07:28AM (#30650917)
Better yet, those URLs communicate what you may do.

Instead of building the logic to determine if, say, a Payment can be cancelled, based on its attributes, you simply check 'is the cancel link there'.

I find this a critical feature. Because between the backend, and various mobile clients, react, some admin, and several versions thereof, clients will implement such businesslogic wrong. Much better to make the backend responsible for communicating abilities. Because that backend has to do this anyway already.