Trigo
A high-performance RDF triplestore and SPARQL 1.1 query engine written in Go
What is Trigo?
Trigo is a modern RDF triplestore inspired by Oxigraph's architecture, implementing:
- Full SPARQL 1.1 support - SELECT, CONSTRUCT, ASK, DESCRIBE queries with advanced patterns
- Multiple RDF formats - Turtle, N-Triples, N-Quads, TriG, RDF/XML, JSON-LD parsers
- Efficient storage - 11-index architecture with BadgerDB backend
- HTTP SPARQL endpoint - W3C SPARQL 1.1 Protocol compliant
- Named graphs support - Full quad store with graph-level operations
- High performance - xxHash3 encoding, optimal index selection, query optimization
Documentation
Quick Start
Get up and running with Trigo in minutes. Build the project, load data, and run your first SPARQL query.
Read Guide →Architecture
Deep dive into Trigo's design: 11-index storage, query optimization, Volcano iterator model, and encoding strategies.
Learn More →HTTP Endpoint
Complete HTTP API reference. Query via REST, bulk data loading, result formats, and client examples.
API Reference →Testing & Compliance
W3C test suite integration, current compliance rates, RDF parser tests, and SPARQL execution validation.
View Tests →Key Features
🚀 High Performance
Optimal index selection, query optimization, lazy evaluation, and efficient encoding with xxHash3.
📊 SPARQL 1.1
Full query support with OPTIONAL, UNION, MINUS, GRAPH, BIND, and 20+ functions and operators.
🔄 RDF Formats
Parse and serialize Turtle, N-Triples, N-Quads, TriG, RDF/XML, and JSON-LD with high compliance.
🌐 HTTP API
W3C SPARQL 1.1 Protocol compliant endpoint with JSON, XML, CSV, and TSV result formats.
✅ Standards Compliant
Validated against W3C test suites for RDF 1.1 and SPARQL 1.1 specifications.
📦 Easy Integration
Use as a library in your Go applications or run as a standalone SPARQL endpoint server.
Quick Example
// Start the SPARQL endpoint
./trigo serve
// Query via HTTP
curl -X POST http://localhost:8080/sparql \
-H 'Content-Type: application/sparql-query' \
-H 'Accept: application/sparql-results+json' \
-d 'SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 10'
// Or use as a library
import (
"github.com/aleksaelezovic/trigo/pkg/store"
"github.com/aleksaelezovic/trigo/pkg/rdf"
)
storage, _ := storage.NewBadgerStorage("./data")
ts := store.NewTripleStore(storage)
triple := rdf.NewTriple(
rdf.NewNamedNode("http://example.org/alice"),
rdf.NewNamedNode("http://xmlns.com/foaf/0.1/name"),
rdf.NewLiteral("Alice"),
)
ts.InsertTriple(triple)
Test Results
Trigo is validated against the official W3C test suites:
RDF 1.1 Parsers — 🎉 Perfect Compliance!
- RDF N-Triples: 100% (70/70 tests)
- RDF N-Quads: 100% (87/87 tests)
- RDF Turtle: 100% (313/313 tests)
- RDF TriG: 100% (356/356 tests)
- RDF/XML: 100% (166/166 tests)
RDF 1.1 Total: 100% (992/992 tests) — Full W3C Compliance Achieved! ✅
RDF 1.2 Parsers — 🎉 Perfect Compliance!
- RDF 1.2 N-Triples: 100% (140/140 tests) — Perfect compliance ✅
- RDF 1.2 N-Quads: 100% (155/155 tests) — Perfect compliance ✅
- RDF 1.2 Turtle: 100% (405/405 tests) — Perfect compliance ✅
- RDF 1.2 TriG: 100% (416/416 tests) — Perfect compliance ✅
- RDF 1.2 XML: 100% (196/196 tests) — Perfect compliance ✅
RDF 1.2 Total: 100% (1,312/1,312 tests) — Full W3C Compliance Achieved! ✅
Combined RDF: 100% (2,304/2,304 tests) — Perfect W3C Compliance! 🎉
SPARQL Query
- SPARQL Syntax: 69.1% (65/94 tests)
- SPARQL BIND: 70.0% (7/10 tests)
- SPARQL CSV/TSV: 83.3% (5/6 tests)