'limit' and 'skip' parameters have been renamed. Please update your API client to the newest version. (error 400)

Hi all!
I am trying to query the database with a list of material_ids, but am currently being prompted with the following error:

MPRestError: REST query returned with error status code 400 on URL https://api.materialsproject.org/summary/?fields=material_id%2Ctheoretical&material_ids=omissis with message:
'limit' and 'skip' parameters have been renamed. Please update your API client to the newest version.

Th message appears even if I am working on mp_api == 0.23.3 and pymatgen == 2022.4.26, which seem to be the most up to date.

Any idea on how to solve this?

Hi @acarnevali, can you try doing pip install --upgrade mp_api?

1 Like

Hi! I tried that as my first response to the problem, and upgraded to the version I mentioned, but didn’t seem to solve the issue.
Here is the traceback, in case it is needed:

MPRestError                               Traceback (most recent call last)
omissis/MP_query.py in <module>
      36     theoretical = {
      37         str(d.material_id): d.theoretical
----> 38         for d in mpr.summary.search_summary_docs(
      39             material_ids=ids, fields=["material_id", "theoretical"]
      40         )

~\miniconda3\envs\mp_update\lib\site-packages\mp_api\routes\summary.py in search_summary_docs(self, material_ids, formula, chemsys, elements, exclude_elements, possible_species, nsites, volume, density, crystal_system, spacegroup_number, spacegroup_symbol, deprecated, total_energy, formation_energy, energy_above_hull, equilibrium_reaction_energy, uncorrected_energy, is_stable, band_gap, efermi, is_gap_direct, is_metal, magnetic_ordering, total_magnetization, total_magnetization_normalized_vol, total_magnetization_normalized_formula_units, num_magnetic_sites, num_unique_magnetic_sites, k_voigt, k_reuss, k_vrh, g_voigt, g_reuss, g_vrh, elastic_anisotropy, poisson_ratio, e_total, e_ionic, e_electronic, n, piezoelectric_modulus, weighted_surface_energy, weighted_work_function, surface_energy_anisotropy, shape_factor, has_reconstructed, has_props, theoretical, sort_fields, num_chunks, chunk_size, all_fields, fields)
    264         }
    265 
--> 266         return super().search(
    267             num_chunks=num_chunks,
    268             chunk_size=chunk_size,

~\miniconda3\envs\mp_update\lib\site-packages\mp_api\core\client.py in search(self, num_chunks, chunk_size, all_fields, fields, **kwargs)
    799         # documented kwargs.
    800 
--> 801         return self._get_all_documents(
    802             kwargs,
    803             all_fields=all_fields,

~\miniconda3\envs\mp_update\lib\site-packages\mp_api\core\client.py in _get_all_documents(self, query_params, all_fields, fields, chunk_size, num_chunks)
    848         chosen_param = list_entries[0][0] if len(list_entries) > 0 else None
    849 
--> 850         results = self._query_resource(
    851             query_params,
    852             fields=fields,

~\miniconda3\envs\mp_update\lib\site-packages\mp_api\core\client.py in _query_resource(self, criteria, fields, suburl, use_document_model, parallel_param, num_chunks, chunk_size)
    292                     url += "/"
    293 
--> 294             data = self._submit_requests(
    295                 url=url,
    296                 criteria=criteria,

~\miniconda3\envs\mp_update\lib\site-packages\mp_api\core\client.py in _submit_requests(self, url, criteria, use_document_model, parallel_param, num_chunks, chunk_size)
    399         ]
    400 
--> 401         initial_data_tuples = self._multi_thread(
    402             use_document_model, initial_params_list
    403         )

~\miniconda3\envs\mp_update\lib\site-packages\mp_api\core\client.py in _multi_thread(self, use_document_model, params_list, progress_bar)
    602 
    603                 for future in finished:
--> 604                     data, subtotal = future.result()
    605                     if progress_bar is not None:
    606                         progress_bar.update(len(data["data"]))

~\miniconda3\envs\mp_update\lib\concurrent\futures\_base.py in result(self, timeout)
    436                     raise CancelledError()
    437                 elif self._state == FINISHED:
--> 438                     return self.__get_result()
    439 
    440                 self._condition.wait(timeout)

~\miniconda3\envs\mp_update\lib\concurrent\futures\_base.py in __get_result(self)
    388         if self._exception:
    389             try:
--> 390                 raise self._exception
    391             finally:
    392                 # Break a reference cycle with the exception in self._exception

~\miniconda3\envs\mp_update\lib\concurrent\futures\thread.py in run(self)
     50 
     51         try:
---> 52             result = self.fn(*self.args, **self.kwargs)
     53         except BaseException as exc:
     54             self.future.set_exception(exc)

~\miniconda3\envs\mp_update\lib\site-packages\mp_api\core\client.py in _submit_request_and_process(self, url, verify, params, use_document_model)
    670                     message = str(data)
    671 
--> 672             raise MPRestError(
    673                 f"REST query returned with error status code {response.status_code} "
    674                 f"on URL {response.url} with message:\n{message}"

Found the problem: for some reason pip install --upgrade mp-api resulted in having two versions of mp_api installed in the environment: the old one and the updated one.

Solved by simply calling pip uninstall mp-api twice and then pip installing.

1 Like

I am having the same problem “‘limit’ and ‘skip’ parameters have been renamed. Please update your API client to the newest version.” tried to use “pip install --upgrade mp-api”, uninstall and install mp-api. But no luck. Anyone have any solution?

Hi, I am requesting a list of material with one mpid list, every time I reinstall the mp API, the requesting loop will break when requesting different material. I feel this API is super unstable, and how can I skip those failed requests?

Hi @YuanZi, I am not sure I understand. If you describe what you are doing and the errors you are getting in more detail I can try and help.

– Jason