tomasbasham / ratelimit

API Rate Limit Decorator
MIT License
768 stars 159 forks source link

Does not work for me #60

Open mikklaos opened 1 year ago

mikklaos commented 1 year ago

When calling the function, it throws the exception and dies. What I am doing wrong?


@on_exception(expo, RateLimitException, max_tries=8)
@limits(calls=15, period=300)
def mint_nft_to_address(cust_address):
    global contract_address
    assert contract_address, "Unable to mint. Empty contract address given"
    assert cust_address, "Unable to mint. Empty customer address given"
    assert metadata_directory_ipfs_uri, "Unable to mint. Empty metadata directory url given"
    url = "https://api.nftport.xyz/v0/mints/customizable"

    payload = {
        "chain": "polygon",
        "contract_address": contract_address,
        "metadata_uri": metadata_directory_ipfs_uri + "/1",
        "mint_to_address": cust_address
    }
    headers = {
        "Content-Type": "application/json",
        "Authorization": API_KEY
    }

    response = requests.post(url, json=payload, headers=headers)

    if response.status_code != 200:
        raise Exception('API response: {}'.format(response.status_code))
    print(response.text)
    return response