java – Downloading files. VK API. What should be the delay?


What is the minimum delay for mass downloading files in VK?

I noticed that if you do not write Thread.sleep (), VK can close the connection. Now I am using the following code:

    // Парсим JSON, сохраняем имена файлов и ссылки...

    // Download files
    docList.forEach { doc ->
        val url = URL(doc.url)
        val file = File(savePath + doc.title)

        try {
            FileUtils.copyURLToFile(url, file)
            logTextArea?.appendText("Completed: ${file.path}\n")

        } catch (e: Exception) {
            logTextArea?.appendText("Error: ${file.path}\n")


I would like to keep sleep to a minimum. Tell me, maybe this approach is not correct at all?

* The example is written in Kotlin, but I think it's not that important.


The VKontakte API has a limitation, so you won't be able to make requests too often:

The VK API methods (with the exception of the methods from the secure and ads sections) with the user's access key can be accessed no more than 3 times per second.

See "Limitations and Recommendations"

Scroll to Top