Publish Nanopublications

Publish Nanopublications using Nanobench.

Install the d2s tool#

See the complete installation documentation to install pip, pipx and Docker using Chocolatey.

Then install the d2s tool using pipx or pip:

pipx install d2s cwlref-runner
d2s init my-project-folder
cd my-project-folder

We recommend using pipx, but you can use pip or pip3 depending on your preferences.

You will not need the GraphDB installation file for this tutorial. So you can leave it blank when asked.

Start Nanobench#

We will use the Nanobench web service to publish Nanopublications.

d2s start nanobench

Access on http://localhost:37373

See official documentation for Docker.

Alternatively Nanobench can be run directly using docker run if d2s is not installed

docker run -d --rm --name nanobench -p 37373:37373 \
-v $(pwd)/workspace/.nanopub:/root/.nanopub \

Complete your profile#

Follow the instructions provided by the locally deployed Nanobench web UI to complete your profile, and publish your first nanopublication:

  • Provide your ORCID identifier. If you don't have one you can create an account at

  • You will then be prompted to create you Keys for Digital Signatures. Those keys are stored in workspace/.nanopub/id_rsa

  • To finish, link your ORCID account to prove you are the rightful owner (follow the Nanobench web UI instructions)

    • Keep the URL generated for your first nanopublication. It should starts with

Publish your first nanopublications#

Follow the tutorial from the locally deployed Nanobench web UI to publish your first nanopublications to the Maastricht University Institute of Data Science and and the official Nanopub servers!

Feel free to publish new nanopublications anytime you want ๐Ÿ“ข

Create a new template#

We will now create a new template to describe a dataset that has a publicly available SPARQL endpoint.

To create a new template we will need to use Nanopub-java to publish a Nanopublication from an arbitrary number of triples, instead of Nanobench.

Define the template#

We defined the template to let the user describe 4 properties:

  • title
  • description
  • homepage
  • SPARQL endpoint URL

Additionally the type dcat:Dataset is used to describe the generated entity.

The template is defined in TRiG format (similar to Turtle):

@prefix : <> .
@prefix xsd: <> .
@prefix rdf: <> .
@prefix rdfs: <> .
@prefix dct: <> .
@prefix prov: <> .
@prefix np: <> .
@prefix orcid: <> .
@prefix nt: <> .
@prefix npx: <> .
@prefix dcat: <> .
@prefix dctypes: <> .
@prefix void: <> .
@prefix foaf: <> .
:Head {
: np:hasAssertion :assertion ;
np:hasProvenance :provenance ;
np:hasPublicationInfo :pubinfo ;
a np:Nanopublication .
:assertion {
:assertion a nt:AssertionTemplate ;
rdfs:label "Describe a dataset with a SPARQL endpoint" ;
nt:hasStatement :st0 , :st1 , :st2 , :st3 , :st4 .
:title a nt:LiteralPlaceholder ;
rdfs:label "add the name of the dataset here" .
:description a nt:LiteralPlaceholder ;
rdfs:label "add the description of the dataset here" .
:homepage a nt:UriPlaceholder ;
rdfs:label "add the URL to the dataset homepage here" .
:sparqlEndpoint a nt:UriPlaceholder ;
rdfs:label "add the URL to the dataset SPARQL endpoint here" .
:dataset a nt:LocalResource ;
rdfs:label "This dataset" .
:st0 rdf:object dctypes:Dataset ;
rdf:predicate rdf:type ;
rdf:subject :dataset ;
a rdf:Statement ;
nt:statementOrder 0 .
:st1 rdf:object :title ;
rdf:predicate dct:title ;
rdf:subject :dataset ;
a rdf:Statement ;
nt:statementOrder 1 .
:st2 rdf:object :description ;
rdf:predicate dct:description ;
rdf:subject :dataset ;
a rdf:Statement ;
nt:statementOrder 2 .
:st3 rdf:object :homepage ;
rdf:predicate foaf:page ;
rdf:subject :dataset ;
a rdf:Statement ;
nt:statementOrder 3 .
:st4 rdf:object :sparqlEndpoint ;
rdf:predicate void:sparqlEndpoint ;
rdf:subject :dataset ;
a rdf:Statement ;
nt:statementOrder 4 .
dct:title rdfs:label "has name" .
dct:description rdfs:label "has description" .
foaf:page rdfs:label "has homepage" .
void:sparqlEndpoint rdfs:label "has SPARQL endpoint URL" .
rdf:type rdfs:label "is a" .
dctypes:Dataset rdfs:label "Dataset" .
:provenance {
:assertion prov:wasAttributedTo orcid:0000-0002-1501-1082 .
:pubinfo {
: dct:created "2020-04-14T13:13:44.817+01:00"^^xsd:dateTime ;
dct:creator orcid:0000-0002-1501-1082 .

Copy this template to a file named nanopub.trig in the project root folder.

Publish the template#

Copy the id_rsa key file generated by Nanobench to your home

cp -r workspace/.nanopub ~/.nanopub

Sign the nanopub.trig in the current folder using nanopub-java image from DockerHub:

docker run -it --rm -v ~/.nanopub:/root/.nanopub -v $(pwd):/data umids/nanopub-java sign /data/nanopub.trig

It should generate a signed.nanopub.trig, you can now publish it:

docker run -it --rm -v ~/.nanopub:/root/.nanopub -v $(pwd):/data umids/nanopub-java publish /data/signed.nanopub.trig

Our template can now be used at http://localhost:37373/publish?22&template=

See an example of a nanopub generated using this template to describe the Bio2RDF biomedical dataset:

Feel free to add more datasets or create new templates!