mendeley

Mendeley - how to get paginated response using the new documents API


As part of migration from oapi to the new api, I am replacing a call that used the "library" api with a new call that now uses the "documents" api ( since the "library" api is not available anymore).

Here is what the request looks like : https://api.mendeley.com/documents?limit=5 ( with the token in the header).

The response is just JSON data for the documents in the library.I am not getting the fields like - total_results, total_pages, current_page etc. in the response.

How can I get the total_results, total_pages, current_page data etc. in the response.

Thanks, Prasad


Solution

  • The total results is returned in the response in a header called - Mendeley-Count: XXXX. This header is only included in the first page of a paged results set so your application should retrieve this value before requesting other result pages.

    You don't need to know the total_pages or current_pages as we have abstracted this away in the link headers. All you have to do is follow these links.

    There is a worked example here and it working with collections is documented here