Is there a way to fix this - {"error":"Your handler script took too long to execute. The handler script must execute in under 30 seconds"}

The API is taking too long to return the results and I’m getting this error where I am trying to generate 1 or 100 records.

{“error”:“Your handler script took too long to execute. The handler script must execute in under 30 seconds”}