DEV Community

Discussion on: IG Public API - Lessons Learned

Collapse
 
lirantal profile image
Liran Tal

my 2 cents:

A. APIs should definitely use HTTP status codes as part of being RESTful. For example, some times it makes sense to return just 200, but in other cases it makes more sense to return 201 (created), for a POST action for example.

B. Error messages in REST/API applications is indeed a topic that has a lot of confusion but also many do things different, but what's probably considered a standard is that you should always assign and provide an actual error code (i.e: ERR1234) for your errors so your users can easily reference it. If you're generous enough, you can also provide the textual representation of the error ("not enough credits"), or be verbose on what field validations failed for example.