Introduction
Google Business Profile doesn’t let you export reviews natively. But the Google Business Profile API does — and with a Python script, you can export all your reviews to CSV or JSON in seconds.
This post gives you a complete, runnable script.
Prerequisites
- Google Cloud project with Business Profile API enabled
- Service account with access to your business
- Python 3.8+ with
google-api-python-client
Setup Google Cloud
- Go to console.cloud.google.com
- Create a project → Enable “Business Profile API”
- Create a Service Account → download JSON key
- Share your Google Business Profile with the service account email (as manager)
Install dependencies
pip install google-api-python-client google-auth
The script
import json
import csv
from google.oauth2 import service_account
from googleapiclient.discovery import build
from datetime import datetime
# Configuration
SERVICE_ACCOUNT_FILE = "service_account.json"
ACCOUNT_ID = "accounts/YOUR_ACCOUNT_ID" # e.g., "accounts/123456789"
LOCATION_ID = "locations/YOUR_LOCATION_ID" # e.g., "locations/987654321"
OUTPUT_FORMAT = "csv" # "csv" or "json"
# Authenticate
creds = service_account.Credentials.from_service_account_file(
SERVICE_ACCOUNT_FILE,
scopes=["https://www.googleapis.com/auth/business.manage"],
)
service = build("mybusiness", "v4", credentials=creds)
def fetch_all_reviews():
"""Fetch all reviews with pagination."""
reviews = []
page_token = None
while True:
params = {"parent": f"{ACCOUNT_ID}/{LOCATION_ID}", "pageSize": 50}
if page_token:
params["pageToken"] = page_token
response = service.accounts().locations().reviews().list(**params).execute()
batch = response.get("reviews", [])
reviews.extend(batch)
print(f"Fetched {len(batch)} reviews (total: {len(reviews)})")
page_token = response.get("nextPageToken")
if not page_token:
break
return reviews
def parse_review(review):
"""Extract relevant fields from a review."""
return {
"review_id": review.get("reviewId", ""),
"reviewer_name": review.get("reviewer", {}).get("displayName", "Anonymous"),
"reviewer_photo": review.get("reviewer", {}).get("profilePhotoUrl", ""),
"rating": review.get("starRating", "N/A"),
"comment": review.get("comment", ""),
"create_time": review.get("createTime", ""),
"update_time": review.get("updateTime", ""),
"reply": review.get("reviewReply", {}).get("comment", ""),
"reply_time": review.get("reviewReply", {}).get("updateTime", ""),
}
def export_to_csv(reviews, filename="reviews.csv"):
"""Export reviews to CSV."""
if not reviews:
print("No reviews to export.")
return
parsed = [parse_review(r) for r in reviews]
fieldnames = parsed[0].keys()
with open(filename, "w", newline="", encoding="utf-8") as f:
writer = csv.DictWriter(f, fieldnames=fieldnames)
writer.writeheader()
writer.writerows(parsed)
print(f"Exported {len(parsed)} reviews to {filename}")
def export_to_json(reviews, filename="reviews.json"):
"""Export reviews to JSON."""
parsed = [parse_review(r) for r in reviews]
with open(filename, "w", encoding="utf-8") as f:
json.dump(parsed, f, indent=2, ensure_ascii=False)
print(f"Exported {len(parsed)} reviews to {filename}")
def analyze_reviews(reviews):
"""Print basic analytics."""
parsed = [parse_review(r) for r in reviews]
total = len(parsed)
ratings = [r["rating"] for r in parsed if r["rating"] != "N/A"]
rating_map = {"ONE": 1, "TWO": 2, "THREE": 3, "FOUR": 4, "FIVE": 5}
numeric = [rating_map.get(r, 0) for r in ratings]
avg = sum(numeric) / len(numeric) if numeric else 0
replied = sum(1 for r in parsed if r["reply"])
print(f"\n=== Review Analytics ===")
print(f"Total reviews: {total}")
print(f"Average rating: {avg:.2f}/5")
print(f"Replied: {replied}/{total} ({replied/total*100:.1f}%)")
from collections import Counter
dist = Counter(numeric)
for star in range(1, 6):
count = dist.get(star, 0)
bar = "█" * count
print(f" {star}⭐: {count} {bar}")
if __name__ == "__main__":
print("Fetching reviews...")
reviews = fetch_all_reviews()
print(f"Total reviews fetched: {len(reviews)}")
analyze_reviews(reviews)
if OUTPUT_FORMAT == "csv":
export_to_csv(reviews)
else:
export_to_json(reviews)
Usage
- Replace
YOUR_ACCOUNT_IDandYOUR_LOCATION_IDwith your actual IDs- Find them at: business.google.com → Your business → Settings → Advanced
- Or use the API:
service.accounts().list().execute()
- Place
service_account.jsonin the same directory - Run:
python export_reviews.py
Output
CSV
review_id,reviewer_name,rating,comment,create_time,reply,reply_time
abc123,Galvan,FIVE,"Great service!",2026-03-01T10:00:00Z,"Thank you!",2026-03-01T12:00:00Z
Console analytics
=== Review Analytics ===
Total reviews: 47
Average rating: 4.62/5
Replied: 42/47 (89.4%)
1⭐: 1 █
2⭐: 0
3⭐: 2 ██
4⭐: 5 █████
5⭐: 39 ███████████████████████████████████████
Advanced: Schedule with cron
# Run weekly to export new reviews
0 9 * * 1 cd /path/to/project && python export_reviews.py
Advanced: Send to Google Sheets
import gspread
from google.oauth2.service_account import Credentials
def export_to_sheets(reviews):
creds = Credentials.from_service_account_file("service_account.json",
scopes=["https://www.googleapis.com/auth/spreadsheets"])
gc = gspread.authorize(creds)
sheet = gc.open("Reviews Export").sheet1
parsed = [parse_review(r) for r in reviews]
headers = list(parsed[0].keys())
sheet.clear()
sheet.append_row(headers)
for row in parsed:
sheet.append_row(list(row.values()))
print(f"Exported {len(parsed)} reviews to Google Sheets")
Common mistakes
- Wrong account/location IDs — double-check from the GBP dashboard
- Service account not added as manager — share your GBP with the service account email
- API not enabled — enable “Business Profile API” in Google Cloud Console
- Pagination not handled — the script handles this, but if you modify it, don’t forget
nextPageToken - Rate limiting — Google’s API has rate limits. The script includes small delays between requests.
Key Concepts
- Google Business Profile API = programmatic access to reviews, posts, and profile data
- Service account = headless authentication for API access
- Pagination = fetching data in batches (50 per request)
- OAuth2 = authentication protocol used by Google APIs
- CSV/JSON = standard export formats
What to Try Next
- Automate Google review replies with AI
- Build a review tracking dashboard in Streamlit
- Automate Google review requests for consistent flow
- Reply to negative reviews with templates
FAQ
Is the Google Business Profile API free?
Yes — the API is free to use. You just need a Google Cloud project with the API enabled. There are rate limits (requests per minute) but they’re generous for small businesses.
Can I export reviews from a competitor’s profile?
No — you can only access reviews for businesses you manage. The API requires authentication and ownership verification.
How often should I export reviews?
Weekly or monthly. Set up a cron job to run the script automatically. Store exports in a database or spreadsheet for trend analysis.
Can I use this data for sentiment analysis?
Yes! Feed the exported reviews into a sentiment analysis dashboard to track customer sentiment over time. See Sentiment Dashboard with Streamlit.