2
Personally I would prefer both to be present in the API response, something like:
{"author": [1,3,4], "title": "my book", "cat_id": 1, "cat_name": "Sci-Fi"}
reason being, just the id doesn’t impart much information by itself about the category, and the name is something variable in the future, so that alone doesn’t help either.
Of course, with both present, we can specify in the documentation that the cat_name
is for cosmetic purpose, while the cat_id
is what will remain same.
Source:stackexchange.com