Landing page for Grakn examples.


This page lists the examples of Grakn that we suggest you study to learn how to work with our stack. We plan to continue to expand our set, and we also encourage you to let us know if you have example code to share, so we can link to it (for example, to your repo or a blog post).

If you would like to request a particular example, please get in touch with us by leaving a comment on this page or posting a question on the discussion boards. Our Community page lists other ways you can talk to us.

Genealogy Dataset

The genealogy dataset is widely used across our documentation about GRAKN.AI, because it allows for a simple, yet powerful, illustration of many key features. As described below, it is used to illustrate CSV migration and the Grakn Reasoner.

It is available on the sample-datasets repo on Github, and is also discussed in the “Family Matters” blog post.

Use Cases

CSV Migration

There are several examples available:

JSON Migration

There is an example of using the Java Migration API for JSON migration on the sample-projects repository on Github.

SQL Migration

There are several examples available:

  • A common use-case is to migrate existing SQL data to a knowledge graph in Grakn. We walk through a simple example of using the migration script as part of the documentation about SQL migration

  • There is a an additional example of SQL migration using the Java API.

  • We also cover SQL migration in a blog post.

Reasoning with Graql

We use the genealogy dataset to illustrate how to write rules to infer new information from a dataset. You can find the example here.

Learn Graql

  • The Modern example is a simple one, designed to test your knowledge of Graql.
  • We have a simple Pokemon example to illustrate how to form a range of different Graql queries.
  • The philosophers.gql file, also distributed in the Grakn release zip, contains a simple schema and data, for use as an example.


We have two examples to illustrate how to use Graql analytics:

  • Statistical Analysis describes using the compute and aggregate methods on a familar R dataset (MTCars) to compare them and illustrate them.
  • Analytics using Java APIs uses the Java APIs to show how to calculate clusters and degrees using the familar genealogy example set.


Haskell, R and Python Bindings

It is possible to extract data from Grakn and use it as a data science tool for analysis. You can take the results of a Graql query and store the results in a dataframe or similar structure, for use with Haskell, R or Python.

  • Haskell: This blog post is the first in a series of posts about combining GRAKN.AI and Haskell.
  • R and Python: This blog post explains and gives a simple example.
  • Python: A further blog post uses the Python driver to examine our example movie dataset.

Java Examples

Moogi Movie Database

Moogi is a large database of information about movies. We have provided a subset of its data to try out in our sample-datasets repository on Github.

Where Next?

If you are interested in writing an example on Grakn, maybe as a way of trying it out, please take a look at the Example Projects page, which lists some ideas that we have for potential examples or research projects.