MP doesn't allow me to query anymore

I am qerying a lot from MP by using the following commands :

a = MPRester(‘xxxMY_API_KEYxxx’)
halides = a.get_entries({“elements”:{“$in”:[“Cl”,“Br”,“I”,“F”],“$all”:[“Li”]}}) #2654 materials found in MP
for i in halides:
band_gap = a.get_bandstructure_by_material_id(str(‘'’+halides[12].entry_id+‘'’)).get_band_gap()

And I get the following error:

MPRestError: REST query returned with error status code 404. Content: b’\n\n\n\n\n Materials Project :: 404 \n \n\n \n \n \n \n <link rel=“search”\n type=“application/opensearchdescription+xml”\n title=“Search Materials Project”\n href='/static/opensearch.25669ffdaab0.xml'>\n <link rel=“shortcut icon” href='/static/images/favicon.00f51d402f3d.png' />\n <link rel=“stylesheet” href='/static/stylesheets/less/compiled/nucleus.5db1710fde48.css' charset=“utf-8”>\n <link rel=“stylesheet” href='/static/stylesheets/less/compiled/app.b2b36524052e.css' charset=“utf-8”>\n \n\n\n\n\n \n \n \n \n\n\n

I know that I have been using the MPRester intensively, but now this error comes up everytime I try to query one material. How can I resume querying (not extensively)?

Thank you in advance !

Hi @Yasmine_Benabed, it looks like you’re connecting to our legacy API. Please make sure to use our new client/API with the new API key from your dashboard. See here and here for more information.

Hi Patrick, thank you for replying to my message and email ! So I followed the steps as explained on (Getting Started - Materials Project Documentation):

  1. installing mp-api :

python -m pip install mp_api

  1. The installation was successful, I proceeded with a simple code :

import pymatgen
from mp_api.client import MPRester

with MPRester(“my_new_key_from_the_dashboard”) as mpr:
halides = mpr.get_entries({“elements”:{“$in”:[“Cl”,“Br”,“I”,“F”],“$all”:[“Li”]}})
print (len(halides))

  1. I got the following error:

MPRestError: REST query returned with error status code 404 on URL https://api.materialsproject.org/thermo/?formula=elements&limit=1000&fields=entries with message:
Response {“message”:“no Route matched with those values”}

Thanks, @Yasmine_Benabed! Could you double-check your mp-api version and make sure it’s the latest (0.33.3)? Your client connecting to /thermo instead of /materials/thermo indicates that it might be outdated.

I tried to find the version (mp_api --version) but oddly enough I am returned the following error:

mp_api: command not found

I tried to install mp-api using the git clone procedure and when I get to the step ‘‘python setup.py’’ I am returned the following error:

usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] …]
or: setup.py --help [cmd1 cmd2 …]
or: setup.py --help-commands
or: setup.py cmd --help

I also tried to install this particular version using the command:

python -m pip install mp_api==0.33.3

and I get the following error:

