cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: ListFolder limit?

ListFolder limit?

AlexBrajkovic
Explorer | Level 4
Go to solution

What is the limit of retrieved items using listFolder?

When using listFolderContinue, what will be response? All data, including files/folders from previous call to listfolder) or just additional missing files/folders?

1 Accepted Solution

Accepted Solutions

jwpegram
Helpful | Level 6
Go to solution

I don't see where there is an actual limit that you can set, it seems to be arbitrary. That said, basically when you make the initial post to list_folder that will return some number of entities along with a cursor value and a has_more value. Think of the cursor as a page value that already knows the user being queried and other information so all you have to post to list_folder/continue all you have to send it is the cursor value. That will return the next page of entities along with another cursor for the page after that, and so on until cursor is returned empty.  Not sure what language you are using but I'm doing it like this in PHP.

 

$first_page = true;

$api = $first_page ? 'https://api.dropboxapi.com/2/files/list_folder' : 'https://api.dropboxapi.com/2/files/list_folder/continue';

do {

 

if ($first_page) {

    $data = json_encode(array(
        "path" => "",
        "recursive" => true,
        "include_media_info" => false,
        "include_deleted" => true,
        "include_has_explicit_shared_members" => false,
    ));

    $first_page = false;

} else {

     $data = json_encode(array(
        'cursor' => $cursor
    ));

}

 

... Make the call out to the endpoint and get the response ($response);

 

} while {$response->has_more);

 

After the first call out $first_page is set to false so if $response->has_more returns 1 the cursor is sent page requesting the next page.  Once you hit the end $response->has_more will be empty.

 

Hope that helps.

View solution in original post

2 Replies 2

jwpegram
Helpful | Level 6
Go to solution

I don't see where there is an actual limit that you can set, it seems to be arbitrary. That said, basically when you make the initial post to list_folder that will return some number of entities along with a cursor value and a has_more value. Think of the cursor as a page value that already knows the user being queried and other information so all you have to post to list_folder/continue all you have to send it is the cursor value. That will return the next page of entities along with another cursor for the page after that, and so on until cursor is returned empty.  Not sure what language you are using but I'm doing it like this in PHP.

 

$first_page = true;

$api = $first_page ? 'https://api.dropboxapi.com/2/files/list_folder' : 'https://api.dropboxapi.com/2/files/list_folder/continue';

do {

 

if ($first_page) {

    $data = json_encode(array(
        "path" => "",
        "recursive" => true,
        "include_media_info" => false,
        "include_deleted" => true,
        "include_has_explicit_shared_members" => false,
    ));

    $first_page = false;

} else {

     $data = json_encode(array(
        'cursor' => $cursor
    ));

}

 

... Make the call out to the endpoint and get the response ($response);

 

} while {$response->has_more);

 

After the first call out $first_page is set to false so if $response->has_more returns 1 the cursor is sent page requesting the next page.  Once you hit the end $response->has_more will be empty.

 

Hope that helps.

Greg-DB
Dropbox Staff
Go to solution
Thanks jwpegram! That's correct, the listFolderContinue response will be structured similarly to listFolder, and will only contain further/new entries, not the same entries already returned by listFolder.

Also, each listFolder/Continue response generally won't be more than around 2,000 items, but that can vary, so don't rely on that number.
Need more support?