This package is used to handl redis persistence
Project description
Installation
Install the package from PyPi with pip3 install redisgetapi
.
Usage
The redis-get-api package comes handy when you want to use api endpoints that have restricted rate limits. It does
exactly that by enforcing rate limits while preserving persistence in the local redis database for the required time limit.
For instance if you are building upon twitter, and you intend to search tweets, you are only allowed say 450 requests within any
15 minutes (900 seconds) interval. This package will fetch the first result and cache it for the next 15 minutes when you are not allowed to hit the twitter API
directly.
Requirements and parameters
You must install redis to use this application. You can use the application as a commandline interface for testing purposes, or within your scipt. The default parameters for redis host and port are 'localhost' and 6379 respectively. The other parameters are
the url to be fetched and the expiry in seconds.
Specific use case
Let the parameters be:
url = 'http://some/url/with/{your_api_key}/and/some/end_point/'
port = 6379 # unless you have your redis-server in a different port, this is the default
host = localhost
expiry = 300 # this is 5 minutes in seconds
Call the application as follows
from redisgetapi.fetch import RedisEndPoint, cli_call, script_call # there are more functions there
Then you can define the function in your script as follows:
def NgrokUrl(url,host,port,expire):
return script_call(url,host,port,expire)
print(NgrokUrl(url,host,port,expire))
NB: The default variable in which redisgetapi is holding the response is 'res'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for redisgetapi-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd6487d8722841b38a28488c8747e9df765d5c16f92852251c4c1411479bf0a7 |
|
MD5 | fc0cab0be34bc6ed80fd9cf51a1f671c |
|
BLAKE2b-256 | 295866a712394f006a5cfe63967c7f1a057e6390084442ca6f46862be58cd81a |