Sample Random GitHub Repositories
15
stars
14
commits
Python
primary language
Sep 9, 2026
updated
Spin the wheel and see which GitHub repositories you get!
# Using pip
pip install reporoulette
# From source
git clone https://github.com/gojiplus/reporoulette.git
cd reporoulette
pip install -e .
RepoRoulette provides three distinct methods for random GitHub repository sampling:
The four samplers draw from different populations, and only one is (approximately) uniform over all repositories. Pick the one whose population matches your research question:
max_id. The closest thing to a true random sample of GitHub; the cost is a moderate hit rate (~37% measured live in 2026; the rest are deleted, private, or unassigned IDs). The default max_id is a dated constant β call update_max_id() (one API call) to cover the newest repositories.CreateEvent filter, repositories created on sampled days; with other event types, an activity-biased event population like the BigQuery sampler. Two caveats: (1) GitHub's Events API change of 2025-10-07 removed repository-creation events from the public feed, so the default population is empty for days after that date β no repository created since then is reachable; (2) GH Archive publishes hourly files, and hours_per_day trades bandwidth for population: the default (all 24 hours) samples the true day population at ~2 GB/day, while hours_per_day=H downloads only H files but redefines the population to repositories active in the sampled hours (over-representing low-traffic hours, the same bias structure as the per-day cap).Uses GitHub's sequential repository ID system to generate truly random samples by probing random IDs from the valid ID range. The downside of using the method is that the hit rate can be low (as many IDs are invalid, partly because the repo. is private or abandoned, etc.) And any filtering on repo. characteristics must wait till you have the names.
The function will continue to sample till either max_attempts or till n_samples. You can pass the seed for reproducibility.
from reporoulette import IDSampler
# Initialize the sampler
sampler = IDSampler(token="your_github_token")
# Get 50 random repositories
repos = sampler.sample(n_samples=50)
# Print basic stats
print(f"Success rate: {sampler.success_rate:.2f}%")
print(f"Samples collected: {len(repos)}")
Randomly selects days within a specified date range and retrieves repositories updated during those periods using weighted sampling based on repository activity.
from reporoulette import TemporalSampler
from datetime import datetime, timedelta
# Define a date range (last 3 months)
end_date = datetime.now()
start_date = end_date - timedelta(days=90)
# Initialize the sampler
sampler = TemporalSampler(
token="your_github_token", start_date=start_date, end_date=end_date
)
# Get 100 random repositories
repos = sampler.sample(n_samples=100)
# Get repositories with specific characteristics
filtered_repos = sampler.sample(
n_samples=50,
min_stars=10,
language="python", # Note: single language, not list
)
The BigQuerySampler leverages Google BigQuery's public GitHub dataset to sample repositories with advanced filtering capabilities.
Create a Google Cloud Platform (GCP) project:
Enable the BigQuery API:
Create a service account:
Install required dependencies:
pip install google-cloud-bigquery google-auth
Using BigQuerySampler:
from reporoulette import BigQuerySampler
# Initialize with service account credentials
sampler = BigQuerySampler(
credentials_path="path/to/your-service-account-key.json",
project_id="your-gcp-project-id",
seed=42,
)
# Sample active repositories with commits in the last year
active_repos = sampler.sample(
n_samples=50,
population="active",
languages=["Python", "JavaScript"], # Optional language filter
)
# Sample repositories across random days
random_repos = sampler.sample_by_day(n_samples=50, days_to_sample=10, years_back=5)
# Get language information for sampled repositories
languages = sampler.get_languages(random_repos)
# Print results
for repo in random_repos:
print(f"Repository: {repo['full_name']}")
repo_languages = languages.get(repo["full_name"], [])
if repo_languages:
print(f"Primary language: {repo_languages[0]['language']}")
print("---")
Advantages:
Limitations:
The GHArchiveSampler fetches repositories by sampling events from GitHub Archive, a project that records the public GitHub timeline.
from reporoulette import GHArchiveSampler
# Initialize with optional parameters
sampler = GHArchiveSampler(seed=42) # Set seed for reproducibility
# Sample repositories
repos = sampler.sample(
n_samples=100, # Number of repositories to sample
days_to_sample=5, # Number of random days to sample from
repos_per_day=20, # Repositories to sample per day
years_back=2, # How many years to look back
event_types=[
"PushEvent",
"CreateEvent",
"PullRequestEvent",
], # Event types to consider
)
# Access results
for repo in repos:
print(f"Repository: {repo['full_name']}")
print(f"Event Type: {repo['event_type']}")
print(f"Sampled From: {repo['sampled_from']}")
print("---")
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Built with β€οΈ by Gojiplus
13 commits
1 commits
Python
100.0%
Sample Random GitHub Repositories
15
stars
14
commits
Python
primary language
Sep 9, 2026
updated
Spin the wheel and see which GitHub repositories you get!
# Using pip
pip install reporoulette
# From source
git clone https://github.com/gojiplus/reporoulette.git
cd reporoulette
pip install -e .
RepoRoulette provides three distinct methods for random GitHub repository sampling:
The four samplers draw from different populations, and only one is (approximately) uniform over all repositories. Pick the one whose population matches your research question:
max_id. The closest thing to a true random sample of GitHub; the cost is a moderate hit rate (~37% measured live in 2026; the rest are deleted, private, or unassigned IDs). The default max_id is a dated constant β call update_max_id() (one API call) to cover the newest repositories.CreateEvent filter, repositories created on sampled days; with other event types, an activity-biased event population like the BigQuery sampler. Two caveats: (1) GitHub's Events API change of 2025-10-07 removed repository-creation events from the public feed, so the default population is empty for days after that date β no repository created since then is reachable; (2) GH Archive publishes hourly files, and hours_per_day trades bandwidth for population: the default (all 24 hours) samples the true day population at ~2 GB/day, while hours_per_day=H downloads only H files but redefines the population to repositories active in the sampled hours (over-representing low-traffic hours, the same bias structure as the per-day cap).Uses GitHub's sequential repository ID system to generate truly random samples by probing random IDs from the valid ID range. The downside of using the method is that the hit rate can be low (as many IDs are invalid, partly because the repo. is private or abandoned, etc.) And any filtering on repo. characteristics must wait till you have the names.
The function will continue to sample till either max_attempts or till n_samples. You can pass the seed for reproducibility.
from reporoulette import IDSampler
# Initialize the sampler
sampler = IDSampler(token="your_github_token")
# Get 50 random repositories
repos = sampler.sample(n_samples=50)
# Print basic stats
print(f"Success rate: {sampler.success_rate:.2f}%")
print(f"Samples collected: {len(repos)}")
Randomly selects days within a specified date range and retrieves repositories updated during those periods using weighted sampling based on repository activity.
from reporoulette import TemporalSampler
from datetime import datetime, timedelta
# Define a date range (last 3 months)
end_date = datetime.now()
start_date = end_date - timedelta(days=90)
# Initialize the sampler
sampler = TemporalSampler(
token="your_github_token", start_date=start_date, end_date=end_date
)
# Get 100 random repositories
repos = sampler.sample(n_samples=100)
# Get repositories with specific characteristics
filtered_repos = sampler.sample(
n_samples=50,
min_stars=10,
language="python", # Note: single language, not list
)
The BigQuerySampler leverages Google BigQuery's public GitHub dataset to sample repositories with advanced filtering capabilities.
Create a Google Cloud Platform (GCP) project:
Enable the BigQuery API:
Create a service account:
Install required dependencies:
pip install google-cloud-bigquery google-auth
Using BigQuerySampler:
from reporoulette import BigQuerySampler
# Initialize with service account credentials
sampler = BigQuerySampler(
credentials_path="path/to/your-service-account-key.json",
project_id="your-gcp-project-id",
seed=42,
)
# Sample active repositories with commits in the last year
active_repos = sampler.sample(
n_samples=50,
population="active",
languages=["Python", "JavaScript"], # Optional language filter
)
# Sample repositories across random days
random_repos = sampler.sample_by_day(n_samples=50, days_to_sample=10, years_back=5)
# Get language information for sampled repositories
languages = sampler.get_languages(random_repos)
# Print results
for repo in random_repos:
print(f"Repository: {repo['full_name']}")
repo_languages = languages.get(repo["full_name"], [])
if repo_languages:
print(f"Primary language: {repo_languages[0]['language']}")
print("---")
Advantages:
Limitations:
The GHArchiveSampler fetches repositories by sampling events from GitHub Archive, a project that records the public GitHub timeline.
from reporoulette import GHArchiveSampler
# Initialize with optional parameters
sampler = GHArchiveSampler(seed=42) # Set seed for reproducibility
# Sample repositories
repos = sampler.sample(
n_samples=100, # Number of repositories to sample
days_to_sample=5, # Number of random days to sample from
repos_per_day=20, # Repositories to sample per day
years_back=2, # How many years to look back
event_types=[
"PushEvent",
"CreateEvent",
"PullRequestEvent",
], # Event types to consider
)
# Access results
for repo in repos:
print(f"Repository: {repo['full_name']}")
print(f"Event Type: {repo['event_type']}")
print(f"Sampled From: {repo['sampled_from']}")
print("---")
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Built with β€οΈ by Gojiplus
13 commits
1 commits
Python
100.0%