Skip to contents

Use this function to configure the rate limiting behavior for API requests to prevent 429 errors (too many requests). By default, the package will attempt to make faster requests (5 per second), but will throttle to 1 request every 3 seconds if Error 429 is encountered.

Usage

nassqs_rate_limit(
  rate_seconds = 0.2,
  throttled_rate_seconds = 3,
  override = FALSE,
  reset_throttling = FALSE
)

Arguments

rate_seconds

The minimum time in seconds between API requests. Default is 0.2 seconds (5 requests per second).

throttled_rate_seconds

The time to wait between requests when throttled. Default is 3 seconds.

override

Whether to override the rate limiting. Default is FALSE. Only set to TRUE for testing or when you know you won't exceed API limits.

reset_throttling

Whether to reset the throttling state to normal speed. Default is FALSE.

Value

Invisibly returns the previous settings as a list.

Examples

# Set custom rate limits
nassqs_rate_limit(rate_seconds = 0.5, throttled_rate_seconds = 1)

# Reset to normal speed after being throttled
nassqs_rate_limit(reset_throttling = TRUE)

# Disable rate limiting (not recommended for production use)
nassqs_rate_limit(override = TRUE)

# Restore default settings
nassqs_rate_limit(rate_seconds = 0.2, throttled_rate_seconds = 3, override = FALSE)