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
3 years agoExplorer | Level 4
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...
- 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))
JuliaNowicka
Explorer | Level 4
So if I understand correctly, I would need to potentially loop through a list of team folders as well to get all the shared links?
Greg-DB
3 years agoDropbox Staff
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
Find help with the Dropbox API from other developers.
5,882 PostsLatest Activity: 19 hours agoIf 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!