Extracting cohesive energy via the API not working?

Hello,

I would like to compare the cohesive energy of some calcium carbonates. I have been trying to use the get_cohesive_energy function for that, but I seem to run into an error that I do not really understand. I tried for some different materials to make sure it’s not just a random entry for Calcite that is missing.
The error I am receiving is the following

if (run_type := entry[“data”][“run_type”]) not in energies[mp_id]:
~~~~~~~~^^^^^^^
KeyError: ‘mp-3953’

A minimal code example would be something like this
from mp_api.client import MPRester
mpr = MPRester(‘avalidkey’)
material_id = “mp-3953”
mpr.get_cohesive_energy(material_id,normalization=‘atom’)

I saw some discussions that the API changed two years ago, but I pulled that last version from the github and it seems to be more a material property issue but I can’t really figure out how to fix it
Any pointers would be very appreciated

Thanks for finding this @tilman-g, looks to be a bug in recent versions of the client, I’ll get back to you once I have this fixed!

Scratch that - no bug in the client, you just need to specify even a single MP ID as a list:

print(mpr.get_cohesive_energy([material_id],normalization=‘atom’))
>>> {'mp-3953': -5.997344877999999}

Thank you very much Aaron, that solved it.