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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay