MPRestError: REST query returned with error status code 404 for B4C molecule data

Hi everyone,

I am trying to retrieve thermodynamic data for Boron Carbide (B4C) from the Materials Project API using the molecules.thermo.search endpoint. I’ve been running the following Python code, but it’s returning a 404 Not Found error.

I have already updated my mp_api library to the latest version (0.45.9) based on a previous discussion, but the error persists.

Code I am using:

with MPRester(api_key) as mpr:
    # Step 1: Get the material_id for B4C from summary
    summary_results = mpr.materials.summary.search(formula="B4C", fields=["material_id"])
    material_ids = [r.material_id for r in summary_results]
    print("Found material IDs for B4C:", material_ids)

    # Step 2: Use those IDs to query absorption
    fields = mpr.molecules.thermo.available_fields
    print("Number of fields available in:", len(fields))

    results = mpr.molecules.thermo.search(
        formula = "B4C",
        #precursor_formula="B4C",
        #fields = ['database_Ids'],
        fields=fields
    )

Error Message:

---------------------------------------------------------------------------
MPRestError                               Traceback (most recent call last)
/tmp/ipython-input-649663158.py in <cell line: 0>()
     18     print("Number of fields available in:", len(fields))
     19 
---> 20     results = mpr.molecules.thermo.search(
     21         #material_ids=material_ids,
     22         #task_ids = material_ids,

9 frames
/usr/local/lib/python3.12/dist-packages/mp_api/client/core/client.py in _submit_request_and_process(self, url, verify, params, use_document_model, timeout)
   1036                     message = str(data)
   1037 
-> 1038             raise MPRestError(
   1039                 f"REST query returned with error status code {response.status_code} "
   1040                 f"on URL {response.url} with message:\n{message}"

MPRestError: REST query returned with error status code 404 on URL https://api.materialsproject.org/molecules/thermo/?_fields=builder_meta%2Ccharge%2Cspin_multiplicity%2Cnatoms%2Celements%2Cnelements%2Cnelectrons%2Ccomposition%2Ccomposition_reduced%2Cformula_alphabetical%2Cformula_pretty%2Cformula_anonymous%2Cchemsys%2Csymmetry%2Cspecies_hash%2Ccoord_hash%2Cproperty_name%2Cproperty_id%2Cmolecule_id%2Cdeprecated%2Cdeprecation_reasons%2Clevel_of_theory%2Csolvent%2Clot_solvent%2Clast_updated%2Corigins%2Cwarnings%2Celectronic_energy%2Ccorrection%2Cbase_level_of_theory%2Cbase_solvent%2Cbase_lot_solvent%2Ccorrection_level_of_theory%2Ccorrection_solvent%2Ccorrection_lot_solvent%2Ccombined_lot_solvent%2Czero_point_energy%2Crt%2Ctotal_enthalpy%2Ctotal_entropy%2Ctranslational_enthalpy%2Ctranslational_entropy%2Crotational_enthalpy%2Crotational_entropy%2Cvibrational_enthalpy%2Cvibrational_entropy%2Cfree_energy&formula=B4C&_limit=1000 with message:
Not Found

Could someone please help me understand why this endpoint is returning a 404 error and how I can correctly access the thermodynamic data for B4C?

Thank you for your help!

The thermo endpoint is not available for molecules. Try mpr.materials.thermo.search. HTH

1 Like

Thank you, @tschaume . I’m also trying to use other endpoints related to molecules, but I’m encountering the same error when querying for B4C. Interestingly, the endpoints related to materials work successfully. Could you help me understand why this error occurs when using the molecule-related endpoints for B4C? I appreciate your support!

We build thermodynamic properties for our materials data (things with periodic boundary conditions, usually bulk solids), but not for our molecules collection (no periodic boundary conditions, usually atoms and molecules, no clusters AFAIK)

Are you trying to get data on molecular properties or materials? They’re different datasets with different physical/chemical properties