Hi, I was trying to use MPDataRetrieval to retrieve the data with my API key, but it returns 403. I’ve tried both from https://legacy.materialsproject.org/dashboar, and https://next-gen.materialsproject.org/api, but both don’t work.
api_key = 'YOUR_API_KEY'
mpdr = MPDataRetrieval(mp_api_key)
query_criteria = {'e_above_hull': {'$lte': 0.08}, 'nelements': {'$gte': 3, '$lte': 4}, 'nsites': {'$lte': 40}}
query_properties = ['material_id', 'formation_energy_per_atom', 'band_gap', 'pretty_formula', 'e_above_hull', 'elements', 'cif', 'spacegroup.number']
dataframe = mpdr.get_dataframe(
criteria = query_criteria,
properties = query_properties,
)
To check if it is my api_key problem, I tried to request “'https://www.materialsproject.org/rest/v2/'tasks”, but 404 is returned. Therefore, I think it is the api_key problem?
api_key = 'YOUR_API_KEY'
base_url = 'https://www.materialsproject.org/rest/v2/'
endpoint = 'tasks'
url = base_url + endpoint
headers = {'X-API-KEY': api_key}
response = requests.get(url, headers=headers)
May anybody help me? Thank you very much!