Quickstart
This runs the core pipeline against the hosted data plane: load RDF, wait for
the snapshot to publish, query it with SPARQL. You can do it with the TypeScript
or Python SDK, or with plain curl.
You need a stack, its API key, and its endpoint. Create a stack in
the hosted console and copy its key, which looks like
lbb_sk_live_… or lbb_sk_test_…. Each stack answers at its own
hostname:
https://<tenant-short-id>--<stack-slug>.db.eu.littlebigbrain.comThe tenant-short-id part is your account’s short ID; the stack slug is scoped
within that account. Copy the complete endpoint from the console’s Connect view. The
examples below use 0abc1def--your-stack; replace it with your endpoint_url.
See Endpoints & base URLs for the addressing model and
Authentication & endpoints for the key model.
The sample payload is three N-Triples statements:
<https://example.org/auth-service> <https://example.org/writesTo> <https://example.org/user-db> .<https://example.org/auth-service> <http://www.w3.org/2000/01/rdf-schema#label> "Auth Service" .<https://example.org/user-db> <http://www.w3.org/2000/01/rdf-schema#label> "User Database" .npm install @littlebigbrain/clientimport { LbbClient } from "@littlebigbrain/client";
const lbb = new LbbClient({ baseUrl: "https://0abc1def--your-stack.db.eu.littlebigbrain.com", // copy endpoint_url apiKey: process.env.LBB_API_KEY, // lbb_sk_live_… / lbb_sk_test_… graph: "main",});
const ntriples = `<https://example.org/auth-service> <https://example.org/writesTo> <https://example.org/user-db> .<https://example.org/auth-service> <http://www.w3.org/2000/01/rdf-schema#label> "Auth Service" .<https://example.org/user-db> <http://www.w3.org/2000/01/rdf-schema#label> "User Database" .`;
// 1. Load RDF. The graph is created on first write if it does not exist.const imported = await lbb.graph("main").facts.importRdf(ntriples, { format: "ntriples", idempotencyKey: "quickstart-1",});
// 2. Query it. `minIndexedSeq` waits for the published snapshot to cover// the sequence the load committed, so you read back your own write.const { rows } = await lbb.sparqlRows( { query: `SELECT ?s ?label WHERE { ?s <http://www.w3.org/2000/01/rdf-schema#label> ?label } LIMIT 10`, }, { minIndexedSeq: imported.committed_commit_seq },);for (const row of rows) console.log(row.s, row.label);pip install littlebigbrainfrom lbb import LbbClient
ntriples = """<https://example.org/auth-service> <https://example.org/writesTo> <https://example.org/user-db> .<https://example.org/auth-service> <http://www.w3.org/2000/01/rdf-schema#label> "Auth Service" .<https://example.org/user-db> <http://www.w3.org/2000/01/rdf-schema#label> "User Database" ."""
with LbbClient( "https://0abc1def--your-stack.db.eu.littlebigbrain.com", api_key="lbb_sk_live_...", graph="main",) as lbb: # 1. Load RDF. The graph is created on first write if it does not exist. imported = lbb.graph("main").facts.import_rdf( ntriples, format="ntriples", idempotency_key="quickstart-1" )
# 2. Query it. `min_indexed_seq` waits for the published snapshot to cover # the sequence the load committed, so you read back your own write. results = lbb.sparql( """ SELECT ?s ?label WHERE { ?s <http://www.w3.org/2000/01/rdf-schema#label> ?label } LIMIT 10 """, min_indexed_seq=imported["committed_commit_seq"], ) for row in results: print(row["s"], row["label"])export LBB_URL=https://0abc1def--your-stack.db.eu.littlebigbrain.comexport LBB_KEY=lbb_sk_live_...
cat > quickstart.nt <<'EOF'<https://example.org/auth-service> <https://example.org/writesTo> <https://example.org/user-db> .<https://example.org/auth-service> <http://www.w3.org/2000/01/rdf-schema#label> "Auth Service" .<https://example.org/user-db> <http://www.w3.org/2000/01/rdf-schema#label> "User Database" .EOF
# 1. Load RDF. The response reports committed_commit_seq.curl -sS -X POST "$LBB_URL/v1/graph/import/rdf?graph=main" \ -H "Authorization: Bearer $LBB_KEY" \ -H "Idempotency-Key: quickstart-1" \ -H "Content-Type: application/n-triples" \ --data-binary @quickstart.nt
# 2. Watch the published snapshot catch up.curl -sS "$LBB_URL/v1/graph/read-snapshot?graph=main" \ -H "Authorization: Bearer $LBB_KEY"
# 3. Query with the native SPARQL 1.1 Protocol endpoint.curl -sS "$LBB_URL/sparql?graph=main" \ -H "Authorization: Bearer $LBB_KEY" \ -H "Accept: application/sparql-results+json" \ --data-urlencode 'query=SELECT ?s ?label WHERE { ?s <http://www.w3.org/2000/01/rdf-schema#label> ?label } LIMIT 10'The hosted console runs the same steps without code: load data, watch the published watermark, and run a query.
What happened
Section titled “What happened”- Load appended the RDF statements to the write-ahead log as append-only events. The original predicate IRIs, named-graph labels, and literal term details are kept, so SPARQL projects the source RDF terms back unchanged.
- Publish built one immutable generation off the request path and exposed it atomically. Nothing reads a half-built index.
- Query ran against that single immutable snapshot. The response reports
served_at_seq, the exact committed prefix it answered from.
Reads default to eventual consistency, which serves the last published
snapshot. min_indexed_seq is the floor that turns that into read-your-writes:
pass the sequence your load returned, and an uncovered floor comes back as a
retryable 429 with a Retry-After so a pipeline can poll.
Validation and time travel
Section titled “Validation and time travel”Two more reads: a validation report, and a query pinned to a past commit.
# SHACL conformance for the published snapshot, derived from the graph's ontology.curl -sS "$LBB_URL/v1/ontology/conformance?graph=main" \ -H "Authorization: Bearer $LBB_KEY"
# The same query against a past commit. Every result stays reproducible.curl -sS "$LBB_URL/sparql?graph=main&as_of_commit_seq=1" \ -H "Authorization: Bearer $LBB_KEY" \ -H "Accept: application/sparql-results+json" \ --data-urlencode 'query=SELECT (COUNT(*) AS ?n) WHERE { ?s ?p ?o }'A pin past the current head is rejected as invalid input, so a cited snapshot always resolves to the same state.
Read Core concepts for snapshots, consistency, and the append-only model, then work through SPARQL, structured query & SHACL.