...
Authentication
Token Authentication
For all REST endpoints, a user has to send a valid API token (see for here for a description how to get a token) to authenticate. Some endpoints can be used without a token when requesting public files. Below descriptions indicate when an endpoint can be used without a token. In general, there are two ways to send a token: as request parameter or as Authorization header (this is the recommended way).
...
Code Block |
---|
accessToken=your-api-token |
Adding Data
Add files to Giles
In theory, you can add any file type you want to Giles. However, only file types supported by Digilib or file types that Giles knows how to convert really make sense. Currently, Giles knows how to convert PDFs to images. Giles is globally configurable in regards to what image type it uses and what DPI when converting PDFs to images (default is tiff/600 dpi). Giles will create one image per PDF page and put all images together into one folder so that you can use Digilib's paginator feature. The original PDF is stored separately outside of Digilib's image folder.
...
Code Block |
---|
{
"errorCode" : "404",
"errorMsg" : "Upload does not exist."
} |
Retrieving Data
Get all uploads of user
...
Code Block |
---|
[
{
"UPMDG2ddX4bDKk": [
{
"id": "FILE0fPS2iO6Ev7g",
"filename": "myfirstfile.pdf"
}
]
},
{
"UPVrMKIv": [
{
"id": "FILEkUcHBh",
"filename": "file2.0.tiff"
}
]
},
{
"UP7R6GOs": [
{
"id": "FILEkUcHBh",
"filename": "myfile2.tiff"
}
]
}
] |
Get image from Digilib
...
- accessToken: an API token that is used to authenticate the uploading user (if possible use the Authorization header instead of this parameter)
- fn: path to image in digilib
- dw or dh: you need at least one size parameter, either width (dw) or height (dh) or both
- any other digilib parameter (optional)
Get public image from Digilib
...
If the requested image is set to public, Giles will return the image from Digilib. Otherwise, you will receive an http status 403 Forbidden.
Get info about upload
...
Code Block |
---|
language | js |
---|
title | Upload Info Sample Response from Giles |
---|
|
[ "documentId" : "DOCOhcqLGMXL8dC",
"uploadId" : "UPMDG2ddX4bDKk",
"uploadedDate" : "2016-10-04T17:40:15.254Z",
"access" : "PUBLIC",
"uploadedFile" : {
"filename" : "your-file.pdf",
"id" : "FILE0fPS2iO6Ev7g",
"url" : "https://your.host/giles/rest/files/FILE0fPS2iO6Ev7g/content",
"path" : "youruser/UPMDG2ddX4bDKk/DOCOhcqLGMXL8dC/your-file.pdf",
"content-type" : "application/pdf",
"size" : 1453836
},
"extractedText" : {
"filename" : "your-file.pdf.txt",
"id" : "FILEjXRK3MKDjcqx",
"url" : "https://your.host/giles/rest/files/FILEjXRK3MKDjcqx/content",
"path" : "youruser/UPMDG2ddX4bDKk/DOCOhcqLGMXL8dC/your-file.pdf.txt",
"content-type" : "text/plain",
"size" : 84313
},
"pages" : [ {
"nr" : 0,
"image" : {
"filename" : "your-file.pdf.0.tiff",
"id" : "FILEgwyK2KjEiniN",
"url" : "https://your.host/giles/rest/digilib?fn=youruser%2FUPMDG2ddX4bDKk%2FDOCOhcqLGMXL8dC%2Fyour-file.pdf.0.tiff",
"path" : "youruser/UPMDG2ddX4bDKk/DOCOhcqLGMXL8dC/your-file.pdf.0.tiff",
"content-type" : "image/tiff",
"size" : 1938832
},
"text" : {
"filename" : "your-file.pdf.0.txt",
"id" : "FILEu3zp4FHaNBEz",
"url" : "https://your.host/giles/rest/files/FILEu3zp4FHaNBEz/content",
"path" : "youruser/UPMDG2ddX4bDKk/DOCOhcqLGMXL8dC/your-file.pdf.0.txt",
"content-type" : "text/plain",
"size" : 3461
}
}, {
"nr" : 1,
"image" : {
"filename" : "your-file.pdf.1.tiff",
"id" : "FILE1vgFj8feXHtG",
"url" : "https://your.host/giles/rest/digilib?fn=username%2FUPMDG2ddX4bDKk%2FDOCOhcqLGMXL8dC%2Fyour-file.pdf.1.tiff",
"path" : "youruser/UPMDG2ddX4bDKk/DOCOhcqLGMXL8dC/your-file.pdf.1.tiff",
"content-type" : "image/tiff",
"size" : 1938382
},
"text" : {
"filename" : "your-file.pdf.1.txt",
"id" : "FILER0t8JQ1WuU94",
"url" : "https://your.host/giles/rest/files/FILER0t8JQ1WuU94/content",
"path" : "youruser/UPMDG2ddX4bDKk/DOCOhcqLGMXL8dC/your-file.pdf.1.txt",
"content-type" : "text/plain",
"size" : 3930
}
}, {
"nr" : 2,
"image" : {
"filename" : "your-file.2.tiff",
"id" : "FILEzQaVarnXZy52",
"url" : "https://your.host/giles/rest/digilib?fn=youruser%2FUPMDG2ddX4bDKk%2FDOCOhcqLGMXL8dC%2Fyour-file.pdf.2.tiff",
"path" : "youruser/UPMDG2ddX4bDKk/DOCOhcqLGMXL8dC/your-file.pdf.2.tiff",
"content-type" : "image/tiff",
"size" : 1809905
},
"text" : {
"filename" : "your-file.pdf.2.txt",
"id" : "FILEFlTXtknorFua",
"url" : "https://your.host/giles/rest/files/FILEFlTXtknorFua/content",
"path" : "youruser/UPMDG2ddX4bDKk/DOCOhcqLGMXL8dC/your-file.pdf.2.txt",
"content-type" : "text/plain",
"size" : 3563
}
} ]
} ] |
Get info about document
...
Code Block |
---|
{
"documentId" : "DOCOhcqLGMXL8dC",
"uploadId" : "UPMDG2ddX4bDKk",
"uploadedDate" : "2016-10-04T17:40:15.254Z",
"access" : "PUBLIC",
"uploadedFile" : {
"filename" : "your-file.pdf",
"id" : "FILE0fPS2iO6Ev7g",
"url" : "https://your.host/giles/rest/files/FILE0fPS2iO6Ev7g/content",
"path" : "youruser/UPMDG2ddX4bDKk/DOCOhcqLGMXL8dC/your-file.pdf",
"content-type" : "application/pdf",
"size" : 1453836
},
"extractedText" : {
"filename" : "your-file.pdf.txt",
"id" : "FILEjXRK3MKDjcqx",
"url" : "https://your.host/giles/rest/files/FILEjXRK3MKDjcqx/content",
"path" : "youruser/UPMDG2ddX4bDKk/DOCOhcqLGMXL8dC/your-file.pdf.txt",
"content-type" : "text/plain",
"size" : 84313
},
"pages" : [ {
"nr" : 0,
"image" : {
"filename" : "your-file.pdf.0.tiff",
"id" : "FILEgwyK2KjEiniN",
"url" : "https://your.host/giles/rest/digilib?fn=youruser%2FUPMDG2ddX4bDKk%2FDOCOhcqLGMXL8dC%2Fyour-file.pdf.0.tiff",
"path" : "youruser/UPMDG2ddX4bDKk/DOCOhcqLGMXL8dC/your-file.pdf.0.tiff",
"content-type" : "image/tiff",
"size" : 1938832
},
"text" : {
"filename" : "your-file.pdf.0.txt",
"id" : "FILEu3zp4FHaNBEz",
"url" : "https://your.host/giles/rest/files/FILEu3zp4FHaNBEz/content",
"path" : "youruser/UPMDG2ddX4bDKk/DOCOhcqLGMXL8dC/your-file.pdf.0.txt",
"content-type" : "text/plain",
"size" : 3461
},
"ocr" : {
"filename" : "your-file.pdf.0.tiff.txt",
"id" : "FILEu3zp4FHaN567",
"url" : "https://your.host/giles/rest/files/FILEu3zp4FHaN567/content",
"path" : "youruser/UPMDG2ddX4bDKk/DOCOhcqLGMXL8dC/your-file.pdf.0.tiff.txt",
"content-type" : "text/plain",
"size" : 3461
}
}, {
"nr" : 1,
"image" : {
"filename" : "your-file.pdf.1.tiff",
"id" : "FILE1vgFj8feXHtG",
"url" : "https://your.host/giles/rest/digilib?fn=youruser%2FUPMDG2ddX4bDKk%2FDOCOhcqLGMXL8dC%2Fyour-file.pdf.1.tiff",
"path" : "youruser/UPMDG2ddX4bDKk/DOCOhcqLGMXL8dC/your-file.pdf.1.tiff",
"content-type" : "image/tiff",
"size" : 1938382
},
"text" : {
"filename" : "your-file.pdf.1.txt",
"id" : "FILER0t8JQ1WuU94",
"url" : "https://your.host/giles/rest/files/FILER0t8JQ1WuU94/content",
"path" : "youruser/UPMDG2ddX4bDKk/DOCOhcqLGMXL8dC/your-file.pdf.1.txt",
"content-type" : "text/plain",
"size" : 3930
},
"ocr" : {
"filename" : "your-file.pdf.1.tiff.txt",
"id" : "FILER123JQ1WuU94",
"url" : "https://your.host/giles/rest/files/FILER123JQ1WuU94/content",
"path" : "youruser/UPMDG2ddX4bDKk/DOCOhcqLGMXL8dC/your-file.pdf.1.tiff.txt",
"content-type" : "text/plain",
"size" : 3930
}
}, {
"nr" : 2,
"image" : {
"filename" : "your-file.pdf.2.tiff",
"id" : "FILEzQaVarnXZy52",
"url" : "https://your.host/giles/rest/digilib?fn=youruser%2FUPMDG2ddX4bDKk%2FDOCOhcqLGMXL8dC%2Fyour-file.pdf.2.tiff",
"path" : "youruser/UPMDG2ddX4bDKk/DOCOhcqLGMXL8dC/your-file.pdf.2.tiff",
"content-type" : "image/tiff",
"size" : 1809905
},
"text" : {
"filename" : "your-file.pdf.2.txt",
"id" : "FILEFlTXtknorFua",
"url" : "https://your.host/giles/rest/files/FILEFlTXtknorFua/content",
"path" : "youruser/UPMDG2ddX4bDKk/DOCOhcqLGMXL8dC/your-file.pdf.2.txt",
"content-type" : "text/plain",
"size" : 3563
},
"ocr" : {
"filename" : "your-file.pdf.2.tiff.txt",
"id" : "FILEFlTXtkn345ua",
"url" : "https://your.host/giles/rest/files/FILEFlTXtkn345ua/content",
"path" : "youruser/UPMDG2ddX4bDKk/DOCOhcqLGMXL8dC/your-file.pdf.2.tiff.txt",
"content-type" : "text/plain",
"size" : 3563
}
} |
...
Get full image from Giles
...
...
...
...
This endpoint can be used without an API token when requesting public files.You can get the original version of a file that you have uploaded through Giles by making a GET request to:
/rest/documentsfiles/{documentIdfileId}/access/changecontent
where {documentIdfileId}
is the id of the document file you want to change the access typeare trying to download.
Giles expects the following parameters:
- accessToken: an API token that is used to authenticate the uploading user (if possible use the Authorization header instead of this parameter)
- access: the new type of access for the specified document:
private
or public
...
Note: when requesting information about an upload, or after uploading a file, the path property of the JSON response will point here for PDF files.
Modifying Data
Change Document Access
...
...
...
...
This features is available with version v0.4.2.You can
...
change the
...
access type of a document (private or public) by making a
...
POST request to:
/rest/filesdocuments/{fileIddocumentId}/contentaccess/change
where {fileIddocumentId}
is the id of the file document you are trying to downloadwant to change the access type.
Giles expects the following parameters:
- accessToken: an API token that is used to authenticate the uploading user (if possible use the Authorization header instead of this parameter)
...
- access: the new type of access for the specified document:
private
or public
Search
Search with Freddie
Starting with version v0.5 documents submitted to Giles can be search if Freddie has been added to the ecosystem.You can search all text documents of a user by making a GET request to:
/rest/search?q={querystring}
where {querystring}
is a Solr query string.
Giles expects the following parameters:
- q: the query string
- accessToken: an API token that is used to authenticate the uploading user (if possible use the Authorization header instead of this parameter)
Giles will respond to a search request with a list of results, similar to:
Code Block |
---|
[{
"id": "FILEqvXix777A6er",
"uploadId": "UPsQY6W7CbBsl1",
"filename": "GraceHopper.pdf.0.txt",
"documentId": "DOC8uY40VmywRMe",
"uploadDate": "2017-04-27T16:33:39.428Z",
"access": "PRIVATE",
"contentType": "text/plain",
"size": 0,
"url": "http://your.giles.host/giles/rest/files/FILEqvXix777A6er/content",
"documentUrl": "http://your.giles.host/giles/rest/documents/DOC8uY40VmywRMe",
"page": 0
}
] |