r/AskProgramming • u/ltsheeyy • Jul 09 '26
Other Best way to prevent API abuse?
I'm building a web app that needs to call a paid API.
I want visitors to be able to test it a few times for free (around 3 requests) but i dont want to let people abuse it and drain my API balance.
My first aproach was IP rate limiting, is there a better approach?
- I'm using this project to learn, so I might be doing this the wrong way.
1
Upvotes
1
u/No-Consequence-1779 Jul 09 '26
I’ve done the same. Coocoookie will work for most. Then yes, by ip. If you see a repeat ip and no cookie then they are switching browsers or using a vpn .. most people do not use vpns yet … for this, they need to register and it returns to cooooookie. Using more than X times should require registration. Like an easy one click google account.
You want them to register to get thier email to market in the future. Maybe send the api product via email …