Download Unsplash Photos to Google Drive

Unsplash is the best source for free images on the Internet. The images have the Creative Commons zero license meaning you can do anything with the photos.

This Google Script uses the Unsplash API to fetch the most recently uploaded photos and downloads them to your Google Drive. The photo details, like the height, width, creator name, full RAW link, etc. are appended to a Google Spreadsheet.

You can set this is a time-based trigger to automatically save all the new Unsplash photos in your Google Drive. Change the page parameter to download all the old pictures as well. You would however need to create your CLIENT_ID for the API call.

function getUnsplashPhotos() {
  try {
    var ss = SpreadsheetApp.getActiveSheet();

    // Fetch a maximum of 30 photos per API call
    var url = 'https://api.unsplash.com/photos/?client_id=API_CLIENT_ID&per_page=30&page=1';

    // Parse the JSON response in an Array
    var photos = JSON.parse(UrlFetchApp.fetch(url).getContentText());

    for (var p = 0; p < photos.length; p++) {
      var categories = [],
        photo = photos[p];

      for (var c = 0; c < photo.categories.length; c++) {
        categories.push(photo.categories[c].title);
      }

      var blob = UrlFetchApp.fetch(photos.urls.full).getBlob();

      var file = DriveApp.createFile(blob);

      file.setName(photos.user.name);

      var row = [
        photo.id,
        photo.created_at.substr(0, 10),
        categories.join(', '),
        photo.width,
        photo.height,
        photo.color, // Main Color Hex Mode
        photo.likes, // How popular is the photograph
        photo.user.name, // Credit the photographer
        photo.user.links.html,
        photo.urls.raw, // Full high res version URL
        photo.urls.full,
        file.getUrl(), // URL of the photo in Google Drive
      ];

      ss.appendRow(row);
    }
  } catch (f) {
    Logger.log(f.toString());
  }
}
Amit Agarwal

Amit Agarwal

Google Developer Expert, Google Cloud Champion

Amit Agarwal is a Google Developer Expert in Google Workspace and Google Apps Script. He holds an engineering degree in Computer Science (I.I.T.) and is the first professional blogger in India.

Amit has developed several popular Google add-ons including Mail Merge for Gmail and Document Studio. Read more on Lifehacker and YourStory

Awards & Titles

Digital Inspiration has won several awards since it's launch in 2004.

Google Developer Expert

Google Developer Expert

Google awarded us the Google Developer Expert award recogizing our work in Google Workspace.

ProductHunt Golden Kitty

ProductHunt Golden Kitty

Our Gmail tool won the Lifehack of the Year award at ProductHunt Golden Kitty Awards in 2017.

Microsoft MVP Alumni

Microsoft MVP Alumni

Microsoft awarded us the Most Valuable Professional (MVP) title for 5 years in a row.

Google Cloud Champion

Google Cloud Champion

Google awarded us the Champion Innovator title recognizing our technical skill and expertise.

Email Newsletter

Sign up for our email newsletter to stay up to date.

We will never send any spam emails. Promise.