{"id":19534638,"url":"https://github.com/buttercup/googledrive-client","last_synced_at":"2025-04-26T14:35:07.919Z","repository":{"id":34240613,"uuid":"171818281","full_name":"buttercup/googledrive-client","owner":"buttercup","description":"Client for making basic Google Drive requests","archived":false,"fork":false,"pushed_at":"2024-06-16T09:54:11.000Z","size":342,"stargazers_count":5,"open_issues_count":2,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-20T09:22:35.597Z","etag":null,"topics":["client","google-api","google-drive","google-drive-api","google-drive-uploader"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/buttercup.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-21T07:01:55.000Z","updated_at":"2024-12-14T15:35:36.000Z","dependencies_parsed_at":"2024-11-06T07:40:12.635Z","dependency_job_id":null,"html_url":"https://github.com/buttercup/googledrive-client","commit_stats":{"total_commits":128,"total_committers":4,"mean_commits":32.0,"dds":0.03125,"last_synced_commit":"6768569be5e2b411f04e365539506a4ac79f8146"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buttercup%2Fgoogledrive-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buttercup%2Fgoogledrive-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buttercup%2Fgoogledrive-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buttercup%2Fgoogledrive-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/buttercup","download_url":"https://codeload.github.com/buttercup/googledrive-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250681804,"owners_count":21470280,"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":["client","google-api","google-drive","google-drive-api","google-drive-uploader"],"created_at":"2024-11-11T02:14:56.605Z","updated_at":"2025-04-26T14:35:07.868Z","avatar_url":"https://github.com/buttercup.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Google Drive Client\n\u003e Client for making basic Google Drive requests\n\n![build status](https://github.com/buttercup/googledrive-client/actions/workflows/test.yml/badge.svg) [![npm version](https://badge.fury.io/js/%40buttercup%2Fgoogledrive-client.svg)](https://www.npmjs.com/package/@buttercup/googledrive-client)\n\n## About\n\nThis library allows for performing basic actions against Google's RESTful Drive API. It supports **fetching directory contents**, **reading** files and **writing** files. Note that file reading \u0026 writing is only supported with text files currently. It uses `fetch` ([cross-fetch](https://github.com/lquixada/cross-fetch)) to perform requests, which will obviously work in a reproducible fassion across environments.\n\n## Usage\n\nInstall the client by running the following:\n\n```shell\nnpm install @buttercup/googledrive-client\n```\n\n_The latest version (v2) requires an [ESM](https://nodejs.org/api/esm.html) environment to run. It is not available to standard CommonJS projects._\n\nThe library exports a factory which can be used to create client adapters. The factory takes a Google Drive OAuth token.\n\n```typescript\nimport { GoogleDriveClient } from \"@buttercup/googledrive-client\";\n\nconst client = new GoogleDriveClient(myToken);\n\nclient.getDirectoryContents(/* tree: */ true /* (default) */).then(tree =\u003e {\n    // ...\n})\n\n// Or return a flat structure with all files and directories:\nclient.getDirectoryContents();\n```\n\n### Token expiration or invalid credentials\n\nThis library uses [`Layerr`](https://github.com/perry-mitchell/layerr) to pass extra error information around, such as when authentication fails while making a request. This makes it easier for downstream libraries to handle such authorisation failures, perhaps by requesting a new token.\n\nIf an error is thrown, use `Layerr` to extract the information from it to test if an authorisation failure has occurred:\n\n```typescript\nclient.getDirectoryContents().catch(err =\u003e {\n    const { authFailure = false } = Layerr.info(err);\n    // handle authFailure === true\n});\n```\n\n### Getting directory contents using a path\n\nThis library supports fetching directory contents by using a path, for a more traditional field. This method is **not recommended** for all use cases as it doesn't support items in the same level with the _same name_. Consider it experimental.\n\n```typescript\nimport { GoogleDriveClient } from \"@buttercup/googledrive-client\";\n\nconst client = new GoogleDriveClient(myToken);\n\nclient.mapDirectoryContents(\"/\").then(arrayOfFiles =\u003e {\n    // ...\n})\n```\n\n**NB:** Items are placed in the root if (and only if) their parents are not resolvable. They may have parent IDs specified in the result - if a parent can be found for a file, it is in that items sub-directory, whereas if the parent cannot be found it is in the root.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuttercup%2Fgoogledrive-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbuttercup%2Fgoogledrive-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuttercup%2Fgoogledrive-client/lists"}