Getting Started
This guide walks you through installing crategraph and using it to explore an RO-Crate collection. No prior experience with Python graph libraries is needed.
Installation
Install crategraph using pip:
If you want to extract text content from files in the crate (PDFs, Word documents, spreadsheets, etc.), install the optional inspection support:
Using Jupyter notebooks
crategraph is designed to work well in Jupyter notebooks, where results display as rich HTML. Everything in this guide also works in plain Python scripts.
Loading a crate
Start by loading an RO-Crate directory. This reads the ro-crate-metadata.json file and builds a graph of all the entities and relationships it describes.
To get a quick overview of what's in the crate, use summary():
This shows a breakdown of entity types (people, files, organisations, etc.) and relationship types (author, hasPart, etc.) in the collection.
Exploring the graph
Browsing entity types
Every entity in the crate has one or more types. You can see what types are available:
Filtering by type
Use select() to narrow down to entities of a particular type. This returns a new graph containing only the matching entities and their connections to each other:
Excluding noise
Use exclude() to remove entity or relationship types from a graph. This is useful when a high-volume administrative relationship dominates the structure:
You can also exclude entity types, for example crate.exclude(entity_types=["Person"]).
By default, entities that become isolated because of the exclusion are dropped. Entities that were already isolated are preserved. Like other filters, exclude() returns a new graph and leaves the original unchanged.
Filtering by property values
Use where() to filter by exact property values:
Filtering by date
Use select(time_range=) to find entities within a year range. This automatically searches common date properties (startDate, endDate, datePublished, etc.) and extracts years from ISO date strings:
Chaining filters
All filtering methods return a new graph, so you can chain them together to progressively refine your results:
Visualising
Interactive network visualisation
Generate an interactive network diagram that you can pan, zoom, and click:
This creates an HTML visualisation where nodes are coloured by type and sized by number of connections. You can save it to a file:
You can open this HTML in a new browser:Quick overview with glimpse
For a high-level view of the crate's structure, glimpse() shows one node per entity type with counts:
This is useful for orienting yourself in an unfamiliar collection before drilling into specific entities.
3D visualisation
For larger collections, a 3D visualisation can help separate clusters:
Inspecting files
RO-Crates often contain data files — documents, images, spreadsheets, and more. You can check whether an entity references a file using has_data:
Viewing a file
To see a rich preview of a file (images, tables, audio players, etc.):
Extracting text content
To extract the text content from a file (requires crategraph[inspect]):
This converts the file to text using markitdown, making it available for further analysis.
Searching
You can also search for entities by text in their properties using search():
This performs fuzzy matching, so it handles minor misspellings. It returns a graph of matching entities and their connections.
Next steps
- Browse the Tutorials for guided walkthroughs using real datasets
- See the API Reference for the full list of methods
- Check out the Resources page for publicly available RO-Crate collections to explore