Google APIs SDK
Comprehensive Google APIs SDK for Node.js with TypeScript support, including Google Ads, Gmail, Drive, Docs, Sheets, and Slides.
Features
- 🚀 Google Ads API: Complete campaign, ad group, and ads management
- 📧 Gmail API: Send, read, and manage emails
- 📁 Drive API: File management and sharing
- 📄 Docs API: Create and edit Google Documents
- 📊 Sheets API: Spreadsheet operations
- 🎨 Slides API: Presentation management
- 🔐 OAuth2 Authentication: Secure authentication flow
- 📝 TypeScript Support: Full type definitions included
- ⚡ Modern API: Promise-based with async/await support
Installation
npm install google-ads-sdk
Quick Start
Google Ads
import { GoogleAdsClient } from 'google-ads-sdk';
const client = new GoogleAdsClient({
developerToken: 'your-developer-token',
clientId: 'your-client-id',
clientSecret: 'your-client-secret',
refreshToken: 'your-refresh-token'
}, 'customer-id');
const campaigns = await client.campaigns.list();
Gmail
import { GmailClient } from 'google-ads-sdk';
const gmail = new GmailClient({
clientId: 'your-client-id',
clientSecret: 'your-client-secret',
refreshToken: 'your-refresh-token'
});
await gmail.messages.send({
to: 'recipient@example.com',
subject: 'Hello from SDK',
body: 'This is a test email'
});
Google Drive
import { DriveClient } from 'google-ads-sdk';
const drive = new DriveClient({
clientId: 'your-client-id',
clientSecret: 'your-client-secret',
refreshToken: 'your-refresh-token'
});
const files = await drive.files.list();
Google Docs
import { DocsClient, DocsBuilders } from 'google-ads-sdk';
const docs = new DocsClient({
clientId: 'your-client-id',
clientSecret: 'your-client-secret',
refreshToken: 'your-refresh-token'
});
const doc = await docs.documents.create({ title: 'My Document' });
await docs.documents.batchUpdate(doc.documentId!, {
requests: [
DocsBuilders.insertTextAtStart('Hello World!')
]
});
Google Sheets
import { SheetsClient } from 'google-ads-sdk';
const sheets = new SheetsClient({
clientId: 'your-client-id',
clientSecret: 'your-client-secret',
refreshToken: 'your-refresh-token'
});
const spreadsheet = await sheets.spreadsheets.create({
properties: { title: 'My Spreadsheet' }
});
Google Slides
import { SlidesClient } from 'google-ads-sdk';
const slides = new SlidesClient({
clientId: 'your-client-id',
clientSecret: 'your-client-secret',
refreshToken: 'your-refresh-token'
});
const presentation = await slides.presentations.create({
title: 'My Presentation'
});
Authentication
All services require OAuth2 authentication. You need:
- Client ID & Secret: From Google Cloud Console
- Refresh Token: Obtained through OAuth2 flow
- Developer Token: Required for Google Ads API
Getting OAuth2 Credentials
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable the required APIs
- Create OAuth2 credentials
- Use the authorization flow to get refresh token
API Documentation
Requirements
- Node.js 14+
- TypeScript 4.5+ (for TypeScript projects)
License
ISC
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.