pymatgen.ext.matproj.MPRestError: REST query returned with error status code 403.Content: b'error code: 1020'

I can’t use the pymatgen.ext.matproj module since 1st April. At the beginning, I still could log in by changing my IP address, but now it totally doen’t work.

Yes, we’ve been getting suspicious traffic from IP addresses in the cernet.edu.cn domain which has been impacting our site (most recently the last couple of hours). We thus had to start blocking ASNs (IP ranges) resulting in the 1020 error message you see. I’ll take a closer look tomorrow to see if I can isolate the root cause. It would help if you could describe your recent activities so we can rule you out. Thanks!

Thank you for reply. I was recently working on a small project to predict the properties of a aqueous solution with some data got from the website like energy, volume etc, which is basically all I used this package for. So the frequency of using the pymatgen was kind of high in last couple of weeks, but i don’t see how it affects your running of website. And if it does make a bad influence, I would appreciate it if you can like you said rule me out this time and maybe give me some advice or warnings, so I will be careful to use next time and make sure it won’t happen. And if this is not about my activities, I truly hope you can give me the access to use it again.

Thanks for providing details. I have unblocked the cernet network. Feel free to send us code samples of how you’re retrieving data from MP. @munrojm and I can try to make suggestions on how to improve its efficiency if needed.

1 Like



As you can see from the code above, I might make a mistake of using multithreading to retrive data, which might create a MP entry several times within a short period of time (I suppose?). So, I wonder if it is helpful to use the ‘with’ sentencewhen creating a MPRester? Or is there another option to get data with a least times of visiting the website.

Thanks for sharing your code.

Yes, please don’t use multithreading to run a large number of MPRester clients in parallel. It’ll just get you rate-limited and in the worst case blocked (again). I think this approach was very likely the culprit for our recent (short-lived but regular) website issues. The latest happened about 20min before you posted this message.

Please consult the documentation at Using the API - Materials Project Documentation for how to use our latest python API client (MPRester). The client already takes care of batching and parallelizing requests, thus trying to retrieve data as fast as possible without putting too much strain on our servers.

Also make sure to use a list of MP IDs as value for the material_ids parameter in mpr.summary.search(). @munrojm might have some examples handy that would demonstrate how to best retrieve your properties of interest using mpr.summary.search()

All right, thank you for your advice, that is very helpful. Although the last time I ran this script was about two or maybe three weeks ago. And I think this might be a common problem which is likely to happen when users are try to speed up the process of retrieving data from the website with this simple function of ‘get_data’. But I didn’t notice there is a clear warning in the API documention or original code source, especially at the module of mpr.get_data function. Anyway, thanks for your help. Best wishes for you and your family as well as the Material Project.

Good to know. It might have been something else then and I’ll need to continue investigating.

Yes, we’ve seen users try this a few times before. We are working on a solution to catch this in the client before any requests are sent and also print a warning.

@tschaume

Dear all,

I am having a similar error. I am teaching a summer school (icmed.engin.umich.edu), and we are using Nanohub Jupyter notebook to query the (legacy) Materials Project. I am teaching how to write large queries, so last week we had ~30 students perform a query that pulled ~7500 materials at a time.

Anyway, the query worked last week, and this week the same code no longer working. I anticipate that we may have gotten blocked similarly to this post here. I have created a separate thread here: MPRester was working last Thursday, now not working, but just found this thread which is similar in nature.

Can you help us investigate and unblock? The summer school Python notebook is attached here for your reference. I also cannot run MP queries from my local computer using this Jupyter notebook on my local computer, which is also problematic.

Best,
Wenhao Sun

@Wenhao_Sun I’ve responded in the thread you’re referencing. Please include in your response there whether and when you’re seeing the error code: 1020 message. Thanks!

Thread closed due to inactivity, please open a new thread to address related issues.