tg-graph-to-turtle
Exports knowledge graph data to Turtle (TTL) format for backup, analysis, or migration.
Synopsis
tg-graph-to-turtle [options]
Description
The tg-graph-to-turtle command connects to TrustGraph’s triple query service and exports graph triples in Turtle format. This is useful for creating backups, analyzing graph structure, migrating data, or integrating with external RDF tools.
The command queries up to 10,000 triples and outputs them in standard Turtle format to stdout, while also saving to an output.ttl file.
Options
Optional Arguments
| Option | Default | Description |
|---|---|---|
-u, --api-url URL | $TRUSTGRAPH_URL or http://localhost:8088/ | TrustGraph API URL |
-t, --token TOKEN | $TRUSTGRAPH_TOKEN | Authentication token |
-f, --flow-id ID | default | Flow instance ID to use |
-U, --user USER | trustgraph | User ID for data scope |
-C, --collection COLLECTION | default | Collection to export |
Examples
Basic Export
tg-graph-to-turtle
Export to File
tg-graph-to-turtle > knowledge-graph.ttl
Export Specific Collection
tg-graph-to-turtle -C "research-data" > research-graph.ttl
Output Format
The command generates Turtle format with proper RDF syntax:
@prefix ns1: <http://example.org/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
ns1:Person rdf:type rdfs:Class .
ns1:john rdf:type ns1:Person ;
ns1:name "John Doe" ;
ns1:age "30" .
Output Destinations
- stdout: Standard output for piping or display
- output.ttl: Automatically created file in current directory
Environment Variables
TRUSTGRAPH_URL: Default API URLTRUSTGRAPH_TOKEN: Default authentication token
Related Commands
tg-load-knowledge- Load knowledge into graphtg-dump-msgpack- Dump MessagePack filestg-show-graph- Display graph information
API Integration
This command uses the Triples Query API to retrieve graph data.