Skip to content
Sampo Pyysalo edited this page Mar 3, 2015 · 5 revisions

Minimal examples

Single annotation

To fetch a single annotation from a known address, try the following:

curl http://weaver.nlplab.org:5000/annotations/d14a982d45

This will give you a response like the following:

{
  "@id": "http://weaver.nlplab.org:5000/annotations/d14a982d45",
  "hasTarget": "http://weaver.nlplab.org:5000/documents/11532192.txt#char=39815,39818"
  "hasBody": "http://purl.obolibrary.org/obo/GO_0005694",
  ...
}

(Part of the response omitted for brevity.) These fields are:

  • @id: the globally unique identifier of the annotation.
  • hasTarget: the thing that is annotated.
  • hasBody: the information that the target is annotated with.

Note that the values of each of @id, hasTarget and hasBody are HTTP URIs that you can look up to get useful information:

This systematic use of HTTP URIs is central to what "linked" means in "linked data".

(TODO: the example response above could equivalently be

{
  "@id": "/annotations/d14a982d45",
  "hasTarget": "/documents/11532192.txt#char=39815,39818"
  "hasBody": "http://purl.obolibrary.org/obo/GO_0005694",
  ...
}

given that the request has http://weaver.nlplab.org:5000/annotations/ as its base URI and JSON-LD allows relative URIs wrt the base. Would this be a better choice?)

Set of annotations

To fetch all annotations from a collection with a known address, try

curl http://weaver.nlplab.org:5000/annotations/

(TODO explanation)

Some background

The API has a RESTful design, and by default exchanges annotations in the JSON-LD format specified by the Open Annotation model.

In practice, this means that the API uses basic web technology and simple object literals with standardized names like annotatedBy and, for the most part, URI values. The following examples illustrate its use with the curl command-line tool.

Clone this wiki locally