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.6.tar.gz (6.4 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.6-py3-none-win_arm64.whl (5.3 MB view details)

Uploaded Python 3Windows ARM64

oxigraph-0.5.6-py3-none-win_amd64.whl (5.6 MB view details)

Uploaded Python 3Windows x86-64

oxigraph-0.5.6-py3-none-manylinux_2_28_x86_64.whl (8.3 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

oxigraph-0.5.6-py3-none-manylinux_2_28_aarch64.whl (7.8 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

oxigraph-0.5.6-py3-none-macosx_11_0_arm64.whl (6.0 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

oxigraph-0.5.6-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.6.tar.gz.

File metadata

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

File hashes

Hashes for oxigraph-0.5.6.tar.gz
Algorithm Hash digest
SHA256 59e05b3a63743d74997e8b802ff798d34a38e8ba17a23692ab48dab1dd39f2da
MD5 edf8f9a46b39bb0110c1a3de7a621d91
BLAKE2b-256 28659066e292ec6c4a69e63cbf2713f7ce8ca6d8fed965b7e502254bde11835c

See more details on using hashes here.

Provenance

The following attestation bundles were made for oxigraph-0.5.6.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.6-py3-none-win_arm64.whl.

File metadata

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

File hashes

Hashes for oxigraph-0.5.6-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 8273ff3674e2e5c9464e1cd408024135879cff4cfd4d1eca05e9c5e0043458a2
MD5 13a110e025f519b4a9d8cba3b5e2c251
BLAKE2b-256 d7b7b152a32ed5018d29d78350f6dfe3f2e1a9ca64774af4ddfac27590b8a816

See more details on using hashes here.

Provenance

The following attestation bundles were made for oxigraph-0.5.6-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.6-py3-none-win_amd64.whl.

File metadata

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

File hashes

Hashes for oxigraph-0.5.6-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 b9ff9de1bee3509960c3ba26aab17fa37a5c1fce3e92ee73a703c0c683caab9b
MD5 ed8818bbbe5ad8809d334ee52b681bf4
BLAKE2b-256 001ae0cad4ca8eff40e27b93d4677422f5c4dce659d37be3a2b14f359651c3cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for oxigraph-0.5.6-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.6-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for oxigraph-0.5.6-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 aa30aed1d5210fe3f014007500201190a9dc7a8d6a644a95e0831a449056d159
MD5 ce57dc723800f067e640a9ba79d1244c
BLAKE2b-256 ae91f18474da79ee057ca5bc91788dc7f504ca8a6f3ea3b9b1d741a76024d3a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for oxigraph-0.5.6-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.6-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for oxigraph-0.5.6-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 dcfc89becceff13899c044c84a0d1c25bc7708b848e4dc06c1ebd529b6cf1f97
MD5 f247145862afda0f4a1089b668f6d7e8
BLAKE2b-256 61148f5d2ac8d3623be4145f96123a8fdc44dfab8b70291383072bcae6a2677e

See more details on using hashes here.

Provenance

The following attestation bundles were made for oxigraph-0.5.6-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.6-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for oxigraph-0.5.6-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 09317ee56666056e1a63d3e9bbb82f3c895687fdd32bab26084f43433232dc6c
MD5 06832c62b65c7a85b8b271c20a9a060c
BLAKE2b-256 dae6e64dbb5720ca6dda0934b235e096d145bf3eeb649cf40edff8e2d801e6f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for oxigraph-0.5.6-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.6-py3-none-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for oxigraph-0.5.6-py3-none-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 8bfe046577b84cb0b8e4a83d53b5ca6930a7b9741c1c906946df6e3aeb7e9d35
MD5 08b4ae681b27c8ad5337a59cdeadf741
BLAKE2b-256 17cb89a76740b84a67d3f654ec423a047500689f3a99a42c7a3499dfd8f2a35e

See more details on using hashes here.

Provenance

The following attestation bundles were made for oxigraph-0.5.6-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