# Joseki: Command Line Applications

The standard distribution provides some client applications for accessing published RDF on a remote server. All are are written on top of the Joseki client library. The command line applications are:

- rdffetch: Get the RDF data contained in a hosted model about a particular resource
- rdfqueryremote: Issue an RDQL query on a model hosted by a Joseki server
- query: general purpose, low-level tool, to format and issue a Joseki query request
- ping: perform a `ping` operation on a remote model.

The protocol used in both these applications is HTTP GET. Any program that can issue HTTP GETs, such as wget or cwm, can access a Joseki server. There is a directory of examples in the distribution, and there is a Python library that works with RDFLib.

## Fetch

A remote fetch returns the recorded RDF about a resource in the model. For example, if the resource is the URI is the subject of Dublin Core statements, an appropriately configured server will return all the statements with properties in the Dublin Core namespace with the requested resource as subject.

Usage:

    java -cp ... joseki.rdffetch --model ModelURI --resource URI

The RDF is written out according to the `--format` argument, or N3 by default.

The exact nature of the RDF returned is determined by the server. See the "Data Objects" page for further information.

## Remote Query

Joseki comes with a command line application, very similar to the command line interface to the RDQL local query system (jena.rdfquery).

Access to RDF in Joseki is in the form of an RDF graph returned as the result of a query (including fetch or issuing an RDQL query). Executing an RDQL query on the server returns the smallest subgraph that matches the query (i.e. the subgraph that gives the same results as the query on the original graph).

Usage:

    java -cp ... joseki.rdfqueryremote [--model URI] {--query file | queryString}

In particular, you can put all the information in the query using the FROM clause of RDQL:

    SELECT ?x
    FROM <http://localhost:2020/testdata>
    WHERE (?x, ?y, "LITERAL-2")

so the command:

    java -cp ... joseki.rdfqueryremote --query SomeFile

will work for the default installation with its test data.

Specifying the "--model URL" parameter overrides the URL specified in the FROM clause of a query if any was present.

## query

A low level command:

    java -cp ... joseki.query --model URL [--format RDFsyntax] [--lang lang] httpQueryString

can be used to construct and perform a single query operation. The arguments must be provided in "HTTP Query String" format but it does not need to be `www-form-urlencoded` encoded. For example:

    java -cp ... joseki.query --model URL --lang RDQL 'q=SELECT * WHERE (?x ?y ?z)'

    java -cp ... joseki.query --model URL 'r=http://example.org/thing' 'lang=fetch'