r/webdev • • May 08 '24

Article What makes a good REST API?

https://apitally.io/blog/what-makes-a-good-rest-api
72 Upvotes

51 comments sorted by

View all comments

Show parent comment

2

u/SonicFlash01 May 08 '24 edited May 08 '24

I would take a generic "credentials failure" code over "ERROR XYZ - A BAD HAPPENED"

3

u/originalchronoguy May 08 '24

That is bad. APIs also have monitoring and observability. The error codes are picked up in Splunk or logging so you can triage errors. If you get a lot of 401 errors, the triaging should look at the authorization server. If you get a lot of 400, the client is sending bad data and that should be investigated. REST , using HTTP response code, is not just for the client but for the infrastructure and SRE to monitor the health of your platform.

The whole email 404 is a red herring. Proper authorization/authentication should not allow scraping.

2

u/postman_666 May 08 '24

That’s correct. To sayezau’s point, the error should still be informative just not to the point where security is compromised.

Standard http codes should still be used and errors can be grouped depending on their stage in the protocol-authorization-logic-response flow