We Want to Hear From You! What Do You Want to See on the Community? Tell us here!

Forum Discussion

Bya23's avatar
Bya23
New member | Level 2
7 years ago

Rate Limit Dropbox API in Web application.

Hello,

I'm hosting a web service that downloads images from the user's dropbox using a shared link. Think thousands of users. 

To download the images i use this piece of code:

private async Task<byte[]> GetDropboxByteArrayAsync(Metadata item, string sharedLink)
{

DropboxClient client = new DropboxClient(DropBoxKey);
SharedLink sl = new SharedLink(sharedLink, null);
var file = await client.Sharing.GetSharedLinkFileAsync(sl.Url, "/" + item.Name, null);

var fileAsByteArray = await file.GetContentAsByteArrayAsync();

return fileAsByteArray;
}

Once I download the image from dropbox i keep it on a cache so i don't download the same image over and over again.

 I'm not sure if i'm approaching this the right way. All the request are using the same OAuth key. That's because the users don't want to log into their dropbox account all the time, that's the point of using the shared link.

The thing is, I'm getting the Rate Limit exception and i don´t know if it is by the number of users requesting images at the same time or the number of threads that I create for a single user.

¿How should I do this?

¿Do I need to generate new OAuths keys?

¿Do I need to keep the DropBoxClient instance and reuse it?

Thank you.

1 Reply

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    7 years ago

    The API was designed with the intention that each user would link their own Dropbox account, in order to interact with their own files. However, it is technically possible to connect to just one account, as you've shown here.

    We generally don't recommend doing so, for various technical and security reasons. For instance, the Dropbox API rate limiting system is built for the scenario where each user connects their own account. The rate limits operate on a per-Dropbox user account basis. 

    So, if you run all of your users through your single Dropbox user account, you are more likely to run in to rate limits. There isn't a supported better way to do this via the API, such as registering more keys/tokens or re-using a client, since it's per-Dropbox user account.

    One alternative may be to access the Dropbox shared link directly, using one of the URL parameters documented here. That way, you wouldn't be using the API and be subject to the API rate limits. You would still be subject to the shared link bandwidth limits though. In general though, it sounds like your use case may be better suited by a general CDN, as opposed to Dropbox.

About Dropbox API Support & Feedback

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

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

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!