Hello @Aayushi Solanki - Thanks for reaching out to us.
In order for you to fetch cost of all tags, resource groups and services together using API, the best recommendation would be to start with using export details.
And if that doesn't work, the alternative would be to use usage details.
That gives you everything you need, you can group/filter on whatever you need from there.
Hope this helps. and please feel free to reach out if you have any further questions.
------------------------------------------------------------------
If the above response was helpful, please feel free to "Accept as Answer" and "Upvote" the same so it can be beneficial to the community.