Unless there is a better way already in place (If so, I'd be interested to know how), this PR would allow the user to have more control on the requests session: caching, rate limiter etc...
from pyrate_limiter import Duration, RequestRate, Limiter
from requests_ratelimiter import LimiterMixin, SQLiteBucket
from requests_cache import CacheMixin, SQLiteCache
from requests import Session
class CachedLimiterSession(CacheMixin, LimiterMixin, Session):
pass
session = CachedLimiterSession(
limiter=Limiter(
RequestRate(8, Duration.MINUTE), RequestRate(800, Duration.DAY)
),
expire_after=timedelta(hours=48),
bucket_class=SQLiteBucket,
backend=SQLiteCache(".cache/requests.db"),
)
twelve_data_client = TDClient(apikey=TWELVEDATA_KEY)
twelve_data_client.ctx.http_client.session = session
Unless there is a better way already in place (If so, I'd be interested to know how), this PR would allow the user to have more control on the requests session: caching, rate limiter etc...