Danno / Dannotate Web APIs

This page describes the Web (i.e. HTTP-based) APIs that are implemented by Danno and Dannotate. Some of these APIs are designed to be used by custom websites and tools. Others are primarily intended for internal use.

Note that the material in this page can easily get out of date. If you notice any discrepancies between what is described here and what is actually implemented, please notify us.


Danno's Annotea API

Danno's Annotea API consists of an implementation of the core Annotea Protocol and a number of Danno-specific extensions in the area of queries.

Danno's Annotea protocol requests

This is a brief summary of the Annotea protocol. For more details, please refer to this document. (But note that that document does not have the standing of a W3C standard or even a W3C draft standard. It is simply a working document that various people have chosen to use as the basis for various annotation clients and servers.)

MethodURIPost dataMeaning
POST POST PUT PUT DELETE DELETE GET GET GET GET GEThttp://<hostname>:/danno/annotea http://<hostname>:/danno/annotea http://<annotation-uri> http://<reply-uri> http://<annotation-uri> http://<reply-uri> http://<annotation-uri> http://<reply-uri> http://<body-uri> http://<hostname>:/danno/annotea/?w3c_annotates=<uri> http://<hostname>:/danno/annotea/?w3c_replyTree=<uri>Annotation RDF Reply RDF Annotation RDF Reply RDF n/a n/a n/a n/a n/a n/a n/aCreate an Annotation Create a Reply Update an Annotation Update a Reply Delete an Annotation Delete a Reply Fetch an Annotation Fetch a Reply Fetch an embedded Body Query Annotations for <uri> Query Replies for Annotation <uri>

The table above assumes that Danno have been configured with the default container name, and so on. Annotation and Reply <uri>'s are of the form:

  http://<hostname>:/danno/annotea/<annotation-id>
  http://<hostname>:/danno/annotea/<reply-id>
  http://<hostname>:/danno/annotea/body/<body-id>

The <id>s are strings of 16 hexadecimal digits that are generated by the Danno server and returned in the responses to the POST requests.

Danno-specific interpretations

The Annotea protocol document does not define schemas for Annotations, Replies or Bodies, but instead references some RDFS files on the W3C website. These RDFS are rather short on detail. For example, no attempt is made to specify the cardinality of the respective properties. We have therefore made the following "interpretations" of the Annotea documentation and related schemas.

  • Every Annotation must have at least one 'a:annotates' property. The property must be URI-valued.
  • Every Reply must have exactly one 'tr:' property. The property must be URI-valued.
  • An Annotation or Reply may have at most one each of 'dc:date', 'dc:creator', 'dc:title', 'a:created', one 'a:modified'. The 'dc:date', 'a:created' and 'a:modified' properties (if supplied) must be well-formed XML 'dateTime' values.
  • An Annotation or Reply may have at most one 'a:body' property which may conform to the HTTP Message schema.
  • An Annotation may have have any number of 'a:context' properties. The encoding and meaning of a context property is annotation tool specific, though Dannotate takes it to be an XPointer.
  • An Annotation, Reply or Body may contain any other properties, including blank-nodes.
  • All Dublin Core (DC) properties use the DC 1.1 versions of the property URIs. DC 1.0 URIs are automatically translated to their DC 1.1 equivalents on input. (This is implemented by the Danno Spring wiring files.)

Danno-specific extensions

Danno implements the following extensions to the basic Annotea model as set out in the protocol document:

  • When an Annotation, Reply or Body includes blank-nodes, the extent of the object is deemed to be the blank-node closure, subject to the "max closure depth" limitation in the Danno configuration properties.
  • Danno automatically adds or updates the 'a:created', 'a:modified' and 'dc:date' date/timestamps to reflect the actual creation and modification times. This is controlled by Danno configuration properties.

Danno implements a number of extension to the Annotea query syntax. Annotea defines two query parameters ("w3c_annotates" and "w3c_replyTree") that can select targeted sets of Annotations and Replies as required to implement an web annotation tool. These parameters can be combined in a request, with the effect of OR'ing the object result-sets.

Danno's query extensions fall into three categories:

  • Danno adds two more "primary" queries ("danno_allObjects" and "danno_allAnnoteaObjects") that allow a client to select objects for the initial result-set from a broader pool.
  • Danno adds a number of "restrictions", that serve to eliminate unwanted objects from the results. For example, adding the restriction parameter "danno_creator=Fred" will eliminate all objects that do not have a 'dc:creator' property with value "Fred".
  • Finally, Danno adds a couple of "modifier" parameters.

Before processing, the "primary" query parameters are extracted and counted. There must be at least one primary query, and the count must not exceed a configurable maximum (by default 2).

The query is then evaluated in a way that is equivalent to the following:

  1. Find all objects that satisfy at least one of the primary queries.
  2. Eliminate any objects that do not satisfy all of the restrictions.
  3. In 'danno_includeBodies' is given, add any embedded Body objects for any remaining Annotation or Reply objects in the result-set.
  4. Return as RDF/XML, with an optional stylesheet processing directive.

(In reality, the SPARQL queries are organized a little differently to what the recipe above suggests, but the end result is the same.)

Here are a couple of example queries. (The URLs have been line-wrapped for the sake of readability.

   http://example.com/danno/annotea/
       ?w3c_annotates=http%3A%2F%2Fwww.w3.org%2F
       &danno_creator=Fred 

This query requests Annotations for the W3 Consortium's website front page that have been created by someone who goes by the name of "Fred".

   http://example.com/danno/annotea/
       ?danno_allAnnoteaObjects
       &danno_annotatesRegex=http%3A%2F%2Fwww%5C.w3%5C.org%2F.%2A

When you unpick the %XX encoding, this query requests all Annotations for resources whose URIs match the regex "http://www\.w3\.org/\.*". In other words, all Annotations for the entire W3 Consortium website.

The complete set of Danno query parameters is as follows:

Query parameterKindValueMeaning
w3c_annotatesprimaryURIQuery all Annotations that annotate the supplied web resource URI; i.e. that have have an 'a:annotates' property with the supplied value. (Annotea standard)
w3c_replyTreeprimaryURIQuery all Replies that (reply directly or indirectly) to the supplied annotation URI; i.e. that have have a 'tr:root' property with the supplied value. (Annotea standard)
w3c_reply_treeprimaryURIAlias for 'w3c_replyTree'. (W3C Annotea server compatibility.)
danno_allAnnoteaObjectsprimaryn/aQuery all Annotations and Replies.
danno_allObjectsprimaryn/aQuery all Objects.
danno_annotatesrestrictionURIRestrict a primary query to objects with an 'a:annotates' for the supplied URI.
danno_annotatesRegexrestrictionRegexRestrict a primary query to objects with an 'a:annotates' that matches the supplied SPARQL Regex.
danno_replyTreerestrictionURIRestrict a primary query to objects with a 'tr:root' property for the supplied URI.
danno_inReplyTorestrictionURIRestrict a primary query to objects with a 'tr:inReplyTo' property for the supplied URI.
danno_creatorrestrictionStringRestrict a primary query to objects with a 'dc:creator' property with the supplied value.
danno_languagerestrictionStringRestrict a primary query to objects with a 'dc:language' property for the supplied value.
danno_collectionIdrestrictionURIRestrict a primary query to objects with a 'danno:collectionId' property for the supplied URI.
danno_sourcerestrictionStringRestrict a primary query to objects with a 'danno:source' property for the supplied value.
danno_beforeDaterestrictiondatetimeRestrict a primary query to objects with a 'dc:date' property less than the supplied value.
danno_afterDaterestrictiondatetimeRestrict a primary query to objects with a 'dc:date' property greater or equal to the supplied value.
danno_createdBeforerestrictiondatetimeRestrict a primary query to objects with a 'a:created' property less than the supplied value.
danno_createdAfterrestrictiondatetimeRestrict a primary query to objects with a 'a:created' property greater or equal to the supplied value.
danno_modifiedBeforerestrictiondatetimeRestrict a primary query to objects with a 'a:modified' property less than the supplied value.
danno_modifiedAfterrestrictiondatetimeRestrict a primary query to objects with a 'a:modified' property greater or equal to the supplied value.
danno_importedBeforerestrictiondatetimeRestrict a primary query to objects with a 'danno:imported' property less than the supplied value.
danno_importedAfterrestrictiondatetimeRestrict a primary query to objects with a 'danno:imported' property greater or equal to the supplied value.
danno_includeBodiesmodifiern/aAdd the embedded Body objects for any Annotations or Replies in the result set.
danno_useStylesheetmodifierURIAdd a stylesheet processing directive to the RDF/XML with the supplied stylesheet URI.

Danno's OAI-PMH API

Danno's OAI-PMH API is a faithful implementation of the OAI-PMH version 2.0 protocol. For details, please refer to the protocol specification. The Danno-specific parameters are as follows:

  • The default base URL for Danno's OAI-PMH API is:
      http://<hostname>/danno/OAI2/

    So for example, the following URI will perform an OAI-PMH "Identify".

      http://<hostname>/danno/OAI2/?verb=Identify
  • Danno's OAI-PMH interface does not support the (optional) notion of "deleted records" as described in the OAI-PMH specs.
  • Danno's OAI-PMH datestamps have granularity "YYYY-MM-DDThh:mm:ssZ".
  • Danno uses the 'dc:date' property of Annotea objects as the notional OAI-PMH datestamp. (Recall that Danno/Annotea POST and PUT operations update this property automatically.)
  • Danno's OAI-PMH interface supports two "formats":
    • The "rdf" format is a straight rendering of the selected objects in RDF/XML format.
    • The "oai_dc" format is a projection of a subset of the objects' properties onto (roughly) equivalent Dublin Core elements.

Danno's RSS API

Danno's RSS API is effectively a "skin" for Danno's extended Annotea queries that causes the result set to be returned in the form of an RSS feed. The syntax is the same as a Danno / Annotea query, except that the "annnotea" container name is replaced with "rss". For example:

   http://example.com/danno/rss/
       ?w3c_annotates=http%3A%2F%2Fwww.w3.org%2F
       &danno_creator=Fred 

This requests an RSS feed for Annotations on the W3 Consortium home page created by our old friend Fred.

The Dannotate API

The Dannotate client-side communicates with the server side using a rather complicated (and unpretty) private API. It is documented below in case someone wants to create a derivative of the Dannotate client.

Note: we treat this particular API as "internal" to Dannotate and may change it without considering compatibility with other tools.

Dannotate Actions

The Dannotate protocol consists of a number of "actions", each with their own set of parameters. The responses for the actions are variously formatted as HTML, JSON or plain text. (The Dannotate client-side does not see the RDF/XML format used in the Annotea protocol.)

ActionParametersResponseDescription
"0"n/atoken (text)Allocate an annotation editor token.
"1"token, url, title, name, (xp, ref, jump)form (HTML)Create an annotation / reply creation form.
"1a"token, url, name, (jump)form (HTML)Create an annotation / reply update form for the existing object 'url'. The form is populated from the object's current state.
"2"token, url, title, name, type, xp, cmnt, (ref, jump)message (HTML)Perform an annotation / reply creation.
"2a"token, aid, url, title, name, type, xp, cmnt, (ref, jump)message (HTML)Perform an annotation / reply update for annotation 'aid'.
"3"tokenstatus, URL, timestamp (JSON)Rendezvous with the completion of the annotation editor given by 'token'.
"4"token, (jump)message (HTML)Cancel the annotation editor given by 'token'.
"gp"n/aname, style, debug, annoy (JSON)Get the user's preferences, based on the existing cookies and defaults.
"sp"pass, name, style, debug, annoymessage or form (HTML)The user preference dialog. If 'pass' is "1", we set browser cookies based on the other parameters. Otherwise, we generate the user preferences web form .
"aget"url, (since)list, timestamp (JSON)Get annotations for resource 'url' (via a 'w3c_annotates' request). If 'since' is present, only get annotations changed since that timestamp.
"bget"urlobject (JSON)Get the annotation or reply identified by 'url'.
"hget"url, sel, numannotation / reply (HTML)Get the annotation or reply identified by 'url' formatted as HTML.
"rget"url, (since)list, timestamp (JSON)Get replies for annotation 'url' (via a 'w3c_replyTree' request), If 'since' is present, only get annotations changed since that timestamp.
"del"url"ok" or "" (text)Delete the annotation or reply identified by the url parameter
"chk"url, sincechanged, timestamp (JSON)Check for updates to the annotations / replies for 'url' made after 'since'. The result is "yes" or "no" together with a new timestamp for the next callback. (Caveat: annotation / reply deletions are not detected.)
"pol"urlpolicy (text)Fetch the default annotation policy for the resource 'url'.
"img"url, rectclipped image (Image type)Fetch a clipped image region for the image 'url' and the bounding box 'rect'.

Dannotate Sequences

One way to understand the Dannotate actions is to see them in the context of the client-server interactions. (Aside: this would be a good place to use some UML sequence diagrams.)

Dannotate Request Parameters

The parameters for the Dannotate actions are as follows:

ParameterTypeDescription
actStringThe request action; see previous table.
tokenopaqueAn annotation editor token. These values are used in the rendezvous mechanism that posts new annotation details back the main page when the annotation editor completes or is cancelled.
urlURLThe URL of the 'target' for the operation, or (for actions "1", "1a", "2" and "2a") the page being annotated or the root of the reply tree.
aidURLThe URL of the annotation / reply being edited.
refURLThe URL of the annotation or reply being replied to.
jumpStringThis controls the auto-close behavior of message windows.
seltextThe selected text for the annotation.
numStringThe current annotation marker for this annotation. (Note: that markers may change at any time.)
rectThe rectangle of the image to be clipped.
sinceopaqueA timestamp that should be treated as opaque by the Dannotate client-side.
nameStringA user name
style"1" or "2"The user's preferred annotation marker style.
debug"0" or "1"The user's debug preference.
annoy"0" or "1"The user's "annoying messages" preference.
titleStringThe annotation title
typeStringThe annotation or reply type
xpXPointerThe annotation's context XPointer; e.g. the selection.
cmntTextThe annotation or reply text. This can be plain text, or text with (a subset of) HTML markup.

The Page Repeater API

The Page Repeater API is an adjunct to the Dannotate API that allows a user to view the annotations on a non-Danno-friendly web resource. This API is what is used by the "Danno Repeat" bookmarklet, but it could also be used programmatically by other browser-resident tools.

The API consists of an HTTP GET request of the form:

     http://<hostname>/danno/repeater.svc?a=<url>&ck=<cookies>&e 

where <url> is the encoded URL of the page to be "repeated", and <cookies> are the encoded browser cookies to be used when the Page Repeater fetches the page. (The 'e' parameter is a sentinel that is used to detect truncation of the request URL in the case where the full URL is too long for the user's web browser or the Page Repeater.)

The result of the request is a modified version of the page denoted by the <url> that has the necessary Javascript hooks for viewing any Annotations and Replies for the page. If the <url> identifies a resource that is a bare image, the result HTML will be entirely synthetic.

The Javascript hooks added by the Page Repeater refer to the Dannotate service that is co-located with the Page Repeater. This in turn will be associated with a fixed Annotea (typically Danno) service instance, though that service does not need to be co-located.