4
votes

So I have been playing with Dropbox APIs for awhile. My app is retrieving all the image files from a user's dropbox via Core API.

Now I want to improve it a bit by allowing users to choose which folder to sync.. i.e. once they authorise the app, it will give them all the folders inside their account. Users can then choose one or many folder(s), the app will only retrieve image files from selected folders.

Is there a specific API that list out all folders inside a user's dropbox?

I'm not using any SDK.

1

1 Answers

1
votes

Using the https://api.dropbox.com/1/metadata/dropbox/<path> gives you the details of the contents of directory

import requests
...
headers = ... # set up auth
...
params = { 'list' : 'true' }
response = requests.get('https://api.dropbox.com/1/metadata/dropbox/<directory>', params=params, headers=headers)
subdirs = [d['path'] for d in response.json()['contents'] if d['is_dir'] == True]    
print(subdirs)