DEV Community

Forge Inc.
Forge Inc.

Posted on

How to generate static Google Review QR Codes with Python (No expiring links)

I recently needed to generate a QR code for a restaurant client that links directly to their Google "Write a Review" screen.

I found plenty of "free" tools online, but they all had the same problem:

  1. They created dynamic links (e.g., qr.co/xyz) that redirect.
  2. They required a signup.
  3. They expired after 14 days unless you paid.

I realized I could build this myself using the Google Places API and Python. Here is how I did it.

The Logic

Google has a direct URL format for reviews:
https://search.google.com/local/writereview?placeid=YOUR_PLACE_ID

If you have the place_id, the link is permanent and free. The trick is getting the ID programmatically.

The Code

I used requests to hit the Places API and qrcode to generate the image.

import requests
import qrcode

def get_place_id(api_key, query):
    url = "https://places.googleapis.com/v1/places:searchText"
    headers = {
        "Content-Type": "application/json",
        "X-Goog-Api-Key": api_key,
        "X-Goog-FieldMask": "places.id"
    }
    payload = {"textQuery": query}
    response = requests.post(url, json=payload, headers=headers)
    return response.json()['places'][0]['id']

def generate_qr(place_id):
    link = f"https://search.google.com/local/writereview?placeid={place_id}"
    img = qrcode.make(link)
    img.save("review-qr.png")
Enter fullscreen mode Exit fullscreen mode

The Web App

I wrapped this in a simple Flask app to make it accessible for non-coders.

You can try the live tool here (no signup required):
ReviewReport Free QR Generator

Or grab the source code on GitHub:
GitHub Repo

Hope this saves you from paying $15/month for a static link!

Top comments (0)