Python code for importing data fails to work

Hi,

My python code for importing data from material project (see below) fails to work since this week.

It worked well before. I wonder if it is because of a recent update the material project.

How do I fix up the problem? Or simply wait for a few more days?

##################################################################
import json
import requests
data = {‘criteria’: {},
‘properties’: [‘material_id’, ‘structure’]}
r = requests.post(‘https://materialsproject.org/rest/v2/query’,
headers={‘X-API-KEY’: ‘****************’},
data={k: json.dumps(v) for k,v in data.items()})
response_content = r.json()
info = response_content[‘response’]
##################################################################

The above problem is figured out. The failure is caused by data overflow, which can be clearly illustrated by the following three experiments:

  • bad
    data = {‘criteria’: {},
    ‘properties’: [‘material_id’, ‘structure’]}

  • good
    data = {‘criteria’: {},
    ‘properties’: [‘material_id’]}

  • good
    data = {‘criteria’: {‘nelements’: 2},
    ‘properties’: [‘material_id’, ‘structure’]}

Hi Eric, sorry we failed to reply in a timely manner, and thank you for following up!