Get limited amount of contacts with NextCloud API / Webdav

I develop an app which syncs contacts from / to another server.
My request works fine via webdav and carddav.

But I can only request all contacts from nextcloud at once.
This is absolutely unacceptable for a company which has a million contacts in their database.

Seems there is no solution for paging / limit the response to e.g. 1000 contacts
and get the next 1000 contacts with the next request.

Is there any other solution to receive a limited amount of contacts from Nextcloud backend?

Hi @Gesko,

How does you app function? Does the NC app push the contacts? Or does the other server pull the contacts?


Hi @sebastiank,
it’s a server pull. Well actually is an external app.
I’m doing it like this:

const xmlData = "<?xml version='1.0'?><propfind xmlns='DAV:'><prop><address-data xmlns='urn:ietf:params:xml:ns:carddav'><prop xmlns:card='urn:ietf:params:xml:ns:carddav' name='EMAIL'/></address-data></prop></propfind>";
	const authHeader =  `Basic ${Buffer.from(`${Username}:${accessToken}`).toString('base64')}`
	const responseXML = await axios({
		method: 'PROPFIND',
		url: new URL(`/remote.php/dav/addressbooks/users/${Username}/contacts/`, apiUrl),
		data: xmlData,
		headers: {
		Accept: `application/json`,
		Authorization: authHeader,
		'Depth': 2,
		'Content-Type': 'text/xml'}

I also read about a limit of 5000 contacts per request but this seem to be wrong.
Somebody mentioned it should be possible to limit the result if the request is made directly via webdav without using carddav. But I could not find any more information about it.


Okay, so NC is based on SaberDAV, I did some quick searching on the interweb but couldn’t find an answer to this either.

That leaves you with two choices,
A. you could download a program like DAVx5, and then check the logs on the NC server to see how they handle this.
B. you would need to do more research on this by looking at the SaberDAV docs.

Sorry, wish I could help more.

Alternatively, you might might be interested in a project I am working on. Its an app to pull data from NC in different formats, and record limiting is one of he features I was think about.