import requests
import time


def get_from_bgg(api_url, parameters):
    """Successively attempts to get data from BGG given an API"""
    response = requests.get(api_url, params=parameters)
    # Retry if return codes indicate "too many requests"
    while response.status_code == 202 or response.status_code == 429:
        time.sleep(2)
        response = requests.get(api_url, params=parameters)
    return response