A collection of Python scripts for automating common tasks with the Badgr digital badge platform, including badge class management and group expiration date updates.
This repository contains four main scripts designed to streamline Badgr administration:
- Badge Class Management - Retrieve and count unique badge classes via API
- Group Link Extraction - Scrape group management links from the web interface
- Batch Group Updates - Update group expiration dates concurrently (high performance)
- Sequential Group Updates - Update group expiration dates one at a time (more stable)
Connects to the Badgr API to retrieve all badge classes and count unique entities.
Features:
- Uses HTTPS connection to Badgr API
- Counts unique badge classes by entityId
- Requires Bearer token authentication
Web scrapes the Badgr interface to extract group management links.
Features:
- Automated login to Badgr web interface
- Navigates through paginated group listings
- Exports group edit links to CSV file
- Handles up to 100 results per page for efficiency
High-performance batch processing script for updating group expiration dates.
Features:
- Concurrent processing (configurable number of simultaneous operations)
- Asynchronous execution for faster processing
- Built-in verification of updates
- Progress tracking and error handling
- Headless browser operation
Sequential processing script for updating group expiration dates.
Features:
- Single-threaded, stable execution
- Step-by-step processing with detailed logging
- Interactive mode for debugging (headless=False)
- Automatic error detection and pause functionality
pip install playwrightplaywright install chromiumYou'll need to configure the following in each script:
-
Badgr API Token (for
get_badge_ids.py)- Set the
Bearervariable with your API token
- Set the
-
Badgr Login Credentials (for web automation scripts)
- Set
login_emailandlogin_passwordvariables ⚠️ Security Note: Remove credentials before committing to version control
- Set
python get_badge_ids.pypython get_group_links.pyThis creates group_links.csv with all group management URLs.
For high-volume processing (recommended for 1000+ groups):
python group_date_auto_batch.pyFor smaller batches or debugging:
python group_date_auto_single.pySet your desired expiration date in the group update scripts:
new_exp_date = "6/24/2031" # MM/DD/YYYY formatAdjust the concurrency limit in group_date_auto_batch.py:
MAX_CONCURRENT = 20 # Reduce if experiencing timeoutsCustomize the output filename in get_group_links.py:
csv_name = "group_links.csv"- Extract Group Links: Run
get_group_links.pyto generate a CSV of all group edit URLs - Update Expiration Dates: Use either batch or single script to update group expiration dates
- Verification: Both update scripts include built-in verification to ensure changes were applied correctly
- Timeouts: Scripts include timeout handling for slow-loading pages
- Login Detection: Automatic re-authentication if session expires
- Verification: Date changes are verified after each update
- Progress Tracking: Real-time progress reporting with completion percentages
- Never commit credentials to version control
- Use environment variables or config files for sensitive data
- Consider using Badgr API instead of web scraping when possible
- Review and test scripts in a development environment first
Authentication Errors:
- Verify your Badgr credentials are correct
- Check if your account has necessary permissions
- Ensure API token is valid and not expired
Timeout Issues:
- Reduce
MAX_CONCURRENTvalue in batch script - Increase timeout values in script configuration
- Check network connectivity
Date Format Issues:
- Ensure date format matches MM/DD/YYYY
- Verify the target date is valid and in the future
Set headless=False in browser launch options to watch the automation in action:
browser = playwright.chromium.launch(headless=False)- Fork the repository
- Create a feature branch
- Make your changes
- Remove any credentials from code
- Submit a pull request
This project is provided as-is for educational and administrative purposes. Please ensure compliance with Badgr's terms of service when using these automation tools.
These scripts are designed for legitimate administrative use of Badgr platforms. Users are responsible for:
- Complying with Badgr's terms of service
- Ensuring proper authorization before running automation scripts
- Testing scripts in development environments before production use
- Protecting credentials and sensitive data