Welcome to the asifkamboh.com
blog on this occasion, I will teach you how to download files directly through the API without opening the Google Drive page.
When you create a download link directly from Google Drive, the download link will expire after the file reaches its daily download quota. But when you create a download link using the Google API key, the link will never end and the user can download the file directly from that link.
Which API method I'm going to tell you, this API key method only works for media files, for example, if your file is mp4, mp3, mkv, or other multimedia files, So you can play these media files in HTML5 video player
or download them directly.
What Is Google Drive API Key?
API stands for Application Programming Interface, and the Google Drive API is a code that users can use in their applications or website projects to access files stored in Google Drive storage.
How to Get Google Drive API Key?
Go to this Google Console URL https://console.developers.google.com/
and then log in with your Google Account.
Then you create a new project with any name, and then go to the credentials option within that project, and click create credentials and click the API key option; then the API key will be generated.
Copy this API key into Notepad (we'll need it to create a direct download link). Remember this is the API key for your account. Now we need to enable the Google Drive API key to access the Drive files for this project.
Type "Google Drive API
" in the search box and press enter, as soon as you search the Google Drive API Service will be at the top of the search results which is produced by Google.
Make sure that when you enable the Google Drive API service, the service is produced by Google.
How to Create a Direct Download Link of Drive Files Using API Key?
Navigate to your Google Drive account, select your media file (MP4, MKV, MP3) to which you want to create a direct download link. And then copy the share link of this file with "Anyone with the link
" security. We need the file id from this link.
Then paste the link of your file in Notepad and separate the file ID from that link because we only need the file ID.
For example, this is your file sharing link. The digits in this link after the d/
and before the /view
are the ID of your file that you have to separate from the link.
In my case this is the file ID 1UVDhOEkzxXmmZqGHP-QZh_SnaSuu5OoI
of my media file URL address, in your case it will be different according to your file.
We now create a direct download link for this file using the File ID and Drive API key. To do this, we need to add the file ID, API key and our file format in the link below.
Copy and paste the following Google APIS link into your Notepad and replace the highlight [file_id]
text with your File ID, [api_key]
to your Google Drive API key, and [.mp4]
to your file extension.
And this is an example of a direct download link that I created using the Google Drive API key.
I hope that through this post
, I have been able to teach you how to create a direct download link for Google Drive media files.