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.1.0.tar.gz (8.0 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.1.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for apirlpy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cc20aaffab1fe3df2da638c4313ff4b28aa35fabc8e9825b5ac5644b64ca32c9
MD5 a56e044aeba7411ebadca0f7ac60f7dc
BLAKE2b-256 dab113946ec6fe49aa3f3aa05be38abac63d986aec77969d0ceebdba8daf6bcc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: apirlpy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.7 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0dc1dcbb959f1eea815be878ca0c3fab24d7fe794293b5f6adf0a0f5f1835399
MD5 2be50d2978dd7dcb2f7595217f01930d
BLAKE2b-256 db16090195735f7e71e826c23bcc773edca4d29d226031b5542ef39c64833c69

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