How can i count the requests to not pass API limit?

My code has just one get and one post request but it is reaching the 5000 request api limit in between 30th and 35th loop. How can I count and how I decrease request usage?