importasyncio# (1)!importhttpximportpandasaspd# (2)!# API endpointendpoint_url="https://sciglass.uni-jena.de/api/trademark"headers={"Accept":"application/json","Content-type":"application/json","Authorization":"Bearer $SCIGLASS_NEXT_API_KEY"}asyncdefexample():asyncwithhttpx.AsyncClient(timeout=None)asclient:r=awaitclient.get(endpoint_url,headers=headers)ifr.status_code==200:data=r.json()print(data)# Define the desired column ordercolumns=["trademark","company","country","usage","note","table_ids"]# in the web UI, only the five columns are visible# Convert JSON to DataFrame with specified column orderdf=pd.DataFrame(data,columns=columns)# Display the DataFrameprint(df)# Export the result to CSVdf.to_csv('out.csv',index=False)else:print(f"Request failed with status code: {r.status_code}")print("Response text:",r.text)asyncio.run(example())
AsyncIO is Python's built-in library for writing concurrent code with the async/await syntax.
This is optional and is imported in this example to show how to export the result to a CSV file using pandas.
[{"trademark":"S87-1",# (1)!"company":"-","country":"USSR","usage":"Electronic tubes","note":"-","table_ids":"2642351"# (2)!},{"trademark":"MKR","company":"-","country":"USSR","usage":"Heat-resistant","note":"-","table_ids":"282"},# more trademarks]
Clicking on the Trademark name in the Web UI opens a list of all tables stored in the key table_ids.
table_ids is invisible in the Web UI, and the table ID is separated by a delimiter (this is not space).
Note
Many table IDs are joined and stored as string in the original SciGlass database, but they are separated by either ,(comma) or (space) or ASCII characters like (This is not space) or \x7f.
The developer is currently keeping it as it was. This decision may change in future updates to improve performance and maintainability.