Draft 2015-06-09
Editions are created by POSTing JSON data to the /editions endpoint. The list of editions can be retrieved by a GET request to the /editions endpoint.
Endpoint: /editions
Method: POST
Request content-type: application/json
Request body: { "title" : "title" }
Response location: /edition/edID
Response body: none
Status: 201 on success.
Comments:
Requires valid JSESSIONID cookie to get the ID of the logged in user. This will be stored as the edition's creator field.
Endpoint: /editions
Method: GET
Request body: none
Response content-type: application/json
Response body: [{"id":edID₁, "title":"title₁"}, … ]
Comments:
Retrieves an array of all edition IDs and titles which for which the logged-in user has at least VIEWER permission. The GET /edition/edID endpoint can then be used to retrieve the details of that edition.
Endpoint: /edition/edID
Method: GET
Request body: none
Response content-type: application/json
Response body: {
"id":1,"title":"Petrus Plaoul 1","creator":2
"witnesses":[
{"id":3,"title":"Lectio 1, Prologus [Reims Transcription]","siglum":"R"},
{"id":7,"title":"Lectio 1, Prologus [Sorbonne Transcription]","siglum":"S"}
],
"permissions":[
{"id":2,"role":"OWNER","name":"Joe User","mail":"joe@slu.edu"}
]
"metadata":[
{"id":1856,"type":"colour","content":"turquoise"}
]
"outlines":[6, 7]
}
Status: 200 on success, 404 if edID does not exist.
Comments:
The response's "creator" field contains a user ID. The "witnesses" field contains an array of witness information for this edition. The "permissions" field contains an array of all permissions associated with the edition. The "outlines" field contains an array of all outlines associated with this edition.
Endpoint: /edition/edID
Method: PUT
Request content-type: application/json
Request body: {"title":"New Title"}
Response body: none
Status: 204 on success, 404 if edID does not exist.
Comments:
The request body should contain a JSON object describing the fields to be changed. Currently, the only valid field is "title", but this may change.
Endpoint: /edition/edID/metadata
Method: POST
Request content-type: application/json
Request body: {"type":"colour","content":"turquoise"}
Response body: none
Response location: /annotation/annID
Status: 201 on success, 404 if edID does not exist.
Comments:
The request body should contain a single annotation object. The Location header of the response gives the caller the ID of the newly-created metadatum.
Endpoint: /edition/edID/metadata
Method: PUT
Request content-type: application/json
Request body: [{"type":"colour","content":"turquoise"}]
Request parameters: merge=true|false (default true)
Response body: none
Status: 204 on success, 404 if edID does not exist.
Comments:
The request body should contain an array of annotation objects. If the merge parameter is false, the contents of the array will completely replace the edition's existing metadata; if merge=true, the PUT will only affect metadata objects included in the request body. In either case, the call will create any objects found in the request body which don't already exist.
Endpoint: /edition/edID/approval
Method: PUT
Request content-type: application/json
Request body (optional): [annID₁, annID₂,…]
Response body: none
Status: 204 on success, 403 if the user does not have EDITOR permission on edID, 404 if edID does not exist.
Comments:
Sets the approvedBy field of the edition's metadata to the ID of the current user. If the request body contains an array of annotation IDs, only those annotations will be marked as approved. If the request body is absent, all the edition's metadata will be approved.
Endpoint: /edition/edID/outlines
Method: POST
Request content-type: application/json
Request body: {
"edition":3,
"title":"Conclusio",
"index":2,
"bounds":[
{"startPage":1000,"startOffset":489,"endPage":1000,"endOffset":1177},
{"startPage":2000,"startOffset":494,"endPage":2000,"endOffset":1186},
{"startPage":3000,"startOffset":472,"endPage":3000,"endOffset":1170}
],
"decisions":[
{"content":"in primis",
"motes":[
{"content":"in\nprimis","endOffset":506,"target":"#2","endPage":2000,"startPage":2000,"type":"tr-mote","startOffset":497},
{"content":"in primis","endOffset":485,"target":"#3","endPage":3000,"startPage":3000,"type":"tr-mote","startOffset":476},
{"content":"inprimis","endOffset":500,"target":"#1","endPage":1000,"startPage":1000,"type":"tr-mote","startOffset":492}
]
},
subsequent decisions associated with this outline
]
}
Response body: none
Response location: /outline/outlID
Comments:
Creates a new outline associated with the given edition. The "title" field is optional. The "index" field indicates the outline's index relative to the edition's other outlines, and defaults to 0 if omitted. The "bounds" field specifies the collation ranges which were used as the basis for the outline, and should be null for a full-edition collation. The "decisions" field contains an initial set of decisions made by the user; this field can be an empty array if the user has not yet made any decisions.
Endpoint: /edition/*edID/outlines
Method: PUT
Request content-type: application/json
Request body: array of outlines
Response body: none
Comments: Use this method to update all outlines associated with the edition. Useful for doing large-scale reorderings.
Endpoint: /edition/edID/permissions
Method: PUT
Request content-type: application/json
Request body: [{"user":uID, "role":"OWNER"}]
Request parameters: merge=true|false (default true)
Response body: none
Status: 204 on success, 404 if edID does not exist, 409 if the request body refers to a nonexistent user ID.
Comments:
The request body should contains an array of user permissions objects. The "user" field of each object should contain a user ID, and the "role" field one of "NONE", "VIEWER", "CONTRIBUTOR", "EDITOR", or "OWNER", identifying the permissions that will be granted to that user for the given edition. Specify "user":0 to set permissions for the "public sharing" user. If the merge parameter is false, the contents of the array will completely replace the edition's existing permissions; if it is true or omitted, only permissions mentioned in the request body will be affected.
Endpoint: /edition/edID
Method: DELETE
Request body: none
Response body: none
Status: 204 on success.
Comments:
Deletes the single edition identified by edID. Associated witnesses, transcriptions, pages, manifests, canvasses, images, outlines, parallels, and annotations will also be deleted.
Witnesses are created by posting JSON, JSON-LD or XML data to an edition's witnesses endpoint. The list of witnesses can be retrieved by a GET request to the edition's witnesses endpoint.
Endpoint: /edition/edID/witnesses
Method: POST
Parameters: none
Request content-type: application/json
Request body: {"title":"My Witness","siglum":"M"}
Status: 201 on success, 404 if edID does not exist.
Comments:
This allows the creation of a witness from JSON (non-LD) data. The "title" and "siglum" fields are required.
Endpoint: /edition/edID/witnesses
Method: POST
Request content-type: application/ld+json
Request body: single-file IIIF metadata representation
Status: 201 on success, 404 if edID does not exist.
Comments:
Currently the only source for this type of file is the JSON-LD export from T-PEN. The IIIF metadata spec is still under development, and does not appear to yet be supported by any other software.
Endpoint: /edition/edID/witnesses
Method: POST
Parameters: src URL of JSON-LD source (i.e. T-PEN project)
Request content-type: application/ld+json
Request body: none
Status: 201 on success, 404 if edID does not exist, or error codes from T-PEN
Comments:
This differs from importing a JSON-LD witness because the call creates a persistent link to T-PEN which is checked for updates every time the user logs in.
Endpoint: /edition/edID/witnesses
Method: POST
Request content-type: text/xml
Request body: TEI XML file
Status: 201 on success, 404 if edID does not exist.
Comments:
This has so far only been tested with TEI files from Jeffrey Witt's Petrus Plaoul corpus. The implementation will need to be generalised as we encounter other TEI files.
Endpoint: /edition/edID/witnesses
Method: POST
Parameters:
lineBreak string to indicate line breaks (e.g. lineBreak=%0a for linefeed)pageBreak string to indicate page breaks (e.g. `pageBreak=%0c for control-L)title string for witness titlesiglum string for siglumEndpoint: /witness/witID
Method: GET
Request body: none
Response body:
{
"id":4,
"author":"Petrus Plaoul",
"edition":1,
"title":"Lectio 1, Prologus [Vatican Transcription]",
"manifest":3,
"siglum":"V",
"transcription":3,
"metadata":{
"editor":"Jeffrey C. Witt",
"pubPlace":"Boston, MA"
}
}
Status: 200 on success, 404 if witID does not exist.
Comments:
Endpoint: /witness/witID
Method: PUT
Request content-type: application/json
Request body: {"author":"New Author", "title":"New Title", "siglum":"New Siglum"}
Response body: none
Status: 204 on success, 404 if witID does not exist.
Comments:
The request body should contain a JSON object describing the fields to be changed. Any fields which are omitted from the request will remain unchanged.
Endpoint: /witness/witID/metadata
Method: POST
Request content-type: application/json
Request body: {"type":"colour","content":"turquoise"}
Response body: none
Response location: /annotation/annID
Status: 201 on success, 404 if witID does not exist.
Comments:
The request body should contain a single annotation object. The Location header of the response gives the caller the ID of the newly-created metadatum.
Endpoint: /witness/witID/metadata
Method: PUT
Request content-type: application/json
Request body: [{"type":"colour","content":"turquoise"}]
Request parameters: merge=true|false (default true)
Response body: none
Status: 204 on success, 404 if witID does not exist.
Comments:
The request body should contain an array of annotation objects. If the merge parameter is false, the contents of the array will completely replace the witness' existing metadata; if merge is true or omitted, the PUT will only affect metadata objects included in the request body. In either case, the call will create any objects found in the request body which don't already exist.
Endpoint: /witness/witID/approval
Method: PUT
Request content-type: application/json
Request body (optional): [annID₁, annID₂,…]
Response body: none
Status: 204 on success, 403 if the user does not have EDITOR permission on witID, 404 if witID does not exist.
Comments:
Sets the approvedBy field of the witness' metadata to the ID of the current user. If the request body contains an array of annotation IDs, only those annotations will be marked as approved. If the request body is absent, all the witness' metadata will be approved.
Endpoint: /witness/witID
Method: DELETE
Request body: none
Response body: none
Status: 204 on success.
Comments:
Deletes the single witness identified by witID. Associated transcriptions, pages, manifests, canvasses, images, and annotations will also be deleted.
Endpoint: /witness/witID/annotations
Method: GET
Request body: none
Response body:
Status: 200 on success, 404 if witID does not exist.
Comments:
Convenience function which aggregates the annotations from all canvasses and pages associated with the witness.
Each witness has exactly one corresponding transcription object, which is created automatically when the witness is created. A transcription contains some metadata (e.g. the editor name), but its main purpose is to serve as a container to group together all the pages.
Endpoint: /transcription/transcrID
Method: GET
Request body: none
Response body: {
"id":1,"editor":"J. Witt",
"pages":[
{"id":1000,"title":"1r"},
{"id":6001,"title":"1v"}
]
}
Status: 200 on success, 404 if transcrID does not exist.
Comments:
The "pages" field of the transcription object provides an array with the IDs and titles of all pages associated with said transcription.
Endpoint: /transcription/transcrID/annotations
Method: POST
Request content-type: application/json
Request body: {"type":"colour","content":"turquoise","startPage":1000,"startOffset":0,"endPage":1001,"endOffset":15}
Response body: none
Response location: /annotation/annID
Status: 201 on success, 404 if transcrID does not exist.
Comments:
The request body should contain a single annotation object. The Location header of the response gives the caller the ID of the newly-created annotation.
Endpoint: /transcription/transcrID/pages
Method: GET
Request body: none
Response body: array of pages
Status: 200 on success, 404 if transcrID does not exist.
Comments:
The response body will be an array containing all the pages belonging to this transcription. The format will be the same as that returned by a GET request to /page/pgID.
Endpoint: /transcription/transcrID/permissions
Method: PUT
Request content-type: application/json
Request body: [{"user":uID, "role":"OWNER"}]
Request parameters: merge=true|false (default true)
Response body: none
Status: 204 on success, 404 if transcrID does not exist, 409 if the request body refers to a nonexistent user ID.
Comments:
The request body should contains an array of user permissions objects. The "user" field of each object should contain a user ID, and the "role" field one of "NONE", "VIEWER", "CONTRIBUTOR", "EDITOR", or "OWNER", identifying the permissions that will be granted to that user for the given transcription. Specify "user":0 to set permissions for the "public sharing" user. If the merge parameter is false, the contents of the array will completely replace the transcription's existing permissions; if it is true or omitted, only permissions mentioned in the request body will be affected.
Endpoint: /page/pageID
Method: GET
Request body: none
Response body: {"id":5, "text":"Quantum ad istud…", "title":"S4r.jpg", "index":4, "transcription":1}
Status: 200 on success, 404 if pageID does not exist.
Comments:
The "index" field contains the page's index within the transcription as a whole. If the "annotations" parameter is specified, the response will include an array of all annotation objects attached to the page. Similarly, specifying the "lines" parameter will include an array of all line objects.
Endpoint: /page/pageID
Method: PUT
Request body: {"id":5, "text":"Quantum ad istud…"}
Response body: none
Status: 204 on success, 404 if pageID does not exist.
Comments:
The JSON object in the request body should contain all fields which are to be modified; fields which aren't being changed can be omitted. Changing the page's "text" property may result in annotations being recalculated. Changing the page's "index" property can be used to reorder pages within the transcription.
Endpoint: /page/pgID/annotations
Method: POST
Request content-type: application/json
Request body: {"type":"colour","content":"turquoise"}
Response body: none
Response location: /annotation/annID
Status: 201 on success, 404 if pgID does not exist.
Comments:
The request body should contain a single annotation object. The annotation will be constrained so that it's startPage and endPage are both equal to pgID (to add an annotation which spans multiple pages, use the /transcription/*transcrID/annotations endpoint instead). The Location header of the response gives the caller the ID of the newly-created annotation.
Endpoint: /page/pgID/annotations
Method: GET
Request body: none
Response body: [{"id":38042,"startOffset":0,"endOffset":46,"type":"line","purpose":"LB","content":"fratres nostri quae acta sunt et quae difinita","motivation":"sc:painting","canvas":2085,"bounds":{"height":50,"width":627,"y":76,"x":40},"startPage":2085,"endPage":2085},…]
Status: 200 on success, 404 if pgID does not exist.
Comments:
Response contains an array with all annotations found on the given page. This includes multi-page annotations whose page range includes the page in question. Since lines are annotations, they will be included in the response.
Endpoint: /page/pgID/annotations
Method: PUT
Request body: [{"id":38042,"startOffset":0,"endOffset":46,"type":"line","purpose":"LB","content":"fratres nostri quae acta sunt et quae difinita","motivation":"sc:painting","canvas":2085,"bounds":{"height":50,"width":627,"y":76,"x":40},"startPage":2085,"endPage":2085},…]
Request parameters: merge=true|false (default true)
Response body: none
Status: 204 on success, 404 if pgID does not exist.
Comments:
The JSON array in the request body should contain new values for the page's annotations. If the merge parameter is false, the existing annotations will be completely replaced; if it is true or omitted, only annotations mentioned in the request body will be affected. For the purposes of this endpoint, a page's annotations are considered to be all annotations whose "startPage" to "endPage" range includes pgID.
Endpoint: /page/pgID/lines
Method: GET
Request body: none
Response body: [
{"id":34796,"startOffset":0,"endOffset":55,"selector":null,"type":"line","purpose":"LB","content":"episcopum fuisse aut esse neque ipsos qui ab eo ordina-","attributes":null,"startPage":6118,"endPage":6118,"bounds":{"height":94,"width":662,"y":9,"x":53},"canvas":6118},
…
]
Status: 200 on success, 404 if pgID does not exist.
Comments:
Response contains an array with all line annotations found on the given page.
Endpoint: /page/pageID/lines
Method: PUT
Request body: [{"id":38042,"startOffset":0,"endOffset":46,"type":"line","purpose":"LB","content":"fratres nostri quae acta sunt et quae difinita","motivation":"sc:painting","canvas":2085,"bounds":{"height":50,"width":627,"y":76,"x":40},"startPage":2085,"endPage":2085},…]
Request parameters: merge=true|false (default true)
Response body: none
Status: 204 on success, 404 if pageID does not exist.
Comments:
The JSON array in the request body should contain new values for the page's lines. If the merge parameter is false, the existing lines will be completely replaced; if it is true or omitted, only lines mentioned in the request body will be affected. For the purposes of this endpoint, a page's lines are considered to be all annotations whose "purpose" is "LB" and whose "startPage" is pageID.
Each witness has exactly one corresponding manifest object, which is created automatically when the witness is created. A manifest will eventually contain some metadata, but its main purpose is to serve as a container to group together all the canvasses.
Endpoint: /manifest/manID
Method: GET
Request body: none
Response body: {"id":3,"canvasses":[9,10,11,12]}
Status: 200 on success, 404 if manID does not exist.
Comments:
The "canvasses" field of the manifest object provides an array with the IDs of all canvasses associated with said manifest.
Endpoint: /manifest/manID/annotations
Method: POST
Request content-type: application/json
Request body: {"type":"colour","content":"turquoise","canvas":"canvas/1000#xywh=0,0,100,100"}
Response body: none
Response location: /annotation/annID
Status: 201 on success, 404 if manID does not exist.
Comments:
The request body should contain a single annotation object. The Location header of the response gives the caller the ID of the newly-created annotation.
Endpoint: /manifest/manID/canvasses
Method: GET
Request body: none
Response body: array of canvasses
Status: 200 on success, 404 if manID does not exist.
Comments:
The response body will be an array containing all the canvasses belonging to this manifest. The format will be the same as that returned by a GET request to /canvas/canvID.
Endpoint: /manifest/manID/permissions
Method: PUT
Request content-type: application/json
Request body: [{"user":uID, "role":"OWNER"}]
Request parameters: merge=true|false (default true)
Response body: none
Status: 204 on success, 404 if manID does not exist, 409 if the request body refers to a nonexistent user ID.
Comments:
The request body should contains an array of user permissions objects. The "user" field of each object should contain a user ID, and the "role" field one of "NONE", "VIEWER", "CONTRIBUTOR", "EDITOR", or "OWNER", identifying the permissions that will be granted to that user for the given manifest. Specify "user":0 to set permissions for the "public sharing" user. If the merge parameter is false, the contents of the array will completely replace the manifest's existing permissions; if it is true or omitted, only permissions mentioned in the request body will be affected.
Endpoint: /canvas/canvID
Method: GET
Request body: none
Response body: {"id":1001,"index":1,"title":"R3.jpg","width":1472,"height":1000,"images":[{"id":2,"index":0,"uri":"http://localhost:8080/T-PEN/imageResize?folioNum=12841944&height=1000&user=ericsmith@slu.edu","format":"JPEG","width":1472,"height":2000,"canvas":1001}],"manifest":1,"page":1001}
Status: 200 on success, 404 if canvID does not exist.
Comments:
The "index" field contains the canvas' index within the manifest as a whole. For convenience, the response body also contains the canvas' "images" array.
Endpoint: /canvas/canvID
Method: PUT
Request body: {"id":5,"title":"Frontispiece"}
Response body: none
Status: 204 on success, 404 if canvID does not exist.
Comments:
The JSON object in the request body should contain all fields which are to be modified; fields which aren't being changed can be omitted. Changing the canvas' "index" property can be used to reorder canvasses within the manifest.
Endpoint: /canvas/canvID/annotations
Method: POST
Request content-type: application/json
Request body: {"type":"colour","content":"turquoise"}
Response body: none
Response location: /annotation/annID
Status: 201 on success, 404 if canvID does not exist.
Comments:
The request body should contain a single annotation object. The Location header of the response gives the caller the ID of the newly-created annotation.
Endpoint: /canvas/canvID/annotations
Method: GET
Request body: none
Response body: [{"id":36748,"startOffset":0,"endOffset":58,"type":"line","purpose":"LB","content":"de adulterio accussant et non habent latentia peccata uin-","motivation":"sc:painting","canvas":2033,"bounds":{"height":66,"width":601,"y":64,"x":31},"startPage":2033,"endPage":2033},…]
Status: 200 on success, 404 if canvID does not exist.
Comments:
Response contains an array with all annotations found on the given canvas. Since lines are annotations, they will be included in the response.
Endpoint: /canvas/canvID/annotations
Method: PUT
Request body: [{"id":38042,"startOffset":0,"endOffset":46,"type":"line","purpose":"LB","content":"fratres nostri quae acta sunt et quae difinita","motivation":"sc:painting","canvas":2085,"bounds":{"height":50,"width":627,"y":76,"x":40},"startPage":2085,"endPage":2085},…]
Request parameters: merge=true|false (default true)
Response body: none
Status: 204 on success, 404 if canvID does not exist.
Comments:
The JSON array in the request body should contain new values for the canvas' annotations. If the merge parameter is false, the existing annotations will be completely replaced; if it is true or omitted, only annotations mentioned in the request body will be affected.
Endpoint: /canvas/canvID/images
Method: PUT
Request body: [{"id":2,"index":0,"uri":"http://localhost:8080/TPEN/imageResize?folioNum=12841944&height=1000&user=ericsmith@slu.edu","format":"JPEG","width":1472,"height":2000,"canvas":1001},…]
Request parameters: merge=true|false (default true)
Response body: none
Status: 204 on success, 404 if canvID does not exist.
Comments:
The JSON array in the request body should contain new values for the canvas' images. If the merge parameter is false, the existing images will be completely replaced; if it is true or omitted, only images mentioned in the request body will be affected.
Endpoint: /canvas/canvID/lines
Method: GET
Request body: none
Response body: [{"id":37484,"index":0,"annotation":38042,"endOffset":46,"content":"fratres nostri quae acta sunt et quae difinita","startOffset":0,"page":2085},…]
Status: 200 on success, 404 if canvID does not exist.
Comments:
Response contains an array with all lines found on the given canvas. A line is actually an annotation, but with a slightly different set of fields. The "annotation" field of the line object can be used to retrieve the full set of annotation fields.
Endpoint: /canvas/canvID/lines
Method: PUT
Request body: [{"id":38042,"startOffset":0,"endOffset":46,"type":"line","purpose":"LB","content":"fratres nostri quae acta sunt et quae difinita","motivation":"sc:painting","canvas":2085,"bounds":{"height":50,"width":627,"y":76,"x":40},"startPage":2085,"endPage":2085},…]
Request parameters: merge=true|false (default true)
Response body: none
Status: 204 on success, 404 if canvID does not exist.
Comments:
The JSON array in the request body should contain new values for the canvas' lines. If the merge parameter is false the existing lines will be completely replaced; if it is true or omitted, only lines mentioned in the request body will be affected. For the purposes of this endpoint, a canvas' lines are considered to be all annotations whose "purpose" is "line" and whose "canvas" is canvID.
Endpoint: /image/imgID
Method: GET
Request body: none
Response body: Image data (usually image/jpeg).
Status: 200 if image is from a known T-PEN repository, 302 if not.
Comments: Retrieves the given image. If the image's uri field corresponds to a known repository, the image data will be fetched using the T-PEN proxy mechanism. Otherwise, the request will be redirected to the location given in the uri field.
Endpoint: /outline/outlID
Method: GET
Request body: none
Response body: an Outline
Status: 200 on success.
Endpoint: /outline/outlID
Method: PUT
Request body: an Outline
Response body: none
Status: 200 on success.
Endpoint: /outline/outlID
Method: DELETE
Request body: none
Response body: none
Status: 204 on success.
Comments:
Deletes the single outline identified by outlID.
Endpoint: /outline/outlID/approval
Method: PUT
Request content-type: application/json
Request body (optional): [annID₁, annID₂,…]
Response body: none
Status: 204 on success, 403 if the user does not have EDITOR permission on outlID, 404 if outlID does not exist.
Comments:
Sets the approvedBy field of the outline's decisions to the ID of the current user. If the request body contains an array of annotation IDs, only those annotations will be marked as approved. If the request body is absent, all the outline's decisions will be approved.