Installation¶
Prerequisites:
- Python 3.9+
- Internet access
Install with pip:
Connect to CRIPT¶
Establish a connection with an API endpoint:
import cript
host = "<endpoint_hostname>" # e.g., criptapp.org
token = "<your_api_token>"
cript.API(host, token)
Note
Your API token can be found in the UI under Account Settings.
Example Tasks¶
Create a node¶
For example, create a Project:
... then a Collection:Note
Notice the use of create()
here, which instantiates and saves the object in one go.
Update a node¶
For example, update the Project node created above:
... then the Collection:Note
Notice the use of update()
here, which updates and saves a node in one go.
Delete a node¶
For example, delete the Collection node created above:
Get an existing node¶
For example, get the official CRIPT Project node:
... then get the official styrene Material node via name: ... or via UID ... or via URLRun a search query¶
For example, search for Material nodes with a molar mass less than 10 g/mol:
res = cript.Material.search(
properties = [
{
"key": "molar_mass",
"value__lt": 10,
"unit": "g/mol"
}
]
)
... then paginate through the results.
res.json() # View the raw JSON for the query
res.objects() # Generate objects for the current page
res.next_page() # Flip to the next page
res.previous_page() # Flip to the previous page
Upload a file¶
First, you'll need a Project and Data node:
Next, create a File node that points to your local file:Download a file¶
For example, download the file you uploaded above.
Note
The default path for a download is your current directory.