One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
8ccarlile
5 years agoExplorer | Level 3
How do I retrieve a file's URL after searching for it using search API call
Hi all,
I'm needing to 1) search Dropbox for all files containing a string, and then 2) get the URLs for all of the files found.
I've set up a Dropbox API call which searches Dropbox for files containing a certain string using
https://api.dropboxapi.com/2/files/search_v2
So far so good, I'm getting a response with the correct files. However in this response, it lists everything about the files (name, path, last modified date/time etc) except for the URL. Is there any way to somehow extend the data presented in the API response? Or is there something else I need to add in to the request's body to return the URL (some kind of metadata call)?
Any help would be much appreciated!
8ccarlile wrote:... Is there any way to somehow extend the data presented in the API response? ...
Hi 8ccarlile,
Seems, my impression related to your final intent is wrong. The fastest way to get actual data of pointed file is using "2/files/download" API call. That's why I pointed this way. If for some reason you prefer web link, then you can get temporary one using "2/files/get_temporary_link" or create permanent using "2/sharing/create_shared_link_with_settings" API call. Already existing permanent link could be received using "2/sharing/list_shared_links" API call. Generally if you want to use file content within the application itself, better download it (one call less). If the content have to be forwarded to some other application, without granted access to the user account (client web browser, for example), then links are better. Temporary or permanent links - depends on what's your objectives. Permanent links let client optimise download speed (already cached content could be skipped) and fester work could be achieved. Temporary links are managed easily inside application and could be good compromise for incidental forwarding. Take in mind, permanent links when received are preview links! To get raw content link replace parameter "?dl=0" to "?raw=1". Once you have found what you're looking for using "2/files/search_v2" and "2/files/search/continue_v2", every metod, just described, gets usable. 😉
Hope this clarifies matter.
- 8ccarlileExplorer | Level 3
Hi @Здравко,
Thank you for your quick reply! I looked at the API response expected with the 2/files/download calll but there's no URL in the example response, would I need to add something else in to the body?
Also as the documents are always changing on Dropbox, so ideally the links would just take you to the file rather than downloading, to ensure that the latest version is being viewed. Is this possible just to pull out the web URL using the /search call?
- ЗдравкоLegendary | Level 20
8ccarlile wrote:... Is there any way to somehow extend the data presented in the API response? ...
Hi 8ccarlile,
Seems, my impression related to your final intent is wrong. The fastest way to get actual data of pointed file is using "2/files/download" API call. That's why I pointed this way. If for some reason you prefer web link, then you can get temporary one using "2/files/get_temporary_link" or create permanent using "2/sharing/create_shared_link_with_settings" API call. Already existing permanent link could be received using "2/sharing/list_shared_links" API call. Generally if you want to use file content within the application itself, better download it (one call less). If the content have to be forwarded to some other application, without granted access to the user account (client web browser, for example), then links are better. Temporary or permanent links - depends on what's your objectives. Permanent links let client optimise download speed (already cached content could be skipped) and fester work could be achieved. Temporary links are managed easily inside application and could be good compromise for incidental forwarding. Take in mind, permanent links when received are preview links! To get raw content link replace parameter "?dl=0" to "?raw=1". Once you have found what you're looking for using "2/files/search_v2" and "2/files/search/continue_v2", every metod, just described, gets usable. 😉
Hope this clarifies matter.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,950 PostsLatest Activity: 2 days ago
If 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!