-
Notifications
You must be signed in to change notification settings - Fork 15
The Javascript API Library
The Javascript API library allows developers to programmatically fetch data from the DigiPal database, as alternative to the API by HTTP queries. To use it, you must include the script in your web page, and then use one of the methods provided by the library to start querying DigiPal.
It works both in local DigiPal instances and in your websites.
You can download the script at https://github.com/kcl-ddh/digipal/blob/master/digipal/static/digipal/scripts/api.digipal.js
Include it in your page:
<script src='api.digipal.js'></script>
Alternatively, you can load it from Github:
<script src='[https://raw.githubusercontent.com/kclddh/digipal/master/digipal/static/digipal/scripts/api.digipal.js](https://raw.githubusercontent.com/kclddh/digipal/master/digipal/static/digipal/scripts/api.digipal.js)'></script>
If you are running the script into a DigiPal instance:
var dapi = new DigipalAPI({
crossDomain: false,
root: '/digipal/api'
});
... otherwise just call it without any options:
var dapi = new DigipalAPI();
It is possible to use the API in various ways:
- Specifying the datatype into the URL path through the method request
- By using the datatype as method nameNote that the first two parameters of the methods are required
In the first case, we would have:
var url = 'graph/12453';
dapi.request(url, function(data) {
console.log(data);
});
Instead, in the second case, we can have:
dapi.graph(12453, function(data) {
console.log(data);
});
// or
dapi.image(61, function(data) {
/* ... data ... */
});
It is possible to use the first parameter in various ways: 1. A single id, like in the examples. Ex. 12453 2. An array of ids. Ex. [134, 553, 356] 3. An object representing the fields and chosen values to match the record. Ex. {id: 10, image:61}
// an object representing properties and values
var parameters = {
name: "Square",
character__name: "a"
};
dapi.allograph(parameters, function(data) {
console.log(data);
});
// a list of ids
dapi.image([60, 61], function(data) {
console.log(data);
});
/* Note the paramters select and limit */
dapi.request(url, callback, select, limit)
The parameter select allows to specify the wished fields to be pulled by the request (the field id is always returned). Ex select = ['image'] will return only two fields: id and image.
The parameter limit allows to limit the number of records returned by the request. The default value is 100.
Another example:
dapi.image({
id: 18
}, function(data) {
/* ... your data ... */
}, ['item_part', 'image']);
// or
// note that if select is empty, it will get all the fields to the response
// here we are limiting the number of record returned down to 1
dapi.image({
hands: 35
}, function(data) {
/* ... your data ... */
}, [], 1);
- count: The number of items found
- errors: An array whose first element represents the HTTP
number error (500,400, etc.) and the second element representing
the error message (can be an HTML page)
- results: An array of objects representing the items found
- success: A boolean that specifies whether the call has been successful or not
JS API call:
dapi.graph(234, function(data) {
console.log(data);
});
The result printed will be:
{ "count": 1, "errors": [], "results": [ { "aspects": [], "created": "2012-05-22 13:08:37.072243+00:00", "idiograph__id": 51, "modified": "2013-05-02 10:19:22.364557+00:00", "group": null, "idiograph": "e. DigiPal Scribe 3. Saec. xi1/4", "parts": [], "display_label": "e. DigiPal Scribe 3. Saec. xi1/4. Hand 1 (fols. 70\u201396)", "str": "e. DigiPal Scribe 3. Saec. xi1/4. Hand 1 (fols. 70\u201396)", "id": 234, "annotation__id": null, "hand": "Hand 1 (fols. 70\u201396)", "annotation": null, "hand__id": 636, "graph_components": [] } ], "success": true}
Giancarlo Buomprisco
__
Archetype is maintained by the King's Digital Lab at King's College London. It has received funding from the European Union Seventh Framework Programme (FP7) under Grant Agreement no. 263751 (DigiPal), the Arts and Humanities Research Council (AHRC) under Grant Reference n° AH/L008041/1 (Models of Authority) and AH/L013975/1 (Exon Domesday), and the Faculty of Arts and Humanities at King's College London.
Credits
Getting Started
Using Archetype
The Data Model
Editorial interface
- The Admin Interface
- Adding Items (Manuscripts)
- Adding Images
- Adding Hands and Scribes
- Adding Symbols (Letters)
- Content Permissions
- The Annotation Process
- Linking image regions with text regions
- Rebuilding the Indices
Customising the framework
Archetype for developers
- Installing Archetype on a Web Server
- Bulk Image Upload
- The Javascript API Library
- The Web API Syntax
- Upgrading Archetype
- Contributing to the code (third party development)
- Restoring an Archetype backup
Troubleshooting