-
Notifications
You must be signed in to change notification settings - Fork 52
Description
Description
When using mp_api.client.MPRester, I encounter an error during initialization related to accessing the /heartbeat endpoint.
/usr/local/lib/python3.13/site-packages/mp_api/client/mprester.py:229: in __init__
emmet_version = MPRester.get_emmet_version(self.endpoint)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/local/lib/python3.13/site-packages/mp_api/client/mprester.py:494: in get_emmet_version
response = get(url=endpoint + "heartbeat").json()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Observed behavior
From reading the code, MPRester appears to access https://api.materialsproject.org/heartbeat without an API key in order to retrieve version information (database and emmet versions). However, this request consistently returns a 403 Forbidden, likely due to Cloudflare’s bot detection. For example: curl -i https://api.materialsproject.org/heartbeat also returns a 403 status.
Suggestion
I understand the operational challenges of running a large API service like the Materials Project. That said, it would be very helpful if the client could support a fallback behavior, for example:
- Gracefully skipping
get_database_version/get_emmet_versionwhen/heartbeatis unreachable - Catching and ignoring 403 (or network) errors for version checks
- Optionally allowing users to disable version checks via a flag or environment variable
Related issue
This may be related to the following issue: #817
Version
mp-api 0.45.15
Which OS?
- MacOS
- Windows
- Linux