#132 API Analytics and Rate Limiting

api development rails api rate limiting api usage tracking

If you don’t limit your API usage, bad users can DDOS your server.
If you don’t track API usage, how do you know if it is even used?
Apps like Twitter and Shopify have daily or monthly (30-day) API usage limits
In this tutorial we will track API usage per user and add a 30-day max limit of API requests per user.

Learn the best practices from Shopify API and Twitter API!

Episode source code: https://github.com/corsego/132-api-request-tracking-limiting/commit/92812d49c4ff7666850a1b0bf7821143f811f614
Based on this blogpost: https://blog.corsego.com/api-usage-tracking-rest-rate-limiting

0:00 Overview of current API app
2:35 Why Track API usage
3:50 ApiRequest model
4:52 Log ApiRequests
7:10 Limit API requests
11:25 Display API call limit in header
15:27 Track API key usage

Sign in to join the conversation