Forum Discussion

8ccarlile's avatar
8ccarlile
Explorer | Level 3
5 years ago
Solved

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.

  • Здравко's avatar
    Здравко
    Legendary | Level 20

    Hi 8ccarlile,

    You have already everything need to reach file content, using the "2/files/download" API call. 😉

    Hope this helps.

    • 8ccarlile's avatar
      8ccarlile
      Explorer | Level 3

      Hi @

  • Здравко's avatar
    Здравко
    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

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,950 PostsLatest Activity: 2 days ago
351 Following

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!