Get Download URL

Get Download URL

The official Box SDKs return the binary data when downloading a file. To get the download URL for the data instead, use the following SDK methods.

cURL
curl -i -X GET "https://api.box.com/2.0/files/12345/content?version=4" \
     -H "authorization: Bearer <ACCESS_TOKEN>"
Python
file_id = '11111'
download_url = client.file(file_id).get_download_url()
print(f'The file\'s download URL is: {download_url}')
.NET
Uri downloadUri = await client.FilesManager.GetDownloadUriAsync(id: "11111");
Node
client.files.getDownloadURL('12345')
	.then(downloadURL => {
		// downloadURL -> 'https://dl.boxcloud.com/...'
	});

Redirects

If you are not using one of our SDKs its important to make sure your HTTP client does not automatically follow HTTP redirects. When redirects are automatically followed, your code will detect the location header returned by the API and follow it to get the binary data.

Download URL expiry

Although this download URL can be passed to a user's browser to allow them to download the file, the URL does expire and should be requested again for any further downloads. In most cases the download URL is valid for 15 minutes, after which a new URL needs to be requested. This expiration time may be subject to change without any prior notification.