DEV Community

Cover image for The biggest mistake you can make when designing an api
Ralf 💥🔥☄️
Ralf 💥🔥☄️

Posted on

The biggest mistake you can make when designing an api

This is just a quick tip for everybody currently designing an api.

I have seen something like that very very often:
Alt Text

Always return something like that instead:
Alt Text

The reason is pretty simple. While you can easily iterate over the object keys in dynamically types languages like javascript, it's not that easily doable in statically typed languages. For example when consuming such an api in c#, you want to serialize the response directly in instances of classes that you already defined. Dynamic keys are the worst for that.

So please please please, never use dynamic keys in an api.

Top comments (0)