https://github.com/anmiles/google-api-wrapper
Wrapper around googleapis for getting data shortly
https://github.com/anmiles/google-api-wrapper
api auth google googleapis javascript jest library nodejs typescript
Last synced: 10 months ago
JSON representation
Wrapper around googleapis for getting data shortly
- Host: GitHub
- URL: https://github.com/anmiles/google-api-wrapper
- Owner: anmiles
- License: mit
- Created: 2024-01-30T20:09:11.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-07-24T07:42:11.000Z (11 months ago)
- Last Synced: 2025-07-24T11:26:19.657Z (11 months ago)
- Topics: api, auth, google, googleapis, javascript, jest, library, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 6.38 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# @anmiles/google-api-wrapper
Wrapper around googleapis for getting data shortly
- provides quick interface for getting google API data
- encapsulates auth process
- combines getting paged items in one call
----
## Installation
`npm install @anmiles/google-api-wrapper`
## Usage
### Authorization
``` js
/* auth.js */
import { createProfile, login } from '@anmiles/google-api-wrapper';
createProfile("username");
// Persistent credentials will be generated and stored to credentials file.
// Next `login` call will re-use persistent credentials without showing oauth window
login("username");
```
### Example with persisted auth
``` js
/* calendar.js */
import { calendar } from 'googleapis/build/src/apis/calendar';
import { getProfiles, getAPI } from '@anmiles/google-api-wrapper';
require('./auth');
getProfiles().map(async (profile) => {
// Persistent credentials will be generated and stored to credentials file.
// Next `getAPI` call will re-use persistent credentials without showing oauth window
const calendarAPI = getAPI((auth) => calendar({ version : 'v3', auth }), profile);
const events = await calendarAPI.getItems((api) => api.events, { timeMax: new Date().toISOString() });
events.forEach((event) => console.log(`Event: ${event.summary}`));
});
```
### Example with temporary auth
``` js
/* videos.js */
import { youtube } from 'googleapis/build/src/apis/youtube';
import { getProfiles, getAPI } from '@anmiles/google-api-wrapper';
getProfiles().map(async (profile) => {
// Temporary credentials will be generated and not stored to credentials file
// Next `getAPI` will start authorization again with showing oauth window
const youtubeAPI = getAPI((auth) => youtube({ version : 'v3', auth }), profile, { temporary: true });
const videos = await youtubeAPI.getItems((api) => api.playlistItems, { playlistId : 'LL', part : [ 'snippet' ], maxResults : 50 });
videos.forEach((video) => console.log(`Downloaded: ${video.snippet?.title}`));
});
```
### Live examples
- [youtube-likes-downloader](https://www.npmjs.com/package/youtube-likes-downloader) - download all liked videos from youtube
- [google-calendar-entries](https://www.npmjs.com/package/google-calendar-entries) - view and manage google calendar entries
- [school-schedule-sync](https://www.npmjs.com/package/school-schedule-sync) - synchronization between JSON schedule and Google Calendar