API Rate Limiting using Node.js & Express.js using Express-rate-limit
API Rate Limiting using Node.js & Express.js using Express-rate-limit
#JavaScript, #LearnToCode, #CodingTips, #WebDevelopment, #Frontend, #Fullstack, #Programming, #CodeNewbie
AI Generated·May contain errors
Hello friends, welcome back to the new tutorial of the Node.js. Today we are going to learn about
API rate limiting using the Node.js and the Express. So, those who haven't subscribed my
channel yet, please do subscribe my channel and if you like the video, please do like,
share and comment on my video. Let's get started. So, basically what do you mean by the API rate
limiting with like suppose if one IP has multiple hits to that same API. So, we can limit that like
one user or one IP address can hit maximum to five requests or six requests to that API. So,
we can limit limit that one. Okay. So, this will help you in the security purpose also. So, let's
try to implement that one. So, here we have the code and let's go to our code base and add api
rate limiting.js. So, here I'm going to paste the code and let's try to run. So, we have to install
the package also at the same time. So, here we have the API rate limited. So, I have copied this
at this package and you can see that the it has pretty much downloads on that. Okay. So, weekly.
So, we were going to use that one. So, node api rate limiting. So, it will run on this port and
let's try to send I think the number of requests over here is more I guess. So, here we have Express
Express rate limit then initialize that one define the rate limit middleware with the window ms 15
minutes. So, I'm going to make it one minute. Okay, and limit each IP 200 requests. No five requests
message too many requests from this IP. Please try again later. Okay, apply the rate limiter to
all the requests with the help of this and api.get API data. So, your data. So, this is the API
handling. Okay, or you can you if you want to make it a specified to the like you can see about
the API route handler specific to that one. Then you can create the middleware and then use that
one. Okay. So, here we go with the pay data. So, let's try to go and check this. So, here we go
with this and it is already start. I think we have changed something. Okay. So, we have to go with
this and let's try to maximum five requests, right first what it says cannot get yeah, it's
get request. Okay, try to send first second third fourth fifth and you can see too many requests
from this API. Now, you can see I'm unable to request the API data. So, this is how you can
limit your API with the help of the Express rate limit any doubt in equity in that do let me know
the comment section and rest of the documentation you are getting from here. Okay, so we have used
this one, right? So, any doubt any query do let me know in the comment section. Thank you so much
for watching this video. Have a great day.

