Matminer's CompositionToStructureFromMP() not accepting my API key

Hello all,

I am trying to use the CompositionToStructureFromMP() to convert a list of pymatgen compositions in a DataFrame to structures, but the method is not accepting my materialsproject. I even tried using that same key to perform a query using the MPRester which runs fine and works, so I am not sure if I am doing something or could there be some kind of bug.

Below is the code I am using and the error I am getting:

from matminer.featurizers.conversions import CompositionToStructureFromMP
cts = CompositionToStructureFromMP(mapi_key=JOHAN_API_KEY)
df2 = cts.featurize_dataframe(df2, 'composition')


MPRestError: REST query returned with error status code 403. Content: b’{“valid_response”: false, “error”: “API_KEY is not a valid key.”, “version”: {“db”: “2020_09_08”, “pymatgen”: “2022.0.8”, “rest”: “2.0”}, “created_at”: “2022-09-20T16:26:58.721279”}’
TO SKIP THESE ERRORS when featurizing specific compounds, set ‘ignore_errors=True’ when running the batch featurize() operation (e.g., featurize_many(), featurize_dataframe(), etc.).

It looks like you might be using API keys for our new website to access the legacy API. Also your pymatgen version is almost 1.5 years old. Try using the API key from the legacy MP dashboard and/or upgrading pymatgen to a more recent version. HTH

Okay ya using the legacy key made it work, I also updated pymatgen just to be safe. Thanks for your help.