Export a Google Play category to CSV

A short Python script that pages through a category and writes one CSV row per app.

Paging the list

/search returns page, pages and results. Ask for 100 apps per page and stop when you reach the last page.

import csv, os, requests

H = {"X-API-Key": os.environ["API_KEY"]}
URL = "https://apkunit.com/api/v1/search"
rows, page = [], 1
while True:
    r = requests.get(URL, headers=H, timeout=60, params={
        "category": "FINANCE", "min_installs": 10000, "per": 100, "page": page}).json()
    for a in r["results"]:
        rows.append([a["id"], a["title"], a["developer"]["name"],
                     a["installs"]["min"], a["rating"]["score"]])
    if page >= r["pages"]:
        break
    page += 1

with open("finance.csv", "w", newline="") as f:
    w = csv.writer(f)
    w.writerow(["id", "title", "developer", "installs", "score"])
    w.writerows(rows)

Cost

Each page costs two tokens. A category with 8,000 apps over 10,000 installs is 80 pages, or 160 tokens, well inside the free tier.

Going further

For full records, send the package names from the CSV to /apps?ids= in groups of 100.