Get started#
Raphtory is a temporal graph database and analytics tool that you can use to investigate social graphs, detect fraud in financial transactions, power graphRAG AI systems, and much more.
Our powerful visual interface allows analysts to explore data and trace the evolution of relationships across time. Data scientists can use APIs to create repeatable analytics pipelines using our built in filters and metrics or add their own custom algorithms.
Raphtory is written in Rust for speed and safety. However, you can interact with your graphs using:
- Python - Our Python APIs are the primary way to create workflows and are described in detail in this documentation.
- GraphQL - Start a GraphQL server that you can interact with programmatically or using the playground integrated in the Raphtory UI.
- Rust - Interact directly with the Rust library to add new algorithms or build into fully featured products.
Note
To cite Raphtory in your work refer to our paper Raphtory: The temporal graph engine for Rust and Python.
Ingest a simple dataset#
You can build graphs directly in Raphtory or import data in standard formats. In the following example we use the OBS.txt baboon interaction dataset from SocioPatterns which is provided in a tab separated text file.
To ingest this data you must first format it using pandas to create a dataframe and convert the timestamps to the datetime format. Then you can create a new graph g in Raphtory using the .load_edges() method and assigning each of the parameters appropriately.
from raphtory import Graph
from raphtory import graphql
from raphtory import algorithms
import pandas as pd
edges_df = pd.read_csv(
"../data/OBS_data.txt", sep="\t", header=0, usecols=[0, 1, 2, 3, 4], parse_dates=[0]
)
edges_df["DateTime"] = pd.to_datetime(edges_df["DateTime"])
edges_df.dropna(axis=0, inplace=True)
edges_df["Weight"] = edges_df["Category"].apply(
lambda c: 1 if (c == "Affiliative") else (-1 if (c == "Agonistic") else 0)
)
g = Graph()
g.load_edges(
data=edges_df,
src="Actor",
dst="Recipient",
time="DateTime",
layer_col="Behavior",
properties=["Weight"],
)
print(g)
You can print the state of the graph object to verify it exists. Note that the earliest_time and latest_time are given in Raphtory's EventTime format.
Output
Graph(number_of_nodes=22, number_of_edges=290, number_of_temporal_edges=3196, earliest_time=EventTime(timestamp=1560419400000, event_id=0), latest_time=EventTime(timestamp=1562756700000, event_id=18446744073709551615))
For more details, see Creating a graph.
Query your data#
Once you have created a graph you can start to analyse it and isolate interesting features.
Continuing from the previous example, you can use the PageRank algorithm to find important nodes.
results = algorithms.pagerank(g)
top_5 = results.top_k({"pagerank_score":"desc"}, 5)
for rank, (node, score) in enumerate(top_5.items(),1):
print(f"Rank {rank}: {node.name} with a score of {score['pagerank_score']:.5f}")
Output
Rank 1: PETOULETTE with a score of 0.05990
Rank 2: BOBO with a score of 0.05941
Rank 3: LIPS with a score of 0.05812
Rank 4: FELIPE with a score of 0.05788
Rank 5: VIOLETTE with a score of 0.05759
Once you have identified some interesting features, you can performed more detailed analysis by filtering your results or examining them across a window of history.
Start the UI server#
To start the Raphtory UI you need to:
- Create a GraphServer and client.
- Every
GraphServerneeds a working directory, you can name this anything.
- Every
- Start the server and get a RaphtoryClient.
- Send the relevant graphs to this client (in this case you only have one graph available).
server = graphql.GraphServer(".idea/my-test/graphs")
client = server.start().get_client()
client.send_graph("OBS-graph", g, overwrite=True)
This will start the UI locally on the default port 1736, you should see Search page by default.
Note
You can also start a standalone server using the Raphtory CLI tool or Docker image.

You can use the Query Builder to select the graph you created and identify which baboons attacked each other in the last month.

For more information see the full User Interface overview.