ERROR: Ignored the following versions that require a different python version: 0.19.0 Requires-Python >=3.8; 0.20.0 Requires-Python >=3.8; 0.20.1 Requires-Python >=3.8; 0.20.2 Requires-Python >=3.8; 0.20.4 Requires-Python >=3.8; 0.20.5 Requires-Python >=3.8; 0.20.6 Requires-Python >=3.8; 0.21.0 Requires-Python >=3.8; 0.21.1 Requires-Python >=3.8; 0.21.2 Requires-Python >=3.8; 0.21.3 Requires-Python >=3.8; 0.21.4 Requires-Python >=3.8; 0.21.5 Requires-Python >=3.8; 0.21.6 Requires-Python >=3.8; 0.22.0 Requires-Python >=3.8; 0.22.1 Requires-Python >=3.8; 0.22.2 Requires-Python >=3.8; 0.23.0 Requires-Python >=3.8; 0.23.1 Requires-Python >=3.8; 0.23.2 Requires-Python >=3.8; 0.23.3 Requires-Python >=3.8; 0.23.4 Requires-Python >=3.8; 0.23.5 Requires-Python >=3.8; 0.23.6 Requires-Python >=3.8; 0.24.0 Requires-Python >=3.8; 0.24.1 Requires-Python >=3.8; 0.24.2 Requires-Python >=3.8; 0.24.3 Requires-Python >=3.8; 0.24.4 Requires-Python >=3.8; 0.24.5 Requires-Python >=3.8; 0.24.6 Requires-Python >=3.8; 0.24.7 Requires-Python >=3.8; 0.24.8 Requires-Python >=3.8; 0.25.0 Requires-Python >=3.8; 0.25.1 Requires-Python >=3.8; 0.25.2 Requires-Python >=3.8; 0.26.0 Requires-Python >=3.8; 0.26.1 Requires-Python >=3.8; 0.26.2 Requires-Python >=3.8; 0.26.3 Requires-Python >=3.8; 0.26.4 Requires-Python >=3.8; 0.27.0 Requires-Python >=3.8; 0.27.1 Requires-Python >=3.8; 0.27.2 Requires-Python >=3.8; 0.27.3 Requires-Python >=3.8; 0.27.4 Requires-Python >=3.8; 0.27.5 Requires-Python >=3.8; 0.28.1 Requires-Python >=3.8; 0.29.0 Requires-Python >=3.8; 0.29.1 Requires-Python >=3.8; 0.29.2 Requires-Python >=3.8; 0.29.3 Requires-Python >=3.8; 0.29.4 Requires-Python >=3.8; 0.29.5 Requires-Python >=3.8; 0.29.6 Requires-Python >=3.8; 0.29.7 Requires-Python >=3.8; 0.29.8 Requires-Python >=3.8; 0.30.0 Requires-Python >=3.8; 0.30.1 Requires-Python >=3.8; 0.30.10 Requires-Python >=3.8; 0.30.11 Requires-Python >=3.8; 0.30.2 Requires-Python >=3.8; 0.30.3 Requires-Python >=3.8; 0.30.4 Requires-Python >=3.8; 0.30.5 Requires-Python >=3.8; 0.30.6 Requires-Python >=3.8; 0.30.7 Requires-Python >=3.8; 0.30.8 Requires-Python >=3.8; 0.30.9 Requires-Python >=3.8; 0.31.0 Requires-Python >=3.8; 0.31.1 Requires-Python >=3.8; 0.31.2 Requires-Python >=3.8; 0.32.0 Requires-Python >=3.8; 0.32.1 Requires-Python >=3.8; 0.33.0 Requires-Python >=3.8; 0.33.0rc1 Requires-Python >=3.8; 0.33.0rc2 Requires-Python >=3.8; 0.33.0rc3 Requires-Python >=3.8; 0.33.0rc4 Requires-Python >=3.8; 0.33.0rc5 Requires-Python >=3.8; 0.33.0rc6 Requires-Python >=3.8; 0.33.1 Requires-Python >=3.8; 0.33.2 Requires-Python >=3.8; 0.33.3 Requires-Python >=3.8
ERROR: Could not find a version that satisfies the requirement mp_api==0.33.3 (from versions: 0.2.1, 0.2.2, 0.2.3, 0.3.0, 0.4.0, 0.4.1, 0.5.0, 0.5.1, 0.6.0, 0.6.1, 0.7.0, 0.7.1, 0.8.0, 0.9.0, 0.9.1, 0.10.0, 0.10.1, 0.10.2, 0.11.0, 0.11.1, 0.11.2, 0.11.3, 0.11.4, 0.12.0, 0.12.1, 0.12.2, 0.13.0, 0.14.0, 0.14.1, 0.15.0, 0.15.1, 0.16.0, 0.16.1, 0.16.2, 0.16.3, 0.16.4, 0.16.5, 0.17.0, 0.18.0)
ERROR: No matching distribution found for mp_api==0.33.3

I have python 3.7.16, is it not compatible ?

Yes, 3.7 is too old. You need at least 3.8.

1 Like

(post deleted by author)