Query materials data with Python
Read paginated public polymer records and distinguish open endpoints from token-protected workflows.
Read one page
The public experimental polymer endpoint accepts GET without a token. The example searches names, PSMILES and references for polyethylene and requests at most two records.
Follow pagination
Use pagination.has_next to decide whether to request another page. Keep search and page_size constant. Successful responses with no rows mean the query did not match any data.
Handle access and errors
Protected requests require Authorization: Token <TOKEN>. Use your own CEMP account to obtain a token and keep it out of logs. POST to this read-only endpoint returns HTTP 405 and Method not allowed.
Example input or output
import requests
response = requests.get(
"https://cleanenergymaterials.cn/polymer/api/public/experiment-polymer-data/",
params={"search": "polyethylene", "page": 1, "page_size": 2},
timeout=20,
)
response.raise_for_status()
result = response.json()
if not result["success"]:
raise RuntimeError(result["error"])
for row in result["data"]:
print(row["Name"], row["PSMILES"], row["Reference"])
print("has_next:", result["pagination"]["has_next"])