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 consists of an implementation of the core Annotea Protocol and a number of Danno-specific extensions in the area of queries.
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.)
| Method | URI | Post data | Meaning |
| POST POST PUT PUT DELETE DELETE GET GET GET GET GET | http://<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/a | Create 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.
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.
Danno implements the following extensions to the basic Annotea model as set out in the protocol document:
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:
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:
(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.%2AWhen 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 parameter | Kind | Value | Meaning |
| w3c_annotates | primary | URI | Query 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_replyTree | primary | URI | Query 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_tree | primary | URI | Alias for 'w3c_replyTree'. (W3C Annotea server compatibility.) |
| danno_allAnnoteaObjects | primary | n/a | Query all Annotations and Replies. |
| danno_allObjects | primary | n/a | Query all Objects. |
| danno_annotates | restriction | URI | Restrict a primary query to objects with an 'a:annotates' for the supplied URI. |
| danno_annotatesRegex | restriction | Regex | Restrict a primary query to objects with an 'a:annotates' that matches the supplied SPARQL Regex. |
| danno_replyTree | restriction | URI | Restrict a primary query to objects with a 'tr:root' property for the supplied URI. |
| danno_inReplyTo | restriction | URI | Restrict a primary query to objects with a 'tr:inReplyTo' property for the supplied URI. |
| danno_creator | restriction | String | Restrict a primary query to objects with a 'dc:creator' property with the supplied value. |
| danno_language | restriction | String | Restrict a primary query to objects with a 'dc:language' property for the supplied value. |
| danno_collectionId | restriction | URI | Restrict a primary query to objects with a 'danno:collectionId' property for the supplied URI. |
| danno_source | restriction | String | Restrict a primary query to objects with a 'danno:source' property for the supplied value. |
| danno_beforeDate | restriction | datetime | Restrict a primary query to objects with a 'dc:date' property less than the supplied value. |
| danno_afterDate | restriction | datetime | Restrict a primary query to objects with a 'dc:date' property greater or equal to the supplied value. |
| danno_createdBefore | restriction | datetime | Restrict a primary query to objects with a 'a:created' property less than the supplied value. |
| danno_createdAfter | restriction | datetime | Restrict a primary query to objects with a 'a:created' property greater or equal to the supplied value. |
| danno_modifiedBefore | restriction | datetime | Restrict a primary query to objects with a 'a:modified' property less than the supplied value. |
| danno_modifiedAfter | restriction | datetime | Restrict a primary query to objects with a 'a:modified' property greater or equal to the supplied value. |
| danno_importedBefore | restriction | datetime | Restrict a primary query to objects with a 'danno:imported' property less than the supplied value. |
| danno_importedAfter | restriction | datetime | Restrict a primary query to objects with a 'danno:imported' property greater or equal to the supplied value. |
| danno_includeBodies | modifier | n/a | Add the embedded Body objects for any Annotations or Replies in the result set. |
| danno_useStylesheet | modifier | URI | Add a stylesheet processing directive to the RDF/XML with the supplied stylesheet URI. |
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:
http://<hostname>/danno/OAI2/
So for example, the following URI will perform an OAI-PMH "Identify".
http://<hostname>/danno/OAI2/?verb=Identify
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 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.
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.)
| Action | Parameters | Response | Description |
| "0" | n/a | token (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" | token | status, 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/a | name, style, debug, annoy (JSON) | Get the user's preferences, based on the existing cookies and defaults. |
| "sp" | pass, name, style, debug, annoy | message 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" | url | object (JSON) | Get the annotation or reply identified by 'url'. |
| "hget" | url, sel, num | annotation / 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, since | changed, 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" | url | policy (text) | Fetch the default annotation policy for the resource 'url'. |
| "img" | url, rect | clipped image (Image type) | Fetch a clipped image region for the image 'url' and the bounding box 'rect'. |
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.)
The parameters for the Dannotate actions are as follows:
| Parameter | Type | Description |
| act | String | The request action; see previous table. |
| token | opaque | An 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. |
| url | URL | The 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. |
| aid | URL | The URL of the annotation / reply being edited. |
| ref | URL | The URL of the annotation or reply being replied to. |
| jump | String | This controls the auto-close behavior of message windows. |
| sel | text | The selected text for the annotation. |
| num | String | The current annotation marker for this annotation. (Note: that markers may change at any time.) |
| rect | The rectangle of the image to be clipped. | |
| since | opaque | A timestamp that should be treated as opaque by the Dannotate client-side. |
| name | String | A 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. |
| title | String | The annotation title |
| type | String | The annotation or reply type |
| xp | XPointer | The annotation's context XPointer; e.g. the selection. |
| cmnt | Text | The annotation or reply text. This can be plain text, or text with (a subset of) HTML markup. |
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.