API v2 Documentation (beta)

 

Version 2 of the Giles API does not require Giles tokens anymore. Instead, Citesphere tokens can be used. The following describes the endpoints that have been implemented so far.

This API is currently under development. Please keep in mind that things could change.

Authentication

To authenticate, simply send a Citesphere user token to Giles as Bearer header.

Authorization: Bearer your-citesphere-token

Giles will check with Citesphere if the user that the passed token belongs to has access to the requested document.

Adding Data 

Add files to Giles 

POST

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.

You can add files to Giles by making a POST request to:

/api/v2/files/upload

You request should be made with a content-type header of:

multipart/form-data

Giles expects the following parameters:

  • access (optional): access policy for uploaded files; possible values are PRIVATE or PUBLIC; default is PRIVATE.

  • document_type (optional): specifies if uploaded files are several pages of the same document (MULTI_PAGE) or if they should be uploaded as separate documents (SINGLE_PAGE); default is SINGLE_PAGE.

  • files: the files to be uploaded

A valid request would look something like this:

Giles will respond with an progress id and a url to check the progress of the upload:

You can now poll the url provided as 'checkUrl'. As long as the upload hasn't finished yet, you will get a 202 Accepted response with the following response body:

As of version v0.5, Giles will also supply the URL of the upload itself. Keep in mind, however, that requests to this URL will return incomplete results as long as processing of a file is ongoing. Only the poll URL will indicate when processing has finished.

Once uploading has finished, you will retrieve the complete information as listed below.

Upload Image Sample Response from Giles

Checking the Progress of an Upload

GET /api/v2/files/upload/check/{progress_id}

You can get information about the status of an upload via this endpoint by providing the progress id of an upload.

The response will look something like this:

You can use the upload id to get more details about the upload. If an upload has not been completely processed, the upload endpoint will return incomplete data.

Depending on if it is an error or not, the provided code will be in a different json property. Possible message codes, this endpoint returns are:

Json property

Code

Description

Json property

Code

Description

errorCode

404

An upload with the provided progress id does not exist.

msgCode

010

Processing of the upload is in progress.

Besides this, the endpoint may return the following HTTP status codes:

Status Code

Description

Status Code

Description

200 OK

Upload has been processed.

202 Accepted

Processing in progress

403 Forbidden

User does not have access to upload.

404 Not Found

Upload with provided progress id does not exist.

500 Internal Server Error

Something went wrong on Giles' side.

Retrieving Data

Getting info about an upload

GET /api/v2/resources/files/upload/{upload_id}

You can get information about an upload by making a GET request to:

where {upload_id} is the id of the upload you are requesting information about.

  • Note that this endpoint will return incomplete data if an upload is still being processed.

  • Also note that the returned url properties are to the v1 version of the api and should therefore not be used.

A response looks something like this:

Getting info about a document

GET /api/v2/resources/documents/{documentId}

This endpoint can be used without an API token when requesting public files.

Starting with version v0.8, the returned json contains lists of additional files for the uploaded document and each page (as shown in the example below). Before version v0.8, the additionalFiles sections are not included.

You can get information about a document by making a GET request to:

where {documentId} is the id of the upload you are requesting information about.

A response looks similar to this:

Get full image from Giles

GET  

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:

where {fileId} is the id of the file you are trying to download.

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.

Note: this will only work for files that have been uploaded using version 2 of the API. For previously uploaded document, use the original API.