Skip to main content

Graphora Client Library

The Graphora Client Library provides a simple and intuitive Python interface to the Graphora API, enabling you to easily integrate Graphora’s graph-based data processing capabilities into your applications and data pipelines.

Overview

Graphora is a Text to Knowledge Graphs platform that helps you transform unstructured text into powerful knowledge graphs. The platform enables you to:
  • Transform unstructured data into structured knowledge graphs
  • Define custom ontologies for your domain
  • Extract entities and relationships from documents
  • Merge and manage graph data with conflict resolution
  • Query and analyze connected data
This client library makes it easy to integrate Graphora into your data pipelines, including platforms like Apache Beam, Apache Spark, and Google Cloud Dataflow.

Key Features

Complete API Coverage

Access all Graphora API endpoints through a clean, intuitive interface

Type Safety

Fully typed with Pydantic models for reliable data handling

User Context

All API calls are automatically scoped to the specified user

Async Support

Efficient handling of long-running operations with status monitoring

Minimal Dependencies

Lightweight implementation with few external dependencies

Comprehensive Documentation

Detailed guides and API references for all functionality

Installation

The Graphora client library can be installed using pip:
pip install graphora
To also install the CLI for command-line extraction:
pip install graphora[cli]
See the CLI Reference for command-line usage.

Quick Example

Here’s a simple example of using the Graphora client library to upload an ontology and transform documents:
import os
from graphora import GraphoraClient

# Base URL defaults to GRAPHORA_API_URL or https://api.graphora.io
client = GraphoraClient(
    auth_token=os.environ["GRAPHORA_AUTH_TOKEN"],
)

# Register an ontology
with open("ontology.yaml", "r") as f:
    ontology_yaml = f.read()
    
ontology_response = client.register_ontology(ontology_yaml)
ontology_id = ontology_response.id

# Transform documents
transform_response = client.transform(
    ontology_id=ontology_id,
    files=["document1.pdf", "document2.txt"]
)

# Wait for processing to complete
transform_status = client.wait_for_transform(transform_response.id)

# Get the resulting graph
graph = client.get_transformed_graph(transform_id=transform_response.id)
print(f"Nodes: {len(graph.nodes)}")
print(f"Edges: {len(graph.edges)}")

# Start merging the processed data
merge = client.start_merge(
    session_id=ontology_id,
    transform_id=transform_response.id,
)

Next Steps