What is the best practice for REST API call from and device (Android, iOS). I am getting extra parameters/fields in JSON response, while calling an API. Throughout the the application there are several API which contains extra params in it.

Should I ignore the extra params or I rectify my API for less needed fields. Which should be right? What should be the best practice?


If you're the designer of the API in question, why did you design it to include these "extra params"? Maybe they are needed elsewhere, but in your new code you just need a subset of the returned data? We don't know.

JSON is a very dynamic format so even if you get a hundred extra fields it doesn't matter (except maybe for the additional time for parsing more data), as long as you get the ones you need.

I'll give you an example. Imagine that you're writing a small program to display the temperature outside. You have a thermometer that does not have any display but you're able to get a JSON response from it, in the following format:

    "temperatureCelcius": 24.0,
    "isWeatherNice": true,
    "canYouGoSkiing": false,

You don't need the isWeatherNice and canYouGoSkiing fields, but their presence will not cause your application to break.

With that information, I say ignore the extra fields. You may not need them, but probably other people do and the API has to accommodate their needs too, not only yours.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.