
Comments

Gamejolt API Python
GameJolt API - Python Wrapper free (Pay what you want) & open-source
A Python wrapper for the GameJolt API that provides an easy-to-use interface for managing game data, scores, and user interactions.
Features
User Authentication: Verify user credentials and manage sessions
Global Data Store: Store and retrieve game-wide data (leaderboards, settings, etc.)
User Data Store: Save and load user-specific data (progress, achievements, etc.)
Score System: Add, fetch, and manage scores with customizable tables
User Management: Fetch user profiles and friend lists
Installation
download the files
Install the required dependencies:
pip install -r requirements.txt
Configuration
Before using the API, you need to obtain your GameJolt credentials:
Go to your game page
Navigate to Manage Game → Game API → API Settings
Copy your Game ID and Private Key
Quick Start
from GamejoltAPI import GameJoltSession
# Initialize the session with your GameJolt credentials
GAME_ID = 123456 # Replace with your Game ID
SECRET = "your_secret_key" # Replace with your Private Key
gj = GameJoltSession(game_id=GAME_ID, private_key=SECRET)
# Login a user
username = "player_username"
user_token = "user_token"
if gj.login(username, user_token):
print(f"Welcome {username}!")
# Set user data
gj.set_user_data(username, user_token, "level", 5)
# Add a score
gj.add_score(score_str="1500", sort_value=1500, username=username, user_token=user_token)
# Fetch scores
top_scores = gj.fetch_scores(limit=10)
print(f"Top scores: {top_scores}")
else:
print("Login failed!")
All functions included :
Authentication
login(username: str, user_token: str) -> bool - Verify user credentials
Global Data Store
fetch_global_data(key: str) -> Any - Retrieve global data by keyset_global_data(key: str, value: Any) -> Dict - Set global dataupdate_global_data(key: str, value: Any, operation: str) -> Dict - Update numeric dataremove_global_data(key: str) -> Dict - Remove global dataget_keys_global_data(pattern: str = None) -> List[str] - List all keys
User Data Store
set_user_data(username, user_token, key, value) -> Dict - Set user datafetch_user_data(username, user_token, key) -> Any - Fetch user dataupdate_user_data(username, user_token, key, value, operation) -> Dict - Update user dataremove_user_data(username, user_token, key) -> Dict - Remove user dataget_keys_user_data(username, user_token, pattern) -> List[str] - List user keys
Score System
add_score(score_str, sort_value, username, user_token, guest, table_id, extra_data) -> Dictfetch_scores(limit, table_id, username, user_token) -> List[Dict]get_tables() -> List[Dict] - Get score tablesget_rank(sort_value, table_id) -> int - Get rank for a score
User Management
fetch_user(username, user_id) -> Dict - Get user infoget_friends(username, user_token) -> List[int] - Get friend IDsfetch_friends_profile(username, user_token) -> List[Dict] - Get friends' profiles
Running the Test Suite
The project includes a comprehensive test suite in test_api.py:
# Update credentials in test_api.py first
python test_api.py
Project Structure
API/
├── GamejoltAPI.py # Main API wrapper
├── test_api.py # Test suite and examples
├── requirements.txt # Python dependencies
└── README.md # This file
Requirements
Python 3.6+
requests library
License
This project is provided as-is for use with the GameJolt API.
Support
If you find a bug or something send me a message on Gamejolt page !
