[SOLVED] Evm_api filter in get_nft_contract_transfers not working (python SDK)

Support,

Regarding the documentation https://docs.moralis.io/reference/getnftcontracttransfers, it seems we can use parameters from_date and to_date but it seems they are not included in the moralis API module in python.

I made some changes in the code to debug. You can find the code and the output

def get_nft_contract_transfers(api_key: str, params: typing.Union[RequestQueryParams, RequestPathParams]):
    api_instance = get_api_instance(api_key)
    query_params = {k: v for k, v in params.items() if k in RequestQueryParams.__annotations__.keys()}
    path_params = {k: v for k, v in params.items() if k in RequestPathParams.__annotations__.keys()}

    print(params)
    print("===== DEBUG =====")
    print(RequestQueryParams.__annotations__.keys())
    print(RequestPathParams.__annotations__.keys())
    print("===== DEBUG =====")
    print(query_params)
    print(path_params)

    api_response = api_instance.get_nft_contract_transfers(
        query_params=query_params,
        path_params=path_params,
        accept_content_types='application/json; charset=utf-8',
        skip_deserialization=True
    )

    return json.loads(api_response.response.data)

And the output

{'address': '0xf34b2632cdf132170e30f4e60327645127012f77', 'chain': 'polygon', 'format': 'decimal', 'from_date': '2022-10-01', 'to_date': '2022-12-31'}
===== DEBUG =====
dict_keys(['chain', 'format', 'limit', 'cursor'])
dict_keys(['address'])
===== DEBUG =====
{'chain': 'polygon', 'format': 'decimal'}
{'address': '0xf34b2632cdf132170e30f4e60327645127012f77'}

it works with your changes?

My changes only display the values but it doesn’t take in account from_date and to_date as none of RequestQueryParams and RequestPathParams contain both value

can you use to_block and from_block?

to_block and from_block aren’t in the RequestQueryParams and RequestPathParams too :confused:

it looks like it is a new addition from less than 1 day, you tried with latest version of the sdk?

The problem is how can I convert a start/end date to start/end block?

there is a separate api function that can make that conversion, date to block

Ok found it: https://docs.moralis.io/reference/getdatetoblock
BTW the requests works so I might stand with it whilst the filter will be added

Thx man :slight_smile:

1 Like