I have been providing a Web API (.NET MVC 5) of an Oracle Database to people who are making a mobile app. I have to admit that I am not very good at it. I have found that I can easily produce Data Transfer Objects to make very simple JSON displays.
My question is whether it is feasible to ask the mobile developers to make multiple calls to the API to get the data they need. This would be in opposition to me providing a more complex model that provides all the info in ONE call.
As a pure example... if we were dealing with animals, in my API they would need to call both the category (api/categories) and the animal name (api/animals) and link the 2 together depending on their needs:
.....call 1 to category_table
[{
CATEGORY_ID: 1,
CATEGORY_NAME: "Dog"
},
{
CATEGORY_ID: 2,
CATEGORY_NAME: "Cat"
}]
.....call 2 to animal_table
[{
ANIMAL_ID: 1,
CATEGORY_ID: 2,
NAME: Tabby
},
{
ANIMAL_ID: 2,
CATEGORY_ID: 2,
NAME: Lion
},
{
...etc,etc,
}
]
The other option would be to use more complex JSON utilizing arrays so that they only make one call. That I am having some difficulty with. At the moment the APIs are very simple so they may have to call a few APIs. I tried directly using the model that I had created from the DB but ended up with humongous amounts of data being produced (arrays inside arrays inside arrays... etc, etc,). I had to use DTOs but I am having difficulty using arrays.
The question is whether it is feasible to have those developers make multiple calls instead of a more complex JSON response. They will be programming for IOS mobile devices using swift.
In other words I could place an array of each animal into the categories call (it was maybe a simplistic example). I am not talking about putting the category_name in the api/animals... that would be easy! I mean some form of associative arrays.