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: 

Check if user shared any links

Check if user shared any links

JuliaNowicka
Explorer | Level 4
Go to solution

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. 

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

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))

 

View solution in original post

5 Replies 5

Здравко
Legendary | Level 20
Go to solution

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? 🧐😉

JuliaNowicka
Explorer | Level 4
Go to solution

No, as I call it for each user on the team, so I'm not sure what that would be. 😅

Greg-DB
Dropbox Staff
Go to solution

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.

JuliaNowicka
Explorer | Level 4
Go to solution

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
Dropbox Staff
Go to solution

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))

 

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    JuliaNowicka Explorer | Level 4
  • User avatar
    Здравко Legendary | Level 20
What do Dropbox user levels mean?