DEV Community

VICTOR OMONDI
VICTOR OMONDI

Posted on

API Design Tip

Please don't keep Important informations as top level object key, cause then the client has to iterate through the object, find the key, relevent to him, at the same time discard the other irrelevant keys and then extract the data.

DONOT PUT IMPORTANT DATA AS OBJECT KEYS

I faced this issue with my AI team, and had to spend a fuckload of time parsing the response

BAD RESPONSE DATA:

{
    "i_am_a_unique_id": 50
}
Enter fullscreen mode Exit fullscreen mode

GOOD RESPONSE DATA

{
    "id": "i_am_a_unique_id",
    count: 50
}
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
decker67 profile image
decker

The first bad data makes no sense, because you never can say: Is it an id or is it a field.