1

say I have a php api like,

api.example.com/request.php?apikey=example123.

In order not to speed up the processes on my hosting site, I just want the user to have 5 consecutive API calls that say they run on multiple tabs. And if they open the Sixth tab for example they get the request blocked. How is this possible? Or is it possible?

Any help or suggestion ?

Bhavik Hirani
  • 1,996
  • 4
  • 28
  • 46
  • 2
    can you show us your best try to achieve this. and one more thing API opening in multiple tabs by code? – Aroon Dec 12 '19 at 04:30
  • You can just maintain daily count of API hit of each user in a db. When count reaches 5, stop serving the page after that – PiNaKa30 Dec 12 '19 at 04:31
  • @PiNaKa30 yes that is also possible but what if the api call was too long and they suddenly closed and that is counted on the sql table, how do I detect the user if they didnt wait for the api to load – Kylie Denesik Dec 12 '19 at 04:49
  • So call your count API in the onload method of page from Javascript. That way you surely know that the page was loaded completely before user closed it – PiNaKa30 Dec 12 '19 at 04:58
  • @PiNaKa30 or if the php has status code of 200, how do I check that if(status == 200) – Kylie Denesik Dec 12 '19 at 05:49
  • 1
    possible duplicate of [https://stackoverflow.com/questions/1375501/how-do-i-throttle-my-sites-api-users?rq=1](https://stackoverflow.com/questions/1375501/how-do-i-throttle-my-sites-api-users?rq=1) – Kagiso Marvin Molekwa Dec 12 '19 at 09:39

0 Answers0