Should a single API call handle everything to make life of frontend easy, or there be as many apis as needed [closed]

So I face this issue often. Apart from being a backend python dev, I also have to handle a team consisting of frontend guys as well.

We are into SPAs, and a single page of ours sometime contain a lot of information. My APIs also control the UI on the frontend part. For example, a single could contain.

  1. Order Detail

  2. Buttons that will be displayed based on role. like a staff can only see the order, whereas a supervisor can modify it. And like this sometime there are even 10 of such buttons.

  3. Order metadata. Like a staff will only see the order date and quantity whereas manager can also see unit and sale cost.

  4. Also, let's say there is something like order_assigned_to, then in that case I will also send a list of eligible users to which order can be assigned. (In this particular case, i can also make one more API "get-eligible-users/<order_id>/". But which one is preferred.

Somehow, my frontend guys don't like many APIs, I myself has not worked that much with next, react. So, I do what they ask me for.

Generally what is preferred ? My APIs are very tightly coupled , do we take care of coupling in APIs as well. Which I guess we should, what is generally the middle ground.

After inspecting many APIs, I have seen that many control the UI through APIs.

I don't think, writing all the role based rules in frontend will be wise, because then it's code duplication.

Вернуться на верх