DEV Community

IG Public API - Lessons Learned

Robert Morschel on May 15, 2017

A few of us built the IG public API in around 6 months, a feat we were all tremendously proud of. But mistakes were made, lessons were learned, bu...
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.

Collapse
 
poooky5 profile image
Pooky

Very nicely written, thank you for that!