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.9.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.9-py3-none-win_arm64.whl (5.4 MB view details)

Uploaded Python 3Windows ARM64

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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3manylinux: glibc 2.28+ x86-64

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

Uploaded Python 3manylinux: glibc 2.28+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

oxigraph-0.5.9-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.9.tar.gz.

File metadata

  • Download URL: oxigraph-0.5.9.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.9.tar.gz
Algorithm Hash digest
SHA256 3a8a1f1edad06fba950a9e0a137fefe7270dcbacbae5f510f857d269c388c3c7
MD5 3d2ee0fca889933c5b171ccaf255a028
BLAKE2b-256 c125949524f81295166391711b5a17892c07aa0f0b2e96eb59c3fb1b76f10772

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: oxigraph-0.5.9-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.9-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 2e32f6357e879e0c6f5b592913622c0257b41fb8ed64fca1d4322cfb8655838f
MD5 02219008036cc0a8c5afe8971db93172
BLAKE2b-256 f8b742c35af9ad5b5ad1a48b839cd29751d992ab0808c2205944c2a75ef936a0

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: oxigraph-0.5.9-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.9-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 0a6b9df33d3c61bca2701466db5437e04c8e5cafd114c777183e2038a84eddce
MD5 31cd245c072967ff3616902ef6b3a39f
BLAKE2b-256 0615fe279e8659e9cbb381ce5481903eda66ce2885d75ba6827a1333569ac007

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for oxigraph-0.5.9-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4fb4792d2231766df13366769387140f08ec39503be36b51ff1354d2c154c596
MD5 0cd9b46c63586ed30e75b3c6de07de0b
BLAKE2b-256 6d9757fc0fc4c6bfaf2fb3f2bd848ca4cb9c45436878598b411de1499a630177

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for oxigraph-0.5.9-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5a225b866c424ded3410773930ae6853670e84547cc7e7833a462a5e503742f2
MD5 dbc440ddfd0675e73dcde165fa390a9f
BLAKE2b-256 b8cfa8793843440ce3769f6f700b81b063641ab31f7cc9a84cc8491478731bb4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for oxigraph-0.5.9-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2c9019be100aaa46c42ad7e352419418c5d38bbfeefd498b4961e5dc27ff065a
MD5 8c9ebc5d52ed5070a1660081c5127015
BLAKE2b-256 32157bdee9b68a9457781a5a003ead0181884517cb5e2d1d984715776bf706d7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for oxigraph-0.5.9-py3-none-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 bd3db8d6518148aaba52345e319feda5fd4980708068cd3eac1582dfb9d372d0
MD5 76d539aa310917f5f6a9651162aba881
BLAKE2b-256 010cafea05d39c46977785f6b2272c0b93e6d60ab71306e17529a05e649cf49b

See more details on using hashes here.

Provenance

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