You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

JuliaNowicka's avatar
JuliaNowicka
Explorer | Level 4
3 years ago

Check if user shared any links

Hello, I need to check how many links user has shared and how many of them are public links. Is this possible using the Dropbox API? I'm using the get_shared_links endpoint at the moment, but I'm not...
  • Greg-DB's avatar
    Greg-DB
    3 years ago

    For a user not on a team with a team space, you can just use sharing_list_shared_links, without setting the path root, to get all the shared links for that user, since their member folder is their root anyway.

     

    For a user on a team with a team space, you should still use sharing_list_shared_links, but you would need to set the path root to their team space if you need to list all their shared links, including those in both their team space and member folder.

     

    This code should illustrate how to count all shared links for either type, checking for and rooting from a team space if present:

    dbx = dropbox.Dropbox(ACCESS_TOKEN)
    
    current_account = dbx.users_get_current_account()
    if isinstance(current_account.root_info, dropbox.common.TeamRootInfo):
    	dbx = dbx.with_path_root(dropbox.common.PathRoot.root(current_account.root_info.root_namespace_id))
    
    links = []
    
    res = dbx.sharing_list_shared_links()
    links += res.links
    
    while res.has_more:
    	res = dbx.sharing_list_shared_links(cursor=res.cursor)
    	links += res.links
    
    print(len(links))

     

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,882 PostsLatest Activity: 18 hours ago
325 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!