INNER CODE UNIT · Python

github_api_request

Steam-Headless/docker-steam-headless · .github/scripts/manage-compatibility-report.py:26

def github_api_request(url, method="GET", data=None, token=None):
    headers = {
        "Accept": "application/vnd.github.v3+json",
        "User-Agent": "steam-headless-automation",
    }
    if token:
        headers["Authorization"] = f"token {token}"

    req_data = None
    if data is not None:
        headers["Content-Type"] = "application/json"
        req_data = json.dumps(data).encode("utf-8")

    req = urllib.request.Request(url, data=req_data, headers=headers, method=method)
    try:
        with urllib.request.urlopen(req) as resp:
            content = resp.read().decode("utf-8")
            return json.loads(content) if content else None

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…