API restriction

Are there best practices for storing / restricting API usage? I am looking to create a basic API using Laravel, but trying to think about limiting the daily use of the API, I focus on the best approach.

I register every call in the database and use it to aggregate common API calls per day to determine if the limit has been reached? What about concurrent API requests? If I want to limit 1 API call every 5 seconds, is it better to query the database and determine this?

Any advice would be highly appreciated!

+6
source share
1 answer

This is one of those things that I like to leave for an existing provider.

To keep things simple, put something in front of your API that is solely responsible for speed limits and consumer control of the API. This is often done with some API proxy.

3scale is a good solution. It is efficient Nginx with a module to perform all the heavy lifting. http://www.3scale.net/ It's also cheap (or free, depending on your load).

There are others, such as Mashery, but to be honest, I had terrible luck with Mashery since Intel bought them. DNS resolution issues, high prices, etc.

+3
source

Source: https://habr.com/ru/post/988622/


All Articles