How to Download files in bulk with collaboration and file info by single rest api call?
Do we have any Rest API so, we can get all files from It's Folders and Sub-Folders with below information in a single API call?
1. Owner of the files.
2. Version information of the files.
3. Content of the files.
4. Collaboration information of the files
In API documentation one Download zip archive( https://developer.box.com/reference/get-zip-downloads-id-content/ ) Rest-API is available but It's not useful in my case as it not contains all above information and we don't want to make multiple API calls due to some performance issue.
We will really appreciate if some one can help us on this.
-
Hi Vivek,
Unfortunately not all in one API call. Here's the sequence of how I might set this up if I needed that information:
- Get the list of all items in a folder using the list file items endpoint.
Then, for each item in the return from #1:
- Call the download file endpoint to get the file content (contains what you need for #3).
- Call the get file information endpoint to get file information (contains what you need in #1 and #2). I believe you'll need to also set "version_number" in the "fields" parameter of this call to return the version information, as it's not immediately available in the standard return object for this call (in the CLI this would look like box files:get 1234567890 --fields=version_number).
- Call the file collaborations endpoint to get the collaborators on the file.
- Jon
-
The only issues that you should run into for app performance would be related to rate limits. I'm not sure what your integration looks like, but let me see if I can provide some general guidance here.
Rate limits
If you take a look at the rate limits page I provided above you can see that the limits are basically placed into two buckets, per user rate limits and per enterprise limits. If you have a lot of load to these API calls at once, from a single user, I would recommend looking into having some rudimentary queuing system in place. This system should be aware of the rate limits and be able to queue requests to make them over time if you have rate limit concerns. Any calls to the APIs should also listen for 429 rate limit errors. This should allow you to handle any rate limiting concerns without losing requests in transit.
Service account calls
One of the main issues that folks run into as they scale is that they make all API requests from the service account of a JWT application. While this might work in prototyping / minimal load conditions you will optimally want to instead make requests on behalf of the users (with a user access token or using an As-User header). Since the rate limits you'll most likely hit with this setup are per-user based, this would allow you to minimize load on any single account. Using a queuing system that I described above would allow you to handle the case where a single user does indeed need to make a lot of calls at once. If you don't have "users" in a traditional sense in the app, then you can use app users to function as worker accounts to spread load over multiple user types instead.
Hope that helps!
Jon
-
Thanks Jon for providing your guidance and useful information, It means a lot for us.
Here we are writing one data indexer which will fetch all files along with collaborations from the box and index into our search server(SOLR).
We are following the same approach as you suggested earlier and for the same we are using Web-Client of Spring 5 feature, So that we can call Box API in asynchronous manner.
While we are calling box API Download File getting 302 status code as in response. We gone through the document but could not find much relevant information there.
We will really appreciate if you or any one from your team can suggest exactly what is failing here.
Thanks
Vivek Jain
-
Here I am writing note for other's reference.
While we are calling box API Download File with Spring-Web-Client, getting 302 status code as in response along with File download URL in Response-header, So we just made another subsequent API call in order to download the file.
Thanks
Vivek Jain
Please sign in to leave a comment.
Comments
5 comments