Here are some guick start quides and code snippets to show you the capabilities of some of the core APIs.
Document types are commonly used to populate selection user interface controls.The JavaScript snippet
below illustrates the creation of a popup menu with document types and the setting of the chosen
value on a document
object:
Displays document reader locations plotted onto a world map. Illustrates implicit OAuth flow, fetching user documents and requesting readership statistics for catalog documents.
Perform a general search where the metadata provided matches any terms.
curl 'https://api.mendeley.com/search/catalog?query=whales' \
-X GET \
-H 'Authorization: Bearer ' \
-H 'Accept: application/vnd.mendeley-document.1+json'
A list of catalog documents is returned from the API resource but only the first item retunred is displayed for brevity. The search query has found all papers with the word whales in any of the fields. Statistics aggregated from all Mendeley users have been provided also.
Perform an advanced search using advanced search operators so that you can get better results. See advanced search
If you have any metadata about the papers you are searching for then you can use the more advanced searching features. The more fields that you provide then the better the results.
At least one of title, author, source or abstract must be provided. If more than one of these is set, the results will return documents which match any of these, but rank those which match several fields higher than those which match fewer fields.
If you would like to filter down the results to a particular year then you can use the min_year and max_year parameters. Setting either a minimum or maximum year excludes documents which do not have a year defined.
Setting the open_access=true
will return just the open access journals.
If you're having trouble narrowing down your search results, you might want to try using our search operators, which you can use to fine-tune your search query. Follow the examples provided below and edit in your own search terms to see the best results.
Search for... | ...to find articles that have |
citation analysis | the words citation or analysis |
citation + analysis | both the words citation and analysis |
ponies | "small horses" | the word ponies OR the exact phrase small horses |
ponies +-"small horses" | the word ponies but NOT the phrase small horses |
Displays current user's documents in their library together with the document annotations. Catalog documents can also be retrieved using a DOI.
Catalog documents can be fetched from the /catalog
API resource using a SHA1 hash of the
file. Compute a hash of the PDF file and use as the value for the filehash
HTTP query
string field. If the response contains a document, the file has been included in the catalog.
openssl sha1 sample.pdf SHA1(/path/to/sample.pdf)= b0b75611366f6a5af8dd906c935f38bf3f509751
curl -H "Authorization: Bearer MSwxNDA5…a1BJUTQ" "https://api.mendeley.com/catalog?filehash=b0b75611366f6a5af8dd906c935f38bf3f509751"
Documents can be created in your library from a PDF. The best metadata available gets returned. It is
either the validated record from our /catalog
, if it's a paper we already know about,
or the data extracted from the PDF, if it's one we've not seen yet. The newly created
document
data will be returned.
curl 'https://api.mendeley.com/documents' \
-X POST \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-H 'Content-Type: application/pdf' \
-H 'Content-Disposition: attachment; filename="example.pdf"' \
--data-binary @example.pdf
To determine if documents in a collection may have files attached, inspect the
file_attached
member of a document. Request all the documents.
GET /documents
{
"id": "1137042a-8c30-3cd6-a7f6-7d5f1f6c450d",
…
"file_attached": true,
…
}
Demonstrates getting all documents in a group.
GET /documents?group_id=77dd7020-e2f6-3fb3-94ea-3cea11555af2
Documents created with a group ID included are inserted into the group. The group must exist and the authorized user must be an owner, administrator or member of the group. Adding a library document to a group, creates a copy of the original document.
POST /documents
{
"group_id":"77dd7020-e2f6-3fb3-94ea-3cea11555af2",
"title": "Map Reduce: Simplified data processing on large clusters",
"type": "journal",
"authors": [
{
"first_name": "Jeffrey",
"last_name": "Dean"
},
{
"first_name": "Sanjay",
"last_name": "Ghemawat"
}
],
"year": 2008
}
To determine if a single document has a file attached.
GET /files?document_id=1137042a-8c30-3cd6-a7f6-7d5f1f6c450d
An empty array in the response indicates the document does not have files attached.
To determine if documents in a collection may have files attached, inspect the
file_attached
member of a document. Request the documents with a
client
or all
value for the view
HTTP query string field.
{
"id": "1137042a-8c30-3cd6-a7f6-7d5f1f6c450d",
…
"file_attached": true,
…
}
Demonstrates downloading a media file.
GET /files/1137042a-8c30-3cd6-a7f6-7d5f1f6c450d
The successful API response will have:
303 See Other
HTTP statusLocation
header containing a link to the file locationThe Location header contains a URL value to download the media file. The URL will only remain valid for a short period of time so your application should not cache these values and should only request a location just before the application intends to download the media file. The URL location, format and authorization mechanism are subject to change and your application must not attempt to parse the download URL.
HTTP/1.1 303 See Other
Location: Location: https://mendeley-files.s3.amazonaws.com/0c/07/0c071302a58db1e471c0923deeb9f47c5cd2f63d?response-content-disposition%3Dattachment%3Bfilename%3D%E2%80%9CReport.pdf%22&response-content-type=application%2Fpdf&AWSAccessKeyId=AKIAJGTIMKBSM3FEA25A&Expires=1409062238&Signature=aLU%2F%2FaqPGYgmiTCgHuKT%2B%2F%2BgWNk%3D
Content-Length: 0
Once the file has completely downloaded to local storage, your application should ensure file integrity by comparing the file size or a SHA1 hash to the API response file metadata.
// API response for file:
{
"id":"76d0efcb-2690-507f-07b7-21234c617b03",
"document_id":"1137042a-8c30-3cd6-a7f6-7d5f1f6c450d",
"mime_type":"application/pdf",
"file_name":"Report.pdf",
"size":6123,
"filehash":"0c071302a58db1e471c0923deeb9f47c5cd2f63d"
}
stat -f %z report.pdf
6123
openssl sha1 report.pdf
SHA1(/path/to/report.pdf)= 0c071302a58db1e471c0923deeb9f47c5cd2f63d
Each file upload request transfers the media data and creates a new object to reference the media file. Files are uploaded using a POST request with HTTP headers containing the metadata and the body containing the media data. Four additional HTTP headers and values.
POST /files HTTP/1.1
Authorization: Bearer MSwxNDA5MDU0ODM0MTQy…zFJd0liZHpSMVU
Link: <https://api.mendeley.com/documents/1137042a-8c30-3cd6-a7f6-7d5f1f6c450d>; rel="document"
Content-Disposition: attachment; filename="report.pdf"
Content-Type: application/pdf
Content-Length: 6123
[binary data in the request body]
The request HTTP header values should be:
Link
document
relationship must contain the URL to the intended parent document.
Content-Disposition
attachment
and your application can use the filename
qualifier to suggest a filename.Content-Type
application/octet-stream
.Content-Length
A successful file upload generates an HTTP response with:
201 Created
.Location
header containing the URL of the newly created file.File objects are immutable and can not be updated. Your client application should replace the document's file in an atomic manner by:
The owner of a group has a profile identifier that can be used to retrieve metadata for the group owner.
GET /groups/{id}
.owning_profile_id
from the
response.GET /profiles/{id}
.
When creating a new folder, include a value for a parent folder's identifier in the request's body.
POST /folders
{
"name":"Untitled folder",
"parent_id":"95342445-ab75-42ba-b98f-888bbe543c0f"
}
When creating a new folder, include a value for the group's identifier in the request's body.
POST /folders
{
"name":"デジタルコンテンツ",
"group_id":"9ab2887c-9b1c-38d7-a64a-3491306362a7"
}
Update the value of the parent_id
member to move a folder within a hierarchy. A folder
can not be moved into itself or any of it's descendent child folders.
PATCH /folders/9ab2887c-9b1c-38d7-a64a-3491306362a7
{
"parent_id":"95342445-ab75-42ba-b98f-888bbe543c0f"
}
It is not possible to list the child folders of a folder directly using the API. Your application
should construct a tree model of folders by parsing the results of /folders
and using
the value of the parent_id
member to establish a parent relationship.
Update the parent_id
value of a folder to the special value root to remove any
previous parent folder.
PATCH /folders/9ab2887c-9b1c-38d7-a64a-3491306362a7
{
"parent_id":"root"
}
Document types are commonly used to populate selection user interface controls.The JavaScript snippet
below illustrates the creation of a popup menu with document types and the setting of the chosen
value on a document
object:
…
<select id="doc_type_popup" onchange="docTypeDidChange(this);"></select> <!-- the popup menu in the HTML -->
…
function processDocumentTypesResponse(xmlhttp) {
// in the successful response to an AJAX request for /document_types
data = JSON.parse(xmlhttp.responseText);
popup_menu = document.getElementById("doc_type_popup");
for (i=0;i<types.length;i++) {
var option = document.createElement("option");
option.textContent = types[i].description; // set the label visible to the user
option.value = types[i].name; // set the data value
popup_menu.appendChild(option);
}
}
function docTypeDidChange(sender) {
selectedDocument.type = sender.value; // assume selectedDocument is a JS object
}