xialin
xialin

Reputation: 7756

Dropbox Core API list all folders

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.

Upvotes: 4

Views: 1682

Answers (1)

AChampion
AChampion

Reputation: 30288

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)

Upvotes: 1

Related Questions