A powerful command-line interface for managing Looker Studio reports via Google Drive API. Perfect for SEO/performance consultants, dev teams, and dashboard automation workflows.
- List Reports: View all accessible Looker Studio reports
- Export Reports: Download reports as PDF or JSON
- Clone Reports: Create copies of existing reports
- OAuth2 Authentication: Secure Google Drive API access
- Cross-platform: Works on macOS, Linux, and Windows
Before using looker-cli, you need to:
-
Create Google Cloud Project & Enable Drive API:
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Google Drive API
- Create OAuth 2.0 credentials (Desktop application)
-
Get OAuth Credentials:
- Go to APIs & Services > Credentials
- Create credentials > OAuth client ID
- Application type: Desktop application
- Download the credentials JSON file
npm install -g looker-cligit clone <repository-url>
cd looker-cli
npm install
npm run build
npm link-
Configure Environment Variables:
cp .env.example .env
-
Edit
.envfile:CLIENT_ID=your-google-client-id CLIENT_SECRET=your-google-client-secret
-
First Run Authentication:
looker-cli list
This will open your browser for OAuth authentication and store the token securely.
looker-cli listSample Output:
π Listing Looker Studio reports...
Found 3 report(s):
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β TITLE β FILE ID β LAST MODIFIED β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β SEO Performance Dashboard β 1ABC123DEF456GHI789JKL012... β 12/15/2024 β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Monthly Analytics Report β 2BCD234EFG567HIJ890KLM123... β 12/10/2024 β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Client Campaign Dashboard β 3CDE345FGH678IJK901LMN234... β 12/08/2024 β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Export as PDF (default)
looker-cli export --id 1ABC123DEF456GHI789JKL012MNO345PQR
# Export as JSON metadata
looker-cli export --id 1ABC123DEF456GHI789JKL012MNO345PQR --format json
# Specify output path
looker-cli export --id 1ABC123DEF456GHI789JKL012MNO345PQR --output ./reports/dashboard.pdflooker-cli clone --id 1ABC123DEF456GHI789JKL012MNO345PQR --name "My Client Report Copy"- Token Storage: Tokens are stored securely in
~/.looker-cli/token.jsonwith 600 permissions - OAuth2 Flow: Uses Google's installed application OAuth2 flow
- Scope: Requests minimal required permissions (
https://www.googleapis.com/auth/drive.readonly)
# Tokens are automatically refreshed
# To manually revoke and re-authenticate, delete the token file:
rm ~/.looker-cli/token.jsonnpm install
npm run buildnpm run dev -- list
npm run dev -- export --id YOUR_FILE_IDsrc/
βββ commands/
β βββ list.ts # List reports command
β βββ export.ts # Export reports command
β βββ clone.ts # Clone reports command
βββ utils/
β βββ auth.ts # OAuth2 authentication
β βββ drive.ts # Google Drive API integration
βββ index.ts # CLI entry point
- Report Detection: Looker Studio reports don't have a specific MIME type in Drive API
- Search Strategy: Uses keyword matching (
looker,data studio,dashboard,report) - Export Limitations:
- PDF export works for most Google Drive files
- JSON export provides metadata only
- Full report data extraction requires Looker Studio's native export
- Better Report Detection: Name your reports with clear keywords
- Full Data Export: Use Looker Studio's built-in export for complete data
- Automation: Combine with other tools for complete workflow automation
1. "CLIENT_ID or CLIENT_SECRET missing"
- Ensure
.envfile exists with correct credentials - Check that environment variables are set properly
2. "Token invalid or expired"
- Delete token file:
rm ~/.looker-cli/token.json - Run any command to re-authenticate
3. "File not found or not accessible"
- Verify file ID is correct
- Ensure you have access to the file
- Check if file was moved or deleted
4. "No reports found"
- Make sure your reports contain keywords like "looker", "dashboard", "report"
- Check if reports are in your Google Drive account
- Verify Drive API permissions
# Enable verbose logging
DEBUG=* looker-cli list- Export client reports for offline analysis
- Create template reports for new clients
- Automate report generation workflows
- Clone dashboard templates for different environments
- Export reports for version control
- Integrate with CI/CD pipelines
- Batch export reports for archiving
- Create backup copies of important dashboards
- Migrate reports between accounts
- Audit Command: Summary of all reports with metadata
- Open Command: Open reports in browser
- Diff Command: Compare two reports
- Batch Operations: Process multiple reports
- Output Formats: CSV, Markdown support
- Report Templates: Create from templates
- Scheduling: Cron-like report exports
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - see LICENSE file for details
For issues and feature requests, please use the GitHub issue tracker.
Happy reporting! πβ¨