Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Fix links to pagination section

...

Another thing to note is that there are Query Parameters that you can tack on to the end of an endpoint to do extra things. The most commonly used one in this API is "?expand". Instead of every API call defaulting to giving you every possible piece of information about it, it only gives a most commonly used set by default and gives the more "expensive" information when you deliberately request it. Each endpoint will provide a list of available expands in the output, but for getting started, you can start with ?expand=all, to make the endpoint provide all of its information (parent objects, metadata, child objects). You can include multiple expands, such as: ?expand=collections,subCommunities.

Pagination

Anchor
Pagination
Pagination

DSpace 6.x supports pagination by allowing two query parameters: limit and offset. Note however that the aggregate results number is not supplied (see DS-3887). Endpoints which return arrays of objects, such as /communities, /collections or /items, are "paginated":  the full list is broken into "pages" which start at offset from the beginning of the list and contain at most limit elements.  By repeated queries you can retrieve any portion of the array or all of it.  The default value of offset  is 0 and the default value of limit is 100.  So, as an example, to retrieve the sixth through tenth elements of the full list of Collections, you could do this:

...

MethodEndpointDescription
GET/

REST API static documentation page listing available endpoints and their function.


Example:

https://demo.dspace.org/rest

POST/login

Login to the REST API using a DSpace EPerson (user). It returns a JSESSIONID cookie, that can be used for future authenticated requests.

Example Request:

Code Block
# Can use either POST or GET (POST recommended). Must pass the parameters "email" and "password".
curl -v -X POST --data "email=admin@dspace.org&password=mypass" https://dspace.myu.edu/rest/login

Example Response:

Code Block
HTTP/1.1 200 OK
Set-Cookie: JSESSIONID=6B98CF8648BCE57DCD99689FE77CB1B8; Path=/rest/; Secure; HttpOnly

Example of using JSESSIONID cookie for subsequent (authenticated) requests:

Code Block
curl -v --cookie "JSESSIONID=6B98CF8648BCE57DCD99689FE77CB1B8" https://dspace.myu.edu/rest/status
# This should return <authenticated>true</authenticated>, and information about the authenticated user session

Invalid email/password combinations will receive an HTTP 401 Unauthorized response.

Please note, special characters need to be HTTP URL encoded.
For example, an email address like dspacedemo+admin@gmail.com (notice the + special character) would need to be encoded as dspacedemo%2Badmin@gmail.com.

GET/shibboleth-login

Login to the REST API using Shibboleth authentication. In order to work, this requires additional Apache configuration. To authenticate, execute the following steps:

1. Call the REST Shibboleth login point with a Cookie jar:

Code Block
curl -v -L -c cookiejar "https://dspace.myu.edu/rest/shibboleth-login"

2. This should take you again to the IdP login page. You can submit this form using curl using the same cookie jar. However this is IdP dependant so we cannot provide an example here.

3. Once you submit the form using curl, you should be taken back to the /rest/shibboleth-login URL which will return you the JSESSIONID.

4. Using that JSESSIONID, check if you have authenticated successfully:

Code Block
curl -v "http://localhost:8080/dspace-rest/status" --cookie "JSESSIONID=0633C6379266A283E53F65DF8EF61AB9"


POST/logout

Logout from the REST API, by providing a JSESSIONID cookie. After being posted this cookie will no longer work.

Example Request:

Code Block
curl -v -X POST --cookie "JSESSIONID=6B98CF8648BCE57DCD99689FE77CB1B8" https://dspace.myu.edu/rest/logout

After posting a logout request, cookie is invalidated and the "/status" path should show you as unauthenticated (even when passing that same cookie). For example:

Code Block
curl -v --cookie "JSESSIONID=6B98CF8648BCE57DCD99689FE77CB1B8" https://dspace.myu.edu/rest/status
# This should show <authenticated>false</authenticated>

Invalid token will result in HTTP 400 Invalid Request

GET/test

Returns string "REST api is running", for testing that the API is up.

Example Request:

Code Block
curl https://demo.dspace.myu.edu.org/rest/test

https://demo.dspace.org/rest/test

Example Response:

Code Block
REST api is running.


GET/status

Receive information about the currently authenticated user token, or the API itself (e.g. version information).

Example Request (XML by default):

Code Block
curl -v --cookie "JSESSIONID=6B98CF8648BCE57DCD99689FE77CB1B8" https://demo.dspace.myu.eduorg/rest/status

https://demo.dspace.org/rest/status

Example Request (JSON):

Code Block
curl -v -H "Accept: application/json" --cookie "JSESSIONID=6B98CF8648BCE57DCD99689FE77CB1B8" https://demo.dspace.myu.eduorg/rest/status

Example JSON Response:

Code Block
{
  "okay":true,
  "authenticated":true,
  "email":"admin@dspace.org",
  "fullname":"DSpace Administrator",
  "sourceVersion":"6.0",
  "apiVersion":"6"
}


...

For an alternative way to create a Community/Collection hierarchy to the REST API take a look at Importing Community and Collection Hierarchy.


HTTP methodREST endpointDescription
GET/communities
Returns

Return an array of all the communities in the repository. The results are paginated.

Example:

https://demo.dspace.org/rest/communities

GET/communities/top-communities
Returns GET/communities/{communityId}Returns  community.

Return an array of all top-level communities.

 The results are paginated.

Example:

https://demo.dspace.org/rest/communities/top-communities

GET/communities/{
communityId
community id}
/collections

Return the specified

Returns array of collections of a

community.

GET

Example:

/communities/{communityId}/communitiesReturns

https://demo.dspace.org/rest/communities/e97b847b-2fd5-4751-8d91-fcf0d8895b81

GET/communities/{community id}/collectionsReturn an array of collections of the specified community. The results are paginated.
GET/communities/{community id}/communitiesReturn an array of sub-communities of
a community
the specified community. The results are paginated.
POST/communitiesCreate a new community at top level. You must
post
POST a community object data type.
POST/communities/{
communityId
community id}/collectionsCreate a new collections in the specified community. You must
post Collection
POST a collection object data type.
POST/communities/{
communityId
community id}/communitiesCreate a new sub-community in the specified community. You must
post Community
POST a community object data type.
PUT/communities/{
communityId
community id}Update the specified community. You must
put Community
PUT a community object data type.
DELETE/communities/{
communityId
community id}Delete the specified community.
DELETE/communities/{
communityId
community id}/collections/{
collectionId
collection id}Delete the specified collection in the specified community.
DELETE/communities/{
communityId
community id}/communities/{
communityId2
sub-community id}Delete the specified sub-community in the specified community.


Collections

Collections in DSpace are containers of Items. (ex: Engineering Faculty Publications).

For an alternative way to create a Community/Collection hierarchy to the REST API take a look at Importing Community and Collection Hierarchy.

HTTP methodREST endpointDescription
GET/collectionsReturn an array of all the collections in
array. Use the limit parameter to control items per response (default 100) and offset for paging
the repository. The results are paginated.
GET/collections/{
collectionId
collection id}Return the specified collection
with id
.
GET/collections/{
collectionId
collection id}/itemsReturn an array all items of the specified collection. The results are paginated.
POST/collections/{
collectionId
collection id}/itemsCreate
posted
an item in the specified collection. You must
post an Item
POST an item object data type.
POST/collections/find-collectionFind collection by passed name. Returns the first exact match or nothing. You must POST a single string, not a JSON object.
PUT/collections/{
collectionId
collection id}Update the specified collection. You must
put Collection
PUT a collection object data type.
DELETE/collections/{
collectionId
collection id}Delete the specified collection
from DSpace
.
DELETE/collections/{
collectionId
collection id}/items/{
itemId
item id}Delete the specified item in the specified collection.


Items

Items in DSpace represent a "work" and combine metadata and files, known as Bitstreams.

HTTP methodREST endpointDescription
GET/items

Return

list

an array of all the items in the repository. The results are paginated.

Example:

https://demo.dspace.org/rest/items

GET/items/{item id}Return the specified item.
GET/items/{item id}/metadataReturn metadata of the specified item
metadata
.
GET/items/{item id}/bitstreamsReturn
item bitstreams
an array of all the bitstreams of the specified item. The results are paginated.
POST/items/find-by-metadata-fieldFind items by metadata entry. You must
post a MetadataEntry
POST a metadataentry object data type.
POST/items/{item id}/metadataAdd metadata to the specified item. You must
post
POST an array of
MetadataEntry
metadataentry object data type.
POST/GET/items/{item id}/bitstreams?name={file name}

Add bitstream to

item. You must post a Bitstream.

the specified item. You must POST the file data and include the name parameter with the value as {file name} in the URL posted to.


Optional query parameters:

description: A description of the bitstream.

groupId: Id of group to set item resource policy to.

year: Year to set embargo date to

month: Month to set embargo date to

day: Day of month to set embargo date to


Example:

/items/{item id}/bitstreams?name=The%20Children%27s%20Crusade%3A%20A%20Duty-Dance%20with%20Death.pdf&description=All%20this%20happened%2C%20more%20or%20less.&groupID=1969&year=2045&month=2&day=13

PUT/items/{item id}/metadataUpdate metadata in the specified item. You must
put a MetadataEntry
PUT a metadataentry object data type.

Each metadata entry that will replace all prior matching metadata entries, i.e. if you submit n 'dc.subject' entries all pre-existing 'dc.subject' entries in the item will be deleted and replaced with the n entries
DELETE/items/{item id}Delete the specified item.
DELETE/items/{item id}/metadataClear the metadata of the specified item
metadata
.
DELETE/items/{item id}/bitstreams/{bitstream id}Delete
item
the specified bitstream of the specified bitstream.

Bitstreams

Bitstreams are files. They have a filename, size (in bytes), and a file format. Typically in DSpace, the Bitstream will the "full text" article, or some other media. Some files are the actual file that was uploaded (tagged with bundleName:ORIGINAL), others are DSpace-generated files that are derivatives or renditions, such as text-extraction, or thumbnails. You can download files/bitstreams. DSpace doesn't really limit the type of files that it takes in, so this could be PDF, JPG, audio, video, zip, or other. Also, the logo for a Collection or a Community, is also a Bitstream..

HTTP methodREST endpointDescription
GET/bitstreams

Return an array of all the bitstreams in the repository. The results are paginated.

Example:

http://demo.dspace.org/rest/bitstreams

HTTP methodREST endpointDescriptionGET/bitstreamsReturn all bitstreams.

GET/bitstreams/{bitstream id}Return the specified bitstream.
GET/bitstreams/{bitstream id}/policyReturn bitstream policies.
GET/bitstreams/{bitstream id}/retrieveReturn data of bitstream.
POST/bitstreams/{bitstream id}/policyAdd policy to item. You must
post a ResourcePolicy
POST a resourcepolicy object data type.
PUT/bitstreams/{bitstream id}/dataUpdate the data/file of the specified bitstream. You must
put
PUT the data.
PUT/bitstreams/{bitstream id}Update metadata of the specified bitstream. You must
put
PUT a
Bitstream
bitstream, does not alter the file/data.
DELETE/bitstreams/{bitstream id}Delete the specified bitstream.
DELETE/bitstreams/{bitstream id}/policy/{policy
_
id}Delete the specified resource policy of the specified bitstream
policy
.


You can access the parent object of a Bitstream (normally an Item, but possibly a Collection or Community when it is its logo) through: /bitstreams/:bitstreamID?expand=parent

...

In DSpace, Communities, Collections, and Items typically get minted a Handle Identifier. You can reference these objects in the REST API by their handle, as opposed to having to use the internal item-ID.

HTTP methodREST endpointDescription
GET/handle/{handle
-
prefix}/{handle
-
suffix}Returns a Community, Collection, or Item object that matches that handle.

Hierarchy

Assembling a full representation of the community and collection hierarchy using the communities and collections endpoints can be inefficient. Retrieve a lightweight representation of the nested community and collection hierarchy.  Each node of the hierarchy contains minimal information (id, handle, name).

HTTP methodREST endpointDescription
GET/hierarchyRetrieve a lightweight representation of the nested community and collection hierarchy.

Schema and Metadata Field Registry

HTTP methodREST endpointDescription
GET/registries/schemaReturn
the list of schemas
an array of all the schema in the registry
GET/registries/schema/{schema
_
prefix}
Returns
Return the specified schema
GET/registries/schema/{schema
_
prefix}/metadata-fields/{element}
Returns
Return the metadata field within a schema with an unqualified element name
GET/registries/schema/{schema
_
prefix}/metadata-fields/{element}/{qualifier}
Returns
Return the metadata field within a schema with a qualified element name
GET
POST/registries/
metadata-fields/{field_id}
schema/Add a schema to the schema registry. You must POST a schema object data type.
POST/registries/schema/{schema prefix}/metadata-fieldsAdd a metadata field to the specified schema
POST
. You must POST a metadatafield object data type.
GET/registries/
schema
metadata-fields/{
schema_prefix}/metadata-fields
field id}Return the specified metadata field
PUT/registries/metadata-fields/{field
_
id}Update the specified metadata field
DELETE/registries/metadata-fields/{field
_
id}Delete the specified metadata field from the metadata field registry
DELETE/registries/schema/{schema
_
id}Delete the specified schema from the schema registry


Note: since the schema object contains no data fields, the following method has not been implemented:  PUT PUT /registries/schema/{schema _ id}

Report Tools

Reporting Tools that allow a repository manager to audit a collection for metadata consistency and bitstream consistency.  See REST Based Quality Control Reports for more information or test the Collection Report Tool or Metadata Query Tool on demo.dspace.org.

HTTP methodREST endpointDescription
GET/reportsReturn a list of report tools built on the
rest api
REST API
GET/reports/{nickname}Return a redirect to a specific report
GET/filtersReturn a list of use case filters available for quality control reporting
GET/filtered-collectionsReturn collections and item counts based on pre-defined filters
GET/filtered-collections/{collection
_
id}Return items and item counts for a collection based on pre-defined filters
GET/filtered-itemsRetrieve a set of items based on a metadata query and a set of filters


Model - Object data types

...

Anchor
Community Object
Community Object

Code Block
{
  "id":456,
  "name":"Reports Community",
  "handle":"10766/10213",
  "type":"community",
  "link":"/rest/communities/456",
  "expand":["parentCommunity","collections","subCommunities","logo","all"],
  "logo":null,
  "parentCommunity":null,
  "copyrightText":"",
  "introductoryText":"",
  "shortDescription":"Collection contains materials pertaining to the Able Family",
  "sidebarText":"",
  "countItems":3,
  "subcommunities":[],
  "collections":[]
}

Collection Object

Anchor
Collection object
Collection object

Code Block
{
  "id":730,
  "name":"Annual Reports Collection",
  "handle":"10766/10214",
  "type":"collection",
  "link":"/rest/collections/730",
  "expand":["parentCommunityList","parentCommunity","items","license","logo","all"],
  "logo":null,
  "parentCommunity":null,
  "parentCommunityList":[],
  "items":[],
  "license":null,
  "copyrightText":"",
  "introductoryText":"",
  "shortDescription":"",
  "sidebarText":"",
  "numberItems":3
}
}

Item Object

Anchor
Item object
Item

...

object

Code Block
{
  "id":14301,
  "name":"2015 Annual Report",
  "handle":"123456789/13470",
  "type":"item",
  "link":"/rest/items/14301",
  "expand":["metadata","parentCollection","parentCollectionList","parentCommunityList","bitstreams","all"],
  "lastModified":"2015-01-12 15:44:12.978",
  "parentCollection":null,
  "parentCollectionList":null,
  "parentCommunityList":null,
  "bitstreams":null,
  "archived":"true",
  "withdrawn":"false"
}

Bitstream Object

Anchor
Bitstream object
Bitstream object

Code Block
{
  "id":47166,
  "name":"appearance and physiology 100 percent copied from wikipedia.pdf",
  "handle":null,
  "type":"bitstream",
  "link":"/rest/bitstreams/47166",
  "expand":["parent","policies","all"],
  "bundleName":"ORIGINAL",
  "description":"","all"]
  "format":"Adobe PDF",
  "mimeType":"application/pdf",
  "sizeBytes":129112,
  "parentObject":null,
  "bundleNameretrieveLink":"ORIGINAL/bitstreams/47166/retrieve",
  "checkSum":{"descriptionvalue":"62778292a3a6dccbe2662a2bfca3b86e",
  "formatcheckSumAlgorithm":"Adobe PDFMD5"},
  "mimeTypesequenceId":"application/pdf",1,
  "policies":null
}

ResourcePolicy Object

Anchor
ResourcePolicy Object
ResourcePolicy Object

Code Block
{
  "sizeBytesid":129112317127,
  "parentObjectaction":null"READ",
  "retrieveLinkepersonId":"/bitstreams/47166/retrieve"-1,
  "checkSumgroupId":{"value0,
  "resourceId":"62778292a3a6dccbe2662a2bfca3b86e","checkSumAlgorithm47166,
  "resourceType":"MD5bitstream"},
  "sequenceIdrpDescription":1null,
  "policiesrpName":null
}

ResourcePolicy Object

Code Block
[{ "id":317127,
   "actionrpType":"READTYPE_INHERITED",
   "epersonIdstartDate":-1null,
   "groupId":0,
 endDate":null
}

MetadataEntry Object

Anchor
MetadataEntry object
MetadataEntry object

Code Block
{
  "resourceIdkey":47166"dc.description.abstract",
   "resourceTypevalue":"bitstream",
This is the "rpDescription":nulldescription abstract",
   "rpNamelanguage":null, null
}

Schema Object

Anchor
Schema object
Schema object

Code Block
{
   "rpTypenamespace":"TYPE_INHERITED "example.org/myschema",
   "startDateprefix":null,
   "endDatemyschema":null
}]

...

MetadataField Object

Anchor
MetadataField object
MetadataField object

Code Block
{
  "keydescription" :"dc.description.abstract "myschema test field",
  "valueelement" : "test"This,
 is the"name" description abstract: "myschema.test",
  "languagequalifier": null
}

User Object

Code Block
{
  "email":"test@dspace.org",
  "password":"pass"
}

Status Object

Code Block
{
  "okay":true,
  "authenticated":true,
  "email":"test@dspace.org",
  "fullname":"DSpace Test User",
  "token":"6d45daaa-7b02-4ae7-86de-a960838fae5c"
}

...

Usage examples can be found at: https://github.com/BrunoNZ/dspace-rest-requests

A tutorial on item deposits, together with Postman examples is available at

Widget Connector
urlhttp://youtube.com/watch?v=wBh2-0YRYHQ