This Python script fetches and displays information about video games using the RAWG API. Simply enter the name of a game, and the script will provide details such as the game's release date, rating, description, and background image.
- Fetches game information from the RAWG API
- Displays game name, release date, rating, description, and background image
- Supports both command-line arguments and interactive input mode
- Error handling for network issues, invalid input, and missing API key
- Developer mode for detailed logging and debugging information
- HTML tag stripping for cleaner description display
- Truncation of long descriptions for better readability
- Custom timeout configuration via environment variables
- Python 3.x
requests
library
-
Clone the repository:
git clone https://github.com/veddevv/vgde.git cd vgde
-
Install dependencies:
pip install -r requirements.txt
-
Set the
RAWG_API_KEY
environment variable with your actual RAWG API key:export RAWG_API_KEY='your_api_key_here'
-
Run the script using either method:
# Interactive mode python vgde.py # Direct mode with command-line argument python vgde.py "The Witcher 3"
The script supports the following environment variables:
RAWG_API_KEY
(required): Your RAWG API keyDEVELOPER_MODE
: Set totrue
,1
, ort
to enable developer mode with detailed loggingREQUEST_TIMEOUT
: Set a custom timeout in seconds for API requests (default: 10)
Example with all options:
RAWG_API_KEY='your_key' DEVELOPER_MODE=true REQUEST_TIMEOUT=15 python vgde.py