update_call_tracker: Manage API calls in last 10 seconds

Description Usage Arguments Details Value

Description

Manages list of all API calls made in the last 10 seconds. If no tracker is provided, a new one is returned. If an already existing tracker is passed as an argument to the function, the function will add a new call to it, then remove all items with a timestamp > 10 seconds from current system time.

Usage

1

Arguments

tracker

Currently tracked calls

Details

The SCB API limits calls to 10 per 10 seconds (rolling). If this number is exceeded, GET returns a 429 response. We could use Sys.sleep with time set to 10 seconds when this occurs, to reset the counter, but this would be inefficient: since the limit is rolling, we should only wait until the oldest call is > 10 seconds in the past, and then attempt a new query. This is what this function facilitates.

Value

data.frame containing currently tracked calls


olhmr/rscb documentation built on May 15, 2019, 10:40 p.m.