{"id":19651788,"url":"https://github.com/tanaikech/gphotoapp","last_synced_at":"2025-04-28T16:31:45.868Z","repository":{"id":44897149,"uuid":"243131748","full_name":"tanaikech/GPhotoApp","owner":"tanaikech","description":"This is a GAS library for retrieving and creating the albums and media items using Google Photo API using Google Apps Script (GAS).","archived":false,"fork":false,"pushed_at":"2022-06-06T05:12:35.000Z","size":18,"stargazers_count":57,"open_issues_count":3,"forks_count":8,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-05T09:51:08.473Z","etag":null,"topics":["developer-tools","gas-library","google-apps-script","google-photos","google-photos-api","library"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tanaikech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-26T00:23:08.000Z","updated_at":"2025-03-01T07:45:35.000Z","dependencies_parsed_at":"2022-09-03T08:32:13.041Z","dependency_job_id":null,"html_url":"https://github.com/tanaikech/GPhotoApp","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanaikech%2FGPhotoApp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanaikech%2FGPhotoApp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanaikech%2FGPhotoApp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanaikech%2FGPhotoApp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tanaikech","download_url":"https://codeload.github.com/tanaikech/GPhotoApp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251345988,"owners_count":21574811,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["developer-tools","gas-library","google-apps-script","google-photos","google-photos-api","library"],"created_at":"2024-11-11T15:08:06.314Z","updated_at":"2025-04-28T16:31:45.576Z","avatar_url":"https://github.com/tanaikech.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GPhotoApp\n\n[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)\n\n\u003ca name=\"overview\"\u003e\u003c/a\u003e\n\n# Overview\n\nA Google Apps Script (GAS) library exposing the Google Photos Library API.\n\nBased on https://github.com/tanaikech/GPhotoApp\n\n\u003ca name=\"description\"\u003e\u003c/a\u003e\n\n## Description\n\nCurrently, the Photos Library API is not available under [Advanced Google services](https://developers.google.com/apps-script/guides/services/advanced). This library enables access via the `UrlFetchApp` service.\n\n## Usage\n\n1. Copy + paste the contents of `PhotoApp.js` to a new file in your Apps Script project.\n1. Link the Cloud Platform project to your Google Apps Script project: Apps Script Sidebar \u003e Project Settings \u003e Google Cloud Platform (GCP) Project. See also [here](https://gist.github.com/tanaikech/e945c10917fac34a9d5d58cad768832c).\n1. [Enable the Photos Library API at the GCP Console](https://console.developers.google.com/apis/library/photoslibrary.googleapis.com)\n1. Edit `appsscript.json` in your project to include the scopes required for Google Photos access (see included sample file):\n\n```json\n  \"oauthScopes\": [\n    \"https://www.googleapis.com/auth/photoslibrary\",\n    \"https://www.googleapis.com/auth/script.external_request\"\n  ]\n```\n\n## Public library\n\nI got a contact that the library key had been removed. The script ID of the library is as follows.\n\n```\n1lGrUiaweQjQwVV_QwWuJDJVbCuY2T0BfVphw6VmT85s9LJFntav1wzs9\n```\n\n- How to install the Google Apps Script can be seen at [here](https://developers.google.com/apps-script/guides/libraries#add_a_library_to_your_script_project).\n\n### Notes\n\n- This library uses modern Javascript. V8 runtime must be [enabled](https://developers.google.com/apps-script/guides/v8-runtime).\n- Media items can be created only within the albums created by your app (see [here](https://developers.google.com/photos/library/guides/upload-media#creating-media-item)). Attempting to upload to an album not created by your app will result in the error: `No permission to add media items to this album`.\n- Paginated results are returned as iterators. Use [`for...of`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of) to iterate over them. If you need all of them, you can use [`Array.from()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from).\n\n# Documentation\n\n| Methods                                                 | Description                 |\n| :------------------------------------------------------ | :-------------------------- |\n| [createAlbum(object)](#createalbum)                     | Create new album.           |\n| [getAlbumList(excludeNonAppCreatedData)](#getalbumList) | Get album list.             |\n| [getMediaItemList()](#getmediaitemList)                 | Get media item list.        |\n| [getMediaItems(object)](#getmediaitems)                 | Get media items.            |\n| [getMediaItem(object)](#getmediaitem)                   | Gets a media item.          |\n| [getMediaItemBlob(object)](#getmediaitemblob)           | Gets data for a media item. |\n| [uploadMediaItems(object)](#uploadmediaitems)           | Upload images to album.     |\n\n\u003ca name=\"usage\"\u003e\u003c/a\u003e\n\n## Sample scripts\n\n\u003ca name=\"createalbum\"\u003e\u003c/a\u003e\n\n### `createAlbum` ([albums.create](https://developers.google.com/photos/library/reference/rest/v1/albums/create))\n\n```javascript\nfunction createAlbum() {\n  const resource = { album: { title: \"sample title\" } };\n  const res = PhotoApp.createAlbum(resource);\n  console.log(res);\n}\n```\n\n\u003ca name=\"getalbumList\"\u003e\u003c/a\u003e\n\n### `getAlbumList` ([albums.list](https://developers.google.com/photos/library/reference/rest/v1/albums/list))\n\n```javascript\nfunction getAlbumList() {\n  const res = Array.from(\n    PhotoApp.getAlbumList({ excludeNonAppCreatedData: true })\n  );\n  console.log(res);\n}\n```\n\n\u003ca name=\"getmediaitemList\"\u003e\u003c/a\u003e\n\n### `getMediaItemList` ([mediaItems.list](https://developers.google.com/photos/library/reference/rest/v1/mediaItems/list))\n\n```javascript\nfunction getMediaItemList() {\n  const res = Array.from(PhotoApp.getMediaItemList());\n  console.log(res);\n}\n```\n\n\u003ca name=\"getmediaitemList\"\u003e\u003c/a\u003e\n\n### `searchMediaItems` ([mediaItems.search](https://developers.google.com/photos/library/reference/rest/v1/mediaItems/search))\n\n```javascript\nfunction searchMediaItems() {\n  const albumId = \"###\"; // Album ID\n  const res = Array.from(PhotoApp.searchMediaItems({ albumId }));\n  console.log(res);\n}\n```\n\n\u003ca name=\"getmediaitems\"\u003e\u003c/a\u003e\n\n### `getMediaItems` ([mediaItems.batchGet](https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchGet))\n\n```javascript\nfunction getMediaItems() {\n  const resource = { mediaItemIds: [\"###\", \"###\"] };\n  // Note that since the list is limited to requested items, this does not return an iterator.\n  const res = PhotoApp.getMediaItems(resource);\n  console.log(res);\n}\n```\n\n\u003ca name=\"getmediaitem\"\u003e\u003c/a\u003e\n\n### `getMediaItem` ([mediaItems.get](https://developers.google.com/photos/library/reference/rest/v1/mediaItems/get))\n\n```javascript\nfunction getMediaItem() {\n  const id = \"###\";\n  const res = PhotoApp.getMediaItem({ mediaItemId: id });\n  console.log(res);\n}\n```\n\n\u003ca name=\"getmediaitemblob\"\u003e\u003c/a\u003e\n\n### `getMediaItemBlob`\n\n```javascript\nfunction getMediaItems() {\n  const id = \"###\";\n  const mediaItem = PhotoApp.getMediaItem({ mediaItemId: id });\n  const blob = PhotoApp.getMediaItemBlob(mediaItem);\n  blob.setName(mediaItem.filename);\n  DriveApp.createFile(blob);\n  console.log(res);\n}\n```\n\n\u003ca name=\"uploadmediaitems\"\u003e\u003c/a\u003e\n\n### `uploadMediaItems` ([mediaItems.batchCreate](https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate))\n\n```javascript\nfunction uploadMediaItems() {\n  const albumId = \"###\"; // Album ID\n  const fileId = \"###\"; // File ID\n  const url = \"###\"; // URL of image file\n  const resource = {\n    albumId: albumId,\n    items: [\n      {\n        blob: DriveApp.getFileById(fileId).getBlob(),\n        description: \"description1\",\n        filename: \"filename1\",\n      },\n      {\n        blob: UrlFetchApp.fetch(url).getBlob(),\n        description: \"description2\",\n        filename: \"filename2\",\n      },\n    ],\n  };\n  const res = PhotoApp.uploadMediaItems(resource);\n  console.log(JSON.stringify(res));\n}\n```\n\n\u003ca name=\"license\"\u003e\u003c/a\u003e\n\n# License\n\n[MIT](LICENSE)\n\n\u003ca name=\"author\"\u003e\u003c/a\u003e\n\n# Authors\n\n[Tanaike](https://tanaikech.github.io/about/), [kwikwag](https://github.com/kwikwag/GPhotoApp)\n\n\u003ca name=\"updatehistory\"\u003e\u003c/a\u003e\n\n# Update History\n\n- v1.0.0 (February 26, 2020) (tanaikech)\n\n  1. Initial release.\n\n- v1.1.0 (January 20, 2022) (kwikwag)\n\n  1. Added some methods\n  2. Refactored code\n  3. Fixed broken pagination API\n  4. Minor breaking interface changes\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftanaikech%2Fgphotoapp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftanaikech%2Fgphotoapp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftanaikech%2Fgphotoapp/lists"}