Skip to main content

Oxigraph CLI tool and SPARQL HTTP server

Project description

Oxigraph CLI

Latest Version Crates.io downloads Conda actions status Gitter

Oxigraph CLI is a graph database implementing the SPARQL standard. It is packaged as a command-line tool allowing to manipulate RDF files, query them using SPARQL... It also allows spawning an HTTP server on top of the database.

Oxigraph is in heavy development, and SPARQL query evaluation has not been optimized yet.

Oxigraph provides different installation methods for Oxigraph CLI:

It is also usable as a Rust library and as a Python library.

Oxigraph implements the following specifications:

A preliminary benchmark is provided.

Note that Oxigraph CLI was previously named Oxigraph Server before version 0.4. Older versions are available under this name.

Packaging status

Installation

You need to have a recent stable version of Rust and Cargo installed as well as Clang for the RocksDB Rust bindings.

To download, build, and install the latest released version run cargo install oxigraph-cli. There is no need to clone the git repository.

To compile the command-line tool from source, clone this git repository including its submodules (git clone --recursive https://github.com/oxigraph/oxigraph.git), and execute cargo build --release in the cli directory to compile the full binary after having downloaded its dependencies. It will create a fat binary in target/release/oxigraph.

Some build options (cargo features) are available:

  • rocksdb-pkg-config: links against an already compiled rocksdb shared library found using pkg-config.
  • native-tls: Enables Oxigraph HTTP client for query federation using the host OS TLS stack (enabled by default).
  • rustls-native Enables Oxigraph HTTP client for query federation using Rustls and the native certificates.
  • rustls-webpki Enables Oxigraph HTTP client for query federation using Rustls and the Common CA Database certificates.

Usage

Run oxigraph serve --location my_data_storage_directory to start the server where my_data_storage_directory is the directory where you want Oxigraph data to be stored. It listens by default on localhost:7878.

The server provides an HTML UI, based on YASGUI, with a form to execute SPARQL requests.

It provides the following REST actions:

  • /query allows evaluating SPARQL queries against the server repository following the SPARQL 1.1 Protocol. For example:
    curl -X POST -H 'Content-Type:application/sparql-query' \
      --data 'SELECT * WHERE { ?s ?p ?o } LIMIT 10' http://localhost:7878/query
    
    This action supports content negotiation and could return Turtle, N-Triples, RDF/XML, SPARQL Query Results XML Format and SPARQL Query Results JSON Format.
  • /update allows to execute SPARQL updates against the server repository following the SPARQL 1.1 Protocol. For example:
    curl -X POST -H 'Content-Type: application/sparql-update' \
      --data 'DELETE WHERE { <http://example.com/s> ?p ?o }' http://localhost:7878/update
    
  • /store allows to retrieve and change the server content using the SPARQL 1.1 Graph Store HTTP Protocol. For example:
    curl -f -X POST -H 'Content-Type:application/n-triples' \
      -T MY_FILE.nt "http://localhost:7878/store?graph=http://example.com/g"
    
    will add the N-Triples file MY_FILE.nt to the server dataset inside of the http://example.com/g named graph. Turtle, N-Triples and RDF/XML are supported. It is also possible to POST, PUT and GET the complete RDF dataset on the server using RDF dataset formats (TriG and N-Quads) against the /store endpoint. For example:
    curl -f -X POST -H 'Content-Type:application/n-quads' \
      -T MY_FILE.nq http://localhost:7878/store
    
    will add the N-Quads file MY_FILE.nq to the server dataset.

Use oxigraph --help to see the possible options when starting the server.

It is also possible to load RDF data offline using bulk loading: oxigraph load --location my_data_storage_directory --file my_file.nq

Using a Docker image

Display the help menu

docker run --rm ghcr.io/oxigraph/oxigraph --help

Run the Webserver

Expose the server on port 7878 of the host machine, and save data on the local ./data folder

docker run --rm -v $PWD/data:/data -p 7878:7878 ghcr.io/oxigraph/oxigraph serve --location /data --bind 0.0.0.0:7878

You can then access it from your machine on port 7878:

# Open the GUI in a browser
firefox http://localhost:7878

# Post some data
curl http://localhost:7878/store?default -H 'Content-Type: text/turtle' -T ./data.ttl

# Make a query
curl -X POST -H 'Accept: application/sparql-results+json' -H 'Content-Type: application/sparql-query' --data 'SELECT * WHERE { ?s ?p ?o } LIMIT 10' http://localhost:7878/query

# Make an UPDATE
curl -X POST -H 'Content-Type: application/sparql-update' --data 'DELETE WHERE { <http://example.com/s> ?p ?o }' http://localhost:7878/update

Run the Web server with basic authentication

It can be useful to make Oxigraph SPARQL endpoint available publicly, with a layer of authentication on /update to be able to add data.

You can do so by using a nginx basic authentication in an additional docker container with docker-compose. First create a nginx.conf file:

daemon off;
events {
    worker_connections  1024;
}
http {
    server {
        server_name localhost;
        listen 7878;
        rewrite ^/(.*) /$1 break;
        proxy_ignore_client_abort on;
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header  Host $http_host;
        proxy_set_header Access-Control-Allow-Origin "*";
        location ~ ^(/|/query)$ {
            proxy_pass http://oxigraph:7878;
            proxy_pass_request_headers on;
        }
        location ~ ^(/update|/store)$ {
            auth_basic "Oxigraph Administrator's Area";
            auth_basic_user_file /etc/nginx/.htpasswd; 
            proxy_pass http://oxigraph:7878;
            proxy_pass_request_headers on;
        }
    }
}

Then a docker-compose.yml in the same folder, you can change the default user and password in the environment section:

version: "3"
services:
  oxigraph:
    image: ghcr.io/oxigraph/oxigraph:latest
    ## To build from local source code:
    # build:
    #   context: .
    #   dockerfile: cli/Dockerfile
    volumes:
      - ./data:/data

  nginx-auth:
    image: nginx:1.21.4
    environment:
      - OXIGRAPH_USER=oxigraph
      - OXIGRAPH_PASSWORD=oxigraphy
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
      ## For multiple users: uncomment this line to mount a pre-generated .htpasswd 
      # - ./.htpasswd:/etc/nginx/.htpasswd
    ports:
      - "7878:7878"
    entrypoint: "bash -c 'echo -n $OXIGRAPH_USER: >> /etc/nginx/.htpasswd && echo $OXIGRAPH_PASSWORD | openssl passwd -stdin -apr1 >> /etc/nginx/.htpasswd && /docker-entrypoint.sh nginx'"

Once the docker-compose.yaml and nginx.conf are ready, start the Oxigraph server and nginx proxy for authentication on http://localhost:7878:

docker-compose up

Then it is possible to update the graph using basic authentication mechanisms. For example with curl: change $OXIGRAPH_USER and $OXIGRAPH_PASSWORD, or set them as environment variables, then run this command to insert a simple triple:

curl -X POST -u $OXIGRAPH_USER:$OXIGRAPH_PASSWORD -H 'Content-Type: application/sparql-update' --data 'INSERT DATA { <http://example.com/s> <http://example.com/p> <http://example.com/o> }' http://localhost:7878/update

In case you want to have multiple users, you can comment the entrypoint: line in the docker-compose.yml file, uncomment the .htpasswd volume, then generate each user in the .htpasswd file with this command:

htpasswd -Bbn $OXIGRAPH_USER $OXIGRAPH_PASSWORD >> .htpasswd

Build the image

You could easily build your own Docker image by cloning this repository with its submodules, and going to the root folder:

git clone --recursive https://github.com/oxigraph/oxigraph.git
cd oxigraph

Then run this command to build the image locally:

docker build -t ghcr.io/oxigraph/oxigraph -f cli/Dockerfile .

Systemd

It is possible to run Oxigraph in the background using systemd.

For that, you can use the following oxigraph.service file (it might be inserted into /etc/systemd/system/ or $HOME/.config/systemd/user):

[Unit]
Description=Oxigraph database server
After=network-online.target
Wants=network-online.target

[Service]
Type=notify
ExecStart=/PATH/TO/oxigraph serve --location /PATH/TO/OXIGRAPH/DATA

[Install]
WantedBy=multi-user.target

Man pages and autocompletion

Autocompletion for various shells are generated on build in the target/{debug,release}/build/oxigraph-cli-<hash>/out/complete directory. Similarly, man pages are generated in the target/{debug,release}/build/oxigraph-cli-<hash>/out/man directory.

Migration guide

From 0.2 to 0.3

  • The cli API has been completely rewritten. To start the server run oxigraph serve --location MY_STORAGE instead of oxigraph --file MY_STORAGE.
  • Fast data bulk loading is now supported using oxigraph load --location MY_STORAGE --file MY_FILE. The file format is guessed from the extension (.nt, .ttl, .nq, ...).
  • RDF-star is now implemented.
  • All operations are now transactional using the "repeatable read" isolation level: the store only exposes changes that have been "committed" (i.e. no partial writes) and the exposed state does not change for the complete duration of a read operation (e.g. a SPARQL query) or a read/write operation (e.g. a SPARQL update).

Help

Feel free to use GitHub discussions or the Gitter chat to ask questions or talk about Oxigraph. Bug reports are also very welcome.

If you need advanced support or are willing to pay to get some extra features, feel free to reach out to Tpt.

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Oxigraph by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oxigraph-0.5.7.tar.gz (6.5 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

oxigraph-0.5.7-py3-none-win_arm64.whl (5.4 MB view details)

Uploaded Python 3Windows ARM64

oxigraph-0.5.7-py3-none-win_amd64.whl (5.7 MB view details)

Uploaded Python 3Windows x86-64

oxigraph-0.5.7-py3-none-manylinux_2_28_x86_64.whl (8.4 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

oxigraph-0.5.7-py3-none-manylinux_2_28_aarch64.whl (7.9 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

oxigraph-0.5.7-py3-none-macosx_11_0_arm64.whl (6.1 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

oxigraph-0.5.7-py3-none-macosx_10_14_x86_64.whl (6.6 MB view details)

Uploaded Python 3macOS 10.14+ x86-64

File details

Details for the file oxigraph-0.5.7.tar.gz.

File metadata

  • Download URL: oxigraph-0.5.7.tar.gz
  • Upload date:
  • Size: 6.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for oxigraph-0.5.7.tar.gz
Algorithm Hash digest
SHA256 4ac8c65f02894dcc595f4fe669b339cea8decd9a409626bfdeae65df4e895600
MD5 61db082b4ef2166497e41e27c925518b
BLAKE2b-256 88e79cc83b7f37d76550ed04ac2148f4b832368370df86d0a2c3040463976cf2

See more details on using hashes here.

Provenance

The following attestation bundles were made for oxigraph-0.5.7.tar.gz:

Publisher: artifacts.yml on oxigraph/oxigraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file oxigraph-0.5.7-py3-none-win_arm64.whl.

File metadata

  • Download URL: oxigraph-0.5.7-py3-none-win_arm64.whl
  • Upload date:
  • Size: 5.4 MB
  • Tags: Python 3, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for oxigraph-0.5.7-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 f2641b7f85090a881fb7b45dec0862ea1301cf488fa564f312f73d614b286644
MD5 cc5ae5f8e1d5549d26ab57c152ca7405
BLAKE2b-256 5038af279c2c194985fe6f83b30eec29dd1d1eb3f0d1b56b1b1abc4cb2c14d77

See more details on using hashes here.

Provenance

The following attestation bundles were made for oxigraph-0.5.7-py3-none-win_arm64.whl:

Publisher: artifacts.yml on oxigraph/oxigraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file oxigraph-0.5.7-py3-none-win_amd64.whl.

File metadata

  • Download URL: oxigraph-0.5.7-py3-none-win_amd64.whl
  • Upload date:
  • Size: 5.7 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for oxigraph-0.5.7-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 fa89360dd0c7e7391032b01d0e8bac2980b240e9f3b42d4818d4996964706a1a
MD5 242c6f1a626c58828548f09e6d781cff
BLAKE2b-256 df936716c39f535e016d108aea938699a7edf321a84998c91767bc27d9488681

See more details on using hashes here.

Provenance

The following attestation bundles were made for oxigraph-0.5.7-py3-none-win_amd64.whl:

Publisher: artifacts.yml on oxigraph/oxigraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file oxigraph-0.5.7-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for oxigraph-0.5.7-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1864bcc7790899bd2abc20f00ecf6093ea815673e1bc9a3e67c7d188db8bd264
MD5 9f2b334ab01080daa98690a88d6c9daf
BLAKE2b-256 b302fc7d251a7ac594a0d9a175f5194a411c594ee1280e9d6edd69768ecdf7a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for oxigraph-0.5.7-py3-none-manylinux_2_28_x86_64.whl:

Publisher: artifacts.yml on oxigraph/oxigraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file oxigraph-0.5.7-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for oxigraph-0.5.7-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d5ef9a76a228ba57de3b7631da74446615393def97e5fdd109d84ddad283c375
MD5 84635fb295b1852e3f4de6ab5fdbe41f
BLAKE2b-256 ed30db97a1d2633c26b0312668a33383cb957f2b75bcf9fcb4cb10bdd1850f25

See more details on using hashes here.

Provenance

The following attestation bundles were made for oxigraph-0.5.7-py3-none-manylinux_2_28_aarch64.whl:

Publisher: artifacts.yml on oxigraph/oxigraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file oxigraph-0.5.7-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for oxigraph-0.5.7-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 edff00d5e9d1b59a4bad3e533a8d89c2b21123498e7e651e33b6bb0231912da1
MD5 521468e75f629d732e6f930bc7d8a3db
BLAKE2b-256 5d22ed24bc1d236d4079b8760c1269a3123a82884583d8c376acb80e19d8e7fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for oxigraph-0.5.7-py3-none-macosx_11_0_arm64.whl:

Publisher: artifacts.yml on oxigraph/oxigraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file oxigraph-0.5.7-py3-none-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for oxigraph-0.5.7-py3-none-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 bee068afa58aefb8bfeca7386cbfec7f7c3a53ae9cd7494d407203959a14da65
MD5 0dc46579e87804b30e0c271da1735f45
BLAKE2b-256 10405477b1109e19a608ae808bc96f63f211cbe58603b8b1511ef54c182678d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for oxigraph-0.5.7-py3-none-macosx_10_14_x86_64.whl:

Publisher: artifacts.yml on oxigraph/oxigraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page