I would like to know how we can set up MP API to download materials containing Yb atom from Legacy site.
For our machine learning project, we need material structures and magnetic ordering. I could use mp_api to access the whole material data in the up-to-date MP database. However, I realized there are no longer materials containing Yb, while we could find them in MP Legacy site (e.g. mp-1104517). Does anybody know why we cannot find materials with Yb in the up-to-date MP? Does it mean the Yb-contained material data is no longer reliable?
Also, I would like to know how we can use Legacy API, which I have not used before.
Do I need to install older version of mp_api, and need an API key that is different from the New API? Also hope to know if thereās any example code to download a large number of materials from MP legacy site.
FYI: I saw thereās an archive repo for legacy usage.
I first tried one section, but I had trouble accessing MP legacy.
from pymatgen import MPRester
m = MPRester()
data = m.query(criteria={"task_id": "mp-1234"}, properties=["final_energy"])
print(data)
Then, I got an error:
ImportError: cannot import name āMPResterā from āpymatgenā (unknown location)
, suggesting recent pymatgen does not work with the legacy version
Below is another code block I have tried based on the repo:
import json
import requests
api_legacy = 'my_legacy_api'
data = {
'criteria': {
'elements': {'$in': ['Li', 'Na', 'K'], '$all': ['O']},
'nelements': 2,
},
'properties': [
'formula',
'formation_energy_per_atom',
]
}
r = requests.post('https://materialsproject.org/rest/v2/query',
headers={'X-API-KEY': api_legacy},
data={k: json.dumps(v) for k,v in data.items()})
response_content = r.json() # a dict
print('response_content:', response_content)
ā¦ then I got:
response_content: {āerrorā: āYour user agent is blocked. Please use our mp-api client (mp-api Ā· PyPI) and donāt scrape our website.ā, āversionā: āblockedā}
Thanks!
Best regards,