Skip to main content

A Python Based API RateLimiter

Project description

How to Run

from apirlpy import  ratelimiter as APIRL
#Import the Function

# Checking rate limit for a specific IP
CoolDown=APIRL(IP_Adrs="127.0.0.1", #IP address ofthe Client
#_______________________________________________________________
Cleaning=False, #To Enable the Ip Address  Cleaning 
CleaningFreq=80,# The Frequency at which the cleaning shoudl occur
AutoUpdate=False, #If you want to update the Data only after a certain time to reduce I/O operations
UpdateFreq=70, #(value in sec) of auto update
CooldownTime=20, #Amount of time differnce the Clients last vist shoudld 
# exced for the IP address cleaner to remove the data
#    ***  FOR JSON AND SQL Format only     ***
#If passed to "no stograge" option then this arguments will not be passed to the ratelimiter
#_______________________________________________________________
AllowedFreq=8, #The Number of Fair attempts the Client can send the request to the server
ResetTime=8, # After the Client is denied the access , how much time 
#they need to wait to get the access again 
Filename="Test", # The file name to store the data
Format="sql", # The File extenstion type which the ratelimiter is going to use to store the data
# Extensions available are : sql to use sqllite , json to use json format and "None" for No storage option  
# If nothing is mentioned then the data will not be stored
FolderPath=None # The path at which u want to store this results

)
if CoolDown == 1: #The Client  can  access the API
    print( "You are a Valid user")
else: # the Request is denied 
    print( f"You need to wait {CoolDown}")

**This is a test code **

The Code Return

  • 1 : Means the Client Can Access the API
  • other than 1: Means the Client Need to wait for the access of the API

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apirlpy-0.0.4.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

apirlpy-0.0.4-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file apirlpy-0.0.4.tar.gz.

File metadata

  • Download URL: apirlpy-0.0.4.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for apirlpy-0.0.4.tar.gz
Algorithm Hash digest
SHA256 941f1215ee626a4ea5edbe1cef0b4159a8c97878f01ff1498e3290b3574ccf88
MD5 ea2e5e568ae1d373e161677c06f279ea
BLAKE2b-256 92ffd7303bd644a4d56e978a7d8dc2f48b70ceaecb98846a3fa8c32ed600f0bb

See more details on using hashes here.

File details

Details for the file apirlpy-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: apirlpy-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for apirlpy-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 84406823a950faf3d64aa46f5cc94d88474506f9fd9b6001e7cfb37bd9c474ab
MD5 19c2176422c42b1b6697e8e415d8c3af
BLAKE2b-256 17f5ce05ff67ee4bc83e73fec7ea2b332b344674e696f8e0532432ea52e3a0f4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page