This is the front page of the web API used to run pyLODE, the OWL ontology documentation tool, built to resemble LODE, written in Python.

The API has only on endpoint (see next) to which you send your RDF to be converted into HTML. As pyLODE's options grow, this API will be adapted to cater for them.

If what you want is a web client to past RDF into to make pyLODE work online, see the Client.

Endpoints

  • api/create - POST requests here, see documentation below

How to use

Request

The API endpoint only accepts JSON POST messages with the following structure:

{
  "inputs": {
    "source": <RDF_STRING_OR_URI>
    "format": <INPUT_FORMAT>
    },
  "output": <HTML_OR_ZIP>
}
        

With the following possible variable values:

  • <RDF_STRING_OR_URI> - a JSON string containing either RDF data or a URI linking to RDF online
  • <INPUT_FORMAT> - only needed if an RDF data string is supplied for <RDF_STRING_OR_URI>. If needed is must be one of the RDF formats understood by rdflib, the Python RDF toolkit that pyLODE uses, expressed as a Media Type. Understood values:
  • <HTML_OR_ZIP> - either "html" or "zip"
    • html - renders a result as an HTML string, wrapped in JSON like { "result": "...HTML..." }
    • zip - return a zip file (no JSON) containing the HTML file (named "output.html") and CSS file ("pylode.css")

Response

The API returns HTML if the <HTML_OR_ZIP> value is set to "html".

It returns a zip file if the <HTML_OR_ZIP> value is set to "zip".

Any errors are returned as plain text (tex/plain) strings with an appropriate HTTP response code.

Example Requests

The following, requests using different HTTP systems ask for response from the API.

curl

Using curl on the command line, this request uses as input the web address of the RDF 1.1 ontology:

curl -i
     --request POST
     --header 'Content-Type: application/json'
     --data '{ "input": { "source": "http://www.w3.org/1999/02/22-rdf-syntax-ns" }, "output": "html" }'
     https://kurrawong.net/pylode-online/api/create
        

A similar request using RDF data in the Turtle format as input is:

curl -i
     --request POST
     --header 'Content-Type: application/json'
     --data '{ "input": { "format": "text/turtle", "source": "RDF_ONTOLOGY_CONTENT" }, "output": "html" }'
     https://kurrawong.net/pylode-online/api/create
        

Python

Using Python's requests module, the two request above are:

import json
import requests

with open('ontology.ttl', 'r') as f:
    rdf = f.read()

data = {
    'input': {
        'source': 'http://www.w3.org/1999/02/22-rdf-syntax-ns',
    },
    'output': 'html',
}

r = requests.post(
    'https://kurrawong.net/pylode-online/api/create',
    headers={'Content-Type': 'application/json'}
    data=json.dumps(data),
)

print(r.text)
        

and

import json
import requests

with open('rdf.ttl', 'r') as f:
    rdf = f.read()

data = {
    'input': {
        'source': rdf,
        'format': 'text/turtle',
    },
    'output': 'html',
}

r = requests.post(
    'https://kurrawong.net/pylode-online/api/create',
    headers={'Content-Type': 'application/json'}
    data=json.dumps(data),
)

print(r.text)