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
    
  • /sparql allows both SPARQL queries and update (see it as the union of /query and /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.8.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.8-py3-none-win_arm64.whl (5.5 MB view details)

Uploaded Python 3Windows ARM64

oxigraph-0.5.8-py3-none-win_amd64.whl (5.8 MB view details)

Uploaded Python 3Windows x86-64

oxigraph-0.5.8-py3-none-manylinux_2_28_x86_64.whl (8.6 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

oxigraph-0.5.8-py3-none-manylinux_2_28_aarch64.whl (8.1 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

oxigraph-0.5.8-py3-none-macosx_11_0_arm64.whl (6.3 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

oxigraph-0.5.8-py3-none-macosx_10_14_x86_64.whl (6.8 MB view details)

Uploaded Python 3macOS 10.14+ x86-64

File details

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

File metadata

  • Download URL: oxigraph-0.5.8.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.8.tar.gz
Algorithm Hash digest
SHA256 3d7f65aca165614d83eebe846ebcf5ec1950b9b6806b3d8ceca9f8a18468e582
MD5 40d64f05a7b75d5219aefd2933232194
BLAKE2b-256 cdddcadd7d290df0d31cb8562ee44fafc570f1deb1bd931349a9136da11c5752

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: oxigraph-0.5.8-py3-none-win_arm64.whl
  • Upload date:
  • Size: 5.5 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.8-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 f25008e160a0304b48569eebecc0f5bf1cdb53e657b7aef2e0d4a4f1082eb8dc
MD5 7c657b3780b6df75969d1c7404c99847
BLAKE2b-256 bab65ccac9c2d844777ef32c6812c1444524881ac53cc555b2a223e96b96b089

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: oxigraph-0.5.8-py3-none-win_amd64.whl
  • Upload date:
  • Size: 5.8 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.8-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 443380e11d6e9a7fa6dd704e53602516337c0d987440c3398f6899b6185a1ef2
MD5 427b88bde2bb1936d6ee1d305225531d
BLAKE2b-256 c6d21ccb4aa97a6b2cae0ac20e615f9e9f7873b5ebb927456d6d60fe0c89e209

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for oxigraph-0.5.8-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3faed06ebc927e94dd634141c7956f25a8d583907156690064f8d51a1b2b3180
MD5 9d563fe395b50e1d9401351337b7baf6
BLAKE2b-256 24489b49f33f47e5440b7471341c76c5e7562b5aba3a8801d0f10453927b9967

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for oxigraph-0.5.8-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 322f30bc2ad1f785b00dbce2e414bec8010f1611ccd1a99810cdb601ab3d7a5d
MD5 ef4a9897297bab871ead561f45e27f3b
BLAKE2b-256 479bdc5fb5a76d3d540eb8f9cf3d12a5f8b4d4231d76dd7e812f85bd68be9495

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for oxigraph-0.5.8-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f59eb7a5edd28bd04e691b89b551d21d9df5eb247e20efc23bb62d96c52aaba5
MD5 ceb33aeac0fb9865ff6fb517fcb447b6
BLAKE2b-256 4acaf3e042dcae0a22cf9cc114a906d21770952d07fb148a8fda27d17554df56

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for oxigraph-0.5.8-py3-none-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 2a7fa74fbcb952fc5497d21f9c18fa6cafc4ebc4dfa61dfc243e107ce6e6f804
MD5 464ad1d4e56cef3d8a5369783227c724
BLAKE2b-256 751f72a3956338b445d0530e8326564ac8f590927c2275488f8d0a5d4e0c5413

See more details on using hashes here.

Provenance

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