Help on Getting the X-Ray diffraction pattern of Fe3Al

I am trying to get the X-ray diffraction pattern of Fe3Al from the provided API, but I keep getting the below error:
MPRestError Traceback (most recent call last)
File /srv/conda/envs/notebook/lib/python3.9/site-packages/mp_api/client/core/client.py:859, in BaseRester.get_data_by_id(self, document_id, fields)
858 try:
→ 859 results = self._query_resource_data(criteria=criteria, fields=fields, suburl=document_id) # type: ignore
860 except MPRestError:

File /srv/conda/envs/notebook/lib/python3.9/site-packages/mp_api/client/core/client.py:814, in BaseRester._query_resource_data(self, criteria, fields, suburl, use_document_model, timeout)
799 “”"
800 Query the endpoint for a list of documents without associated meta information. Only
801 returns a single page of results.
(…)
811 A list of documents
812 “”"
→ 814 return self._query_resource( # type: ignore
815 criteria=criteria,
816 fields=fields,
817 suburl=suburl,
818 use_document_model=use_document_model,
819 chunk_size=1000,
820 num_chunks=1,
821 ).get(“data”)

File /srv/conda/envs/notebook/lib/python3.9/site-packages/mp_api/client/core/client.py:295, in BaseRester._query_resource(self, criteria, fields, suburl, use_document_model, parallel_param, num_chunks, chunk_size, timeout)
293 url += “/”
→ 295 data = self._submit_requests(
296 url=url,
297 criteria=criteria,
298 use_document_model=use_document_model,
299 parallel_param=parallel_param,
300 num_chunks=num_chunks,
301 chunk_size=chunk_size,
302 timeout=timeout,
303 )
305 return data

File /srv/conda/envs/notebook/lib/python3.9/site-packages/mp_api/client/core/client.py:405, in BaseRester._submit_requests(self, url, criteria, use_document_model, parallel_param, num_chunks, chunk_size, timeout)
401 initial_params_list = [
402 {“url”: url, “verify”: True, “params”: copy(crit)} for crit in new_criteria
403 ]
→ 405 initial_data_tuples = self._multi_thread(
406 use_document_model, initial_params_list
407 )
409 for data, subtotal, crit_ind in initial_data_tuples:

File /srv/conda/envs/notebook/lib/python3.9/site-packages/mp_api/client/core/client.py:626, in BaseRester._multi_thread(self, use_document_model, params_list, progress_bar, timeout)
624 for future in finished:
→ 626 data, subtotal = future.result()
628 if progress_bar is not None:

File /srv/conda/envs/notebook/lib/python3.9/concurrent/futures/_base.py:439, in Future.result(self, timeout)
438 elif self._state == FINISHED:
→ 439 return self.__get_result()
441 self._condition.wait(timeout)

File /srv/conda/envs/notebook/lib/python3.9/concurrent/futures/_base.py:391, in Future.__get_result(self)
390 try:
→ 391 raise self._exception
392 finally:
393 # Break a reference cycle with the exception in self._exception

File /srv/conda/envs/notebook/lib/python3.9/concurrent/futures/thread.py:58, in _WorkItem.run(self)
57 try:
—> 58 result = self.fn(*self.args, **self.kwargs)
59 except BaseException as exc:

File /srv/conda/envs/notebook/lib/python3.9/site-packages/mp_api/client/core/client.py:728, in BaseRester._submit_request_and_process(self, url, verify, params, use_document_model, timeout)
726 message = str(data)
→ 728 raise MPRestError(
729 f"REST query returned with error status code {response.status_code} "
730 f"on URL {response.url} with message:\n{message}"
731 )

MPRestError: REST query returned with error status code 404 on URL https://api.materialsproject.org/materials/mp-2018/?_limit=1&_fields=structure with message:
Not Found

During handling of the above exception, another exception occurred:

MPRestError Traceback (most recent call last)
Input In [13], in <cell line: 5>()
3 from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
5 with MPRester(api_key=“…”) as mpr:
6 # first retrieve the relevant structure
----> 7 structure = mpr.get_structure_by_material_id(“mp-2018”)
9 # important to use the conventional structure to ensure
10 # that peaks are labelled with the conventional Miller indices
11 sga = SpacegroupAnalyzer(structure)

File /srv/conda/envs/notebook/lib/python3.9/site-packages/mp_api/client/client.py:217, in MPRester.get_structure_by_material_id(self, material_id, final, conventional_unit_cell)
199 def get_structure_by_material_id(
200 self, material_id: str, final: bool = True, conventional_unit_cell: bool = False
201 ) → Union[Structure, List[Structure]]:
202 “”"
203 Get a Structure corresponding to a material_id.
204
(…)
214 Structure object or list of Structure objects.
215 “”"
→ 217 structure_data = self.materials.get_structure_by_material_id(
218 material_id=material_id, final=final
219 )
221 if conventional_unit_cell and structure_data:
222 if final:

File /srv/conda/envs/notebook/lib/python3.9/site-packages/mp_api/client/routes/materials.py:39, in MaterialsRester.get_structure_by_material_id(self, material_id, final)
26 “”"
27 Get a structure for a given Materials Project ID.
28
(…)
36 pymatgen structure objects.
37 “”"
38 if final:
—> 39 response = self.get_data_by_id(material_id, fields=[“structure”])
40 return response.structure if response is not None else response # type: ignore
41 else:

File /srv/conda/envs/notebook/lib/python3.9/site-packages/mp_api/client/core/client.py:868, in BaseRester.get_data_by_id(self, document_id, fields)
865 from mp_api.client import MPRester
867 with MPRester(api_key=self.api_key, endpoint=self.base_endpoint) as mpr:
→ 868 new_document_id = mpr.get_materials_id_from_task_id(document_id)
870 if new_document_id is not None:
871 warnings.warn(
872 f"Document primary key has changed from {document_id} to {new_document_id}, "
873 f"returning data for {new_document_id} in {self.suffix} route. "
874 )

File /srv/conda/envs/notebook/lib/python3.9/site-packages/mp_api/client/client.py:285, in MPRester.get_materials_id_from_task_id(self, task_id)
278 “”"
279 This method is deprecated, please use get_material_id_from_task_id.
280 “”"
281 warnings.warn(
282 “This method is deprecated, please use get_material_id_from_task_id.”,
283 DeprecationWarning,
284 )
→ 285 return self.get_material_id_from_task_id(task_id)

File /srv/conda/envs/notebook/lib/python3.9/site-packages/mp_api/client/client.py:264, in MPRester.get_material_id_from_task_id(self, task_id)
250 def get_material_id_from_task_id(self, task_id: str) → Union[str, None]:
251 “”"
252 Returns the current material_id from a given task_id. The
253 material_id should rarely change, and is usually chosen from
(…)
262 material_id (MPID)
263 “”"
→ 264 docs = self.materials.search(task_ids=[task_id], fields=[“material_id”])
265 if len(docs) == 1: # pragma: no cover
266 return str(docs[0].material_id) # type: ignore

File /srv/conda/envs/notebook/lib/python3.9/site-packages/mp_api/client/routes/materials.py:178, in MaterialsRester.search(self, material_ids, chemsys, crystal_system, density, deprecated, elements, exclude_elements, formula, num_elements, num_sites, spacegroup_number, spacegroup_symbol, task_ids, volume, sort_fields, num_chunks, chunk_size, all_fields, fields)
168 query_params.update(
169 {“_sort_fields”: “,”.join([s.strip() for s in sort_fields])}
170 )
172 query_params = {
173 entry: query_params[entry]
174 for entry in query_params
175 if query_params[entry] is not None
176 }
→ 178 return super()._search(
179 num_chunks=num_chunks,
180 chunk_size=chunk_size,
181 all_fields=all_fields,
182 fields=fields,
183 **query_params
184 )

File /srv/conda/envs/notebook/lib/python3.9/site-packages/mp_api/client/core/client.py:921, in BaseRester._search(self, num_chunks, chunk_size, all_fields, fields, **kwargs)
898 “”"
899 A generic search method to retrieve documents matching specific parameters.
900
(…)
916 A list of documents.
917 “”"
918 # This method should be customized for each end point to give more user friendly,
919 # documented kwargs.
→ 921 return self._get_all_documents(
922 kwargs,
923 all_fields=all_fields,
924 fields=fields,
925 chunk_size=chunk_size,
926 num_chunks=num_chunks,
927 )

File /srv/conda/envs/notebook/lib/python3.9/site-packages/mp_api/client/core/client.py:970, in BaseRester._get_all_documents(self, query_params, all_fields, fields, chunk_size, num_chunks)
956 list_entries = sorted(
957 (
958 (key, len(entry.split(“,”)))
(…)
965 reverse=True,
966 )
968 chosen_param = list_entries[0][0] if len(list_entries) > 0 else None
→ 970 results = self._query_resource(
971 query_params,
972 fields=fields,
973 parallel_param=chosen_param,
974 chunk_size=chunk_size,
975 num_chunks=num_chunks,
976 )
978 return results[“data”]

File /srv/conda/envs/notebook/lib/python3.9/site-packages/mp_api/client/core/client.py:295, in BaseRester._query_resource(self, criteria, fields, suburl, use_document_model, parallel_param, num_chunks, chunk_size, timeout)
292 if not url.endswith(“/”):
293 url += “/”
→ 295 data = self._submit_requests(
296 url=url,
297 criteria=criteria,
298 use_document_model=use_document_model,
299 parallel_param=parallel_param,
300 num_chunks=num_chunks,
301 chunk_size=chunk_size,
302 timeout=timeout,
303 )
305 return data
307 except RequestException as ex:

File /srv/conda/envs/notebook/lib/python3.9/site-packages/mp_api/client/core/client.py:405, in BaseRester._submit_requests(self, url, criteria, use_document_model, parallel_param, num_chunks, chunk_size, timeout)
399 remaining_docs_avail = {}
401 initial_params_list = [
402 {“url”: url, “verify”: True, “params”: copy(crit)} for crit in new_criteria
403 ]
→ 405 initial_data_tuples = self._multi_thread(
406 use_document_model, initial_params_list
407 )
409 for data, subtotal, crit_ind in initial_data_tuples:
411 subtotals.append(subtotal)

File /srv/conda/envs/notebook/lib/python3.9/site-packages/mp_api/client/core/client.py:626, in BaseRester._multi_thread(self, use_document_model, params_list, progress_bar, timeout)
622 finished, futures = wait(futures, return_when=FIRST_COMPLETED)
624 for future in finished:
→ 626 data, subtotal = future.result()
628 if progress_bar is not None:
629 progress_bar.update(len(data[“data”]))

File /srv/conda/envs/notebook/lib/python3.9/concurrent/futures/_base.py:439, in Future.result(self, timeout)
437 raise CancelledError()
438 elif self._state == FINISHED:
→ 439 return self.__get_result()
441 self._condition.wait(timeout)
443 if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:

File /srv/conda/envs/notebook/lib/python3.9/concurrent/futures/_base.py:391, in Future.__get_result(self)
389 if self._exception:
390 try:
→ 391 raise self._exception
392 finally:
393 # Break a reference cycle with the exception in self._exception
394 self = None

File /srv/conda/envs/notebook/lib/python3.9/concurrent/futures/thread.py:58, in _WorkItem.run(self)
55 return
57 try:
—> 58 result = self.fn(*self.args, **self.kwargs)
59 except BaseException as exc:
60 self.future.set_exception(exc)

File /srv/conda/envs/notebook/lib/python3.9/site-packages/mp_api/client/core/client.py:728, in BaseRester._submit_request_and_process(self, url, verify, params, use_document_model, timeout)
725 except (KeyError, IndexError):
726 message = str(data)
→ 728 raise MPRestError(
729 f"REST query returned with error status code {response.status_code} "
730 f"on URL {response.url} with message:\n{message}"
731 )

MPRestError: REST query returned with error status code 404 on URL https://api.materialsproject.org/materials/?deprecated=False&_fields=material_id&task_ids=mp-2018&_limit=1000 with message:
Not Found

I would really appreciate it if someone could help me through it.

Please provide a small code snippet reproducing the error. It looks like you’re asking for mp-2018 which is not a valid / existing material ID.

Thank you for your reply.
I am using the below code snippet provided in the page of my desired compound (the link to my target compound is “mp-2018: AlFe3 (Cubic, Fm-3m, 225)” )

from mp_api.client import MPRester
from pymatgen.analysis.diffraction.xrd import XRDCalculator
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer

with MPRester(api_key=“”) as mpr:

structure = mpr.get_structure_by_material_id("mp-2018")

sga = SpacegroupAnalyzer(structure)
conventional_structure = sga.get_conventional_standard_structure()

calculator = XRDCalculator(wavelength=“CuKa”)
pattern = calculator.get_pattern(conventional_structure)

Thank you for your help in advance.

Please upgrade your mp-api client. You’re connecting to an outdated API endpoint.

Thank you for your response. After updating, the process was completed successfully.