18.0.3 • Published 1 year ago
@anmiles/google-api-wrapper v18.0.3
@anmiles/google-api-wrapper
Wrapper around googleapis for getting data shortly
- provides quick interface for getting google API data
- incapsulates auth process
- combines getting paged items in one call
Installation
npm install @anmiles/google-api-wrapper
Usage
Authorization
/* 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
/* 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
/* 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 - download all liked videos from youtube
- google-calendar-entries - view and manage google calendar entries
18.0.3
1 year ago
18.0.2
1 year ago
18.0.1
1 year ago
18.0.0
1 year ago
17.0.9
1 year ago
17.0.8
1 year ago
17.0.7
1 year ago
17.0.5
1 year ago
17.0.6
1 year ago
17.0.3
1 year ago
17.0.2
1 year ago
17.0.4
1 year ago
17.0.1
1 year ago
17.0.0
1 year ago
16.0.2
1 year ago
16.0.1
1 year ago
16.0.0
1 year ago
16.0.3
1 year ago
15.3.0
2 years ago
15.2.0
2 years ago
15.0.0
2 years ago
15.1.0
2 years ago
14.1.0
2 years ago
14.2.0
2 years ago
14.0.0
2 years ago
13.0.0
2 years ago
13.0.1
2 years ago
12.0.0
2 years ago
11.0.0
2 years ago
7.0.0
2 years ago
7.0.4
2 years ago
7.0.3
2 years ago
7.0.2
2 years ago
7.0.1
2 years ago
7.0.7
2 years ago
7.0.6
2 years ago
7.0.5
2 years ago
8.0.1
2 years ago
8.0.0
2 years ago
8.0.2
2 years ago
9.1.0
2 years ago
9.0.0
2 years ago
6.1.1
2 years ago
6.1.0
2 years ago
6.0.1
2 years ago
6.0.0
2 years ago
5.0.0
2 years ago
4.0.0
2 years ago
3.1.0
2 years ago
3.0.3
2 years ago
3.0.1
2 years ago
3.0.0
2 years ago
2.1.3
2 years ago
2.1.2
2 years ago
2.1.1
2 years ago
2.1.0
2 years ago
2.0.1
2 years ago
2.0.0
2 years ago
1.0.1
2 years ago