Hi @Pooja Wandile - There is no easy way to do this natively. There's an open suggestion for it here:
The easiest way is to get scriptrunner which has this function built in.
If you want to go about it through the API, you'd have to make a series of calls to get the data you need, store it in a data warehouse and query it. You're better off hitting the database directly.