Quickstart
Get a Legra node running and query it in under five minutes.
1. Install a node
A node is a local Legra instance with its own identity and default workspace.
sudo legra install --apt --node-onlyThis installs Legra daemons on the default port block, generates cryptographic
identities, and creates a default workspace. The gateway HTTP port is 4242
on every platform.
Each machine runs at most one host; to run multiple hosts, use multiple machines (physical or virtual).
2. Start the server
legra node serveBy default, the gateway listens on all network interfaces at 0.0.0.0:4242.
This means other people and other nodes on the network can connect to it —
which is safe and recommended, since all workspace data is end-to-end encrypted.
If you prefer to restrict access to your own machine only, bind to localhost:
legra node serve --host 127.0.0.1The server accepts both HTTP requests and connections from other Legra nodes on the same port.
For quick experiments, you can run in ephemeral mode:
legra node serve --ephemeralEphemeral mode keeps all data in memory instead of writing it to disk. Data is lost when the server stops. Because everything must fit in RAM, this mode is best suited for small datasets and short-lived experiments.
3. Load sample data
Create a file called people.ttl:
@prefix : <http://example.org/> .
:Alice :name "Alice" ;
:knows :Bob .
:Bob :name "Bob" ;
:knows :Alice .Load it into the server:
legra graph upload people.ttlThe upload command also accepts a directory. It recursively scans for RDF files
(Turtle, N-Triples, RDF/XML) in all subdirectories and loads them in one go:
legra graph upload ./data/If you omit the path, it scans the current directory:
legra graph uploadSee the Loading Data guide for more options.
4. Run a query
The easiest way to query is with the legra CLI, which uses the native
protocol for the best performance. The legra graph query command accepts a
SPARQL query string.
legra graph query "SELECT ?name WHERE { ?person <http://example.org/name> ?name }"Output (JSON by default):
{
"results": {
"bindings": [
{ "name": { "type": "literal", "value": "Alice" } },
{ "name": { "type": "literal", "value": "Bob" } }
]
}
}For tab-separated output:
legra graph query "SELECT ?name WHERE { ?person <http://example.org/name> ?name }" --format tsvYou can also query via HTTP using any tool that speaks the SPARQL Protocol, such
as curl:
curl -X POST http://127.0.0.1:4242/api/v1/sparql/query \
-H "x-legra-api-key: $EKG_SPARQL_AUTH_KEY" \
-H "Content-Type: application/sparql-query" \
-d "SELECT ?name WHERE { ?person <http://example.org/name> ?name }"If your node is configured for JWT-based auth instead of API token auth, send
Authorization: Bearer <jwt> instead of x-legra-api-key.
See the HTTP API reference for details.
5. Create a branch
Branches let you make changes without affecting the main timeline:
legra graph branch create experimentQuery against the new branch:
legra graph query "SELECT * WHERE { ?s ?p ?o }" --branch experimentLoad data into it:
legra graph upload more-data.ttl --target-branch experimentList all branches:
legra graph branch listNext steps
- Loading Data — formats, named graphs, directory loads
- Querying — SPARQL features, output formats, query plans
- Branching — merge workflows, delta queries
- Workspaces — encryption, membership, key management
- CLI Reference — full command reference