@Chandra Reddy, Pathapati Venkata Umesh (Cognizant) Query API should be able to solve your needs: Query - REST API (Azure Cost Management) | Microsoft Learn
You can groupby and /or filter on specific services and resources.
However, there is a strict rate limit on the Query API. Functionally speaking, the Query API definitely can do that, but doing multiple calls on the same subscription and filter on different values like Tags / Service Name, etc. And by doing that, you hit a lot of entity and tenant rate limit.
For your scenario, you may do something like a loop through all the service names and call the Query API to filter the cost by the service name and get the desired data you are looking for.
In that way, I doubt you will accept to add 30 seconds wait time between each call since that will cause the script to run much longer time.
Recommended for your scenario:
Can you evaluate CostDetails API - Generate Cost Details Report - Create Operation - REST API (Azure Cost Management) | Microsoft Learn ?
You can get resource costs for all resources under the subscription and can do any client-side filtering.
For the information on the fields:
Understand usage details fields - Microsoft Cost Management | Microsoft Learn
Hope this helps. Let us know if you need any further assistance.
If the response helped, do "Accept Answer" and up-vote it