DEV Community

VICTOR OMONDI
VICTOR OMONDI

Posted on

API Design Tip

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.

DO NOT 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 (0)