Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d10adee
feat: add modern python stack
amine4567 Jul 18, 2025
235c2d2
fix: project name
amine4567 Jul 18, 2025
af70643
fix: (WIP) typing problesm
amine4567 Jul 18, 2025
5368d4d
fix: add more endpoint response types
amine4567 Jul 20, 2025
8b46283
fix: implement more types
amine4567 Jul 20, 2025
ee8c69c
fix: implement more response types and move them to individual modules
amine4567 Jul 20, 2025
a04efab
fix: implement more response types
amine4567 Jul 20, 2025
8dd3d27
chore: improve logging
amine4567 Jul 20, 2025
88356a2
fix: add more types
amine4567 Jul 20, 2025
f15636e
fix: implement remaining types
amine4567 Jul 20, 2025
aba555d
fix: package __init__
amine4567 Jul 20, 2025
d56be17
docs: add CONTRIBUTING.md
amine4567 Jul 20, 2025
9c8e9cc
refactor: (WIP) split the client into multiple modules
amine4567 Jul 20, 2025
765b733
refactor: improve and migrate get_achievements_earned_between
amine4567 Jul 20, 2025
53f3529
fix: get_users_following_me and get_users_i_follow shouldn't have a u…
amine4567 Mar 29, 2026
0a4d585
fix: get_user_completion_progress wrong return type
amine4567 Mar 29, 2026
3a461a9
feat: add 'active_systems_only' and 'gaming_systems_only' params to '…
amine4567 Mar 29, 2026
9d7d174
feat: add 'count' and 'offset' params to 'get_most_ticketed_games' en…
amine4567 Mar 29, 2026
ea7605a
feat: add 'count' and 'offset' params to 'get_game_list' endpoint
amine4567 Mar 29, 2026
f246eea
fix: 'kinds' param as comma-separated list of kinds for the 'get_rece…
amine4567 Mar 29, 2026
862b849
fix: remove non existing endpoint
amine4567 Mar 29, 2026
6dbd8af
fix: output types for several endpoints
amine4567 Mar 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Python-generated files
__pycache__/
*.py[oc]
build/
dist/
wheels/
*.egg-info

# Virtual environments
.venv

# local testing file
sandbox.py
35 changes: 35 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
args: [--unsafe]
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: local
hooks:
- id: ruff fix
name: Check and fix Python linting with ruff
entry: ruff check
types: [python]
language: system
- id: ruff format
name: Autoformat Python files with ruff
entry: ruff format
types: [python]
language: system
- id: pyright
name: Type checking with pyright
entry: pyright
types: [python]
language: system
# - repo: https://github.com/jendrikseipp/vulture
# rev: 'v2.14'
# hooks:
# - id: vulture
# name: Check unused Python code
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.5.14
hooks:
- id: uv-lock
name: Check if uv.lock is up to date
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
# Contributing

### 🔧 Quickstart
- Install [`uv`](https://github.com/astral-sh/uv)

```bash
uv sync --all-packages
pre-commit install
```
27 changes: 27 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[project]
name = "api-python"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
"requests>=2.32.4",
]

[dependency-groups]
dev = [
"pre-commit>=4.2.0",
"pyright>=1.1.403",
"ruff>=0.12.4",
]

[tool.pyright]
reportIncompatibleMethodOverride = true
typeCheckingMode = "strict"

[tool.ruff]
src = [".", "retroachievements"]
line-length = 88

[tool.ruff.lint]
extend-select = ["I"]
4 changes: 3 additions & 1 deletion retroachievements/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"""

__title__ = "retroachievements-api"
__authors__ = "drisc"
__authors__ = "drisc, amine456"
__version__ = "1.0.0"

from .client import RAClient

__all__ = ["RAClient"]
43 changes: 43 additions & 0 deletions retroachievements/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import requests

from retroachievements import __version__

_BASE_URL = "https://retroachievements.org/API/"


class BaseRAClient:
"""
Main class for accessing the RetroAchievements Web API
"""

headers = {"User-Agent": "RetroAchievements-api-python/" + __version__}

def __init__(self, api_key: str):
self.api_key = api_key

def url_params(self, params: dict[str, str | int | None] | None = None):
"""
Inserts the auth and query params into the request
"""
if params is None:
params = {}
params.update({"y": self.api_key})
return params

# URL construction
def call_api(
self,
endpoint: str | None = None,
params: dict[str, str | int | None] | None = None,
timeout: int = 30,
headers: dict[str, str] | None = None,
):
if endpoint is None:
endpoint = ""
req = requests.get(
f"{_BASE_URL}{endpoint}",
params=self.url_params(params),
timeout=timeout,
headers=headers,
)
return req
Loading