Skip to content

Instantly share code, notes, and snippets.

@woctezuma
Created April 25, 2024 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save woctezuma/c968194a222a2e334487a4c3ebbd5e6d to your computer and use it in GitHub Desktop.
Save woctezuma/c968194a222a2e334487a4c3ebbd5e6d to your computer and use it in GitHub Desktop.
Fetch the publisher index from EGS
import json
from pathlib import Path
import requests
BASE_URL = "https://egs-platform-service.store.epicgames.com/api/v1/egs/publisher-index"
OUTPUT_FNAME = "publisher-index.json"
LOCALE = "fr"
STORE_ID = "EGS"
MAX_NUM_PRODUCTS_PER_REQUEST = 100
STATIC_PARAMS = (
f"locale={LOCALE}&storeId={STORE_ID}&count={MAX_NUM_PRODUCTS_PER_REQUEST}"
)
HEADERS = {"User-Agent": "."}
TOTAL_NUM_PRODUCTS = 1800
fetched_total_num_products = None
data = []
for start_no in range(0, TOTAL_NUM_PRODUCTS, MAX_NUM_PRODUCTS_PER_REQUEST):
url = f"{BASE_URL}?{STATIC_PARAMS}&start={start_no}"
print(url)
r = requests.get(url, headers=HEADERS, timeout=10)
if r.ok:
d = r.json()
if fetched_total_num_products is None:
fetched_total_num_products = d["paging"]["total"]
print(f"Total: {fetched_total_num_products} products")
data += d["data"]
else:
print(r.status_code)
break
with Path(OUTPUT_FNAME).open("w", encoding="utf8") as f:
json.dump(data, f, indent=2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment