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 sure if that returns the shared links of that user or their team space.
Thanks in advance for all your help.
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))
- ЗдравкоLegendary | Level 20
Documentation:List shared links of this user. If no path is given, returns a list of all shared links for the current user. For members of business teams using team space and member folders, returns all shared links in the team member's home folder unless the team space ID is specified in the request header.
Have you passed any parameters restricting the set of links? 🧐😉
- JuliaNowickaExplorer | Level 4
No, as I call it for each user on the team, so I'm not sure what that would be. 😅
- Greg-DBDropbox Staff
You can use the Dropbox API to list the shared links for a user. In the Python SDK, you should use sharing_list_shared_links.
Note that by default though, that only lists links in the user's member folder. If the user is on a team with a team space, and you need to list their shared links in the team space, you'd need to configure the call as described in the Team Files Guide to access the team space. With the Python SDK, you'd use the with_path_root method to set that.
- JuliaNowickaExplorer | 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-DBDropbox 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: 14 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!