Comprehensive Python client library providing full access to the GitHub REST API v3 for programmatic management of repositories, users, organizations, issues, pull requests, and other GitHub entities
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Search functionality across repositories, users, issues, code, commits, and topics. Provides comprehensive search capabilities with filtering and sorting options to discover GitHub content.
Search for repositories across GitHub with advanced filtering and sorting options.
class Github:
def search_repositories(
self,
query: str,
sort: str = None,
order: str = None
):
"""
Search repositories.
Args:
query (str): Search query with optional qualifiers
sort (str, optional): Sort field ("stars", "forks", "help-wanted-issues", "updated")
order (str, optional): Sort order ("asc", "desc")
Returns:
PaginatedList[Repository]: Search results
"""Repository search query qualifiers:
user:USERNAME - repositories owned by specific userorg:ORGNAME - repositories owned by specific organizationlanguage:LANGUAGE - repositories primarily written in languagestars:>NUMBER - repositories with more than NUMBER starsforks:>NUMBER - repositories with more than NUMBER forkssize:>NUMBER - repositories larger than NUMBER KBcreated:>YYYY-MM-DD - repositories created after datepushed:>YYYY-MM-DD - repositories pushed after dateis:public or is:private - public or private repositoriesarchived:true or archived:false - archived statusfork:true or fork:false - include/exclude forksmirror:true or mirror:false - include/exclude mirrorstopic:TOPIC - repositories tagged with topicSearch for users and organizations on GitHub.
class Github:
def search_users(
self,
query: str,
sort: str = None,
order: str = None
):
"""
Search users and organizations.
Args:
query (str): Search query with optional qualifiers
sort (str, optional): Sort field ("followers", "repositories", "joined")
order (str, optional): Sort order ("asc", "desc")
Returns:
PaginatedList[NamedUser]: Search results
"""User search query qualifiers:
type:user - search only userstype:org - search only organizationslocation:LOCATION - users in specific locationlanguage:LANGUAGE - users with repositories in languagecreated:>YYYY-MM-DD - users joined after datefollowers:>NUMBER - users with more than NUMBER followersrepos:>NUMBER - users with more than NUMBER repositoriesSearch issues and pull requests across repositories with detailed filtering.
class Github:
def search_issues(
self,
query: str,
sort: str = None,
order: str = None
):
"""
Search issues and pull requests.
Args:
query (str): Search query with optional qualifiers
sort (str, optional): Sort field ("comments", "reactions", "reactions-+1", "reactions--1", "reactions-smile", "reactions-thinking_face", "reactions-heart", "reactions-tada", "interactions", "created", "updated")
order (str, optional): Sort order ("asc", "desc")
Returns:
PaginatedList[Issue]: Search results (includes pull requests)
"""Issue search query qualifiers:
repo:OWNER/NAME - issues in specific repositoryuser:USERNAME - issues involving specific userassignee:USERNAME - issues assigned to usermentions:USERNAME - issues mentioning userauthor:USERNAME - issues created by usercommenter:USERNAME - issues commented on by userinvolves:USERNAME - issues involving user in any waystate:open or state:closed - issue stateis:issue or is:pr - filter by typeis:public or is:private - repository visibilitylabel:LABEL - issues with specific labelmilestone:MILESTONE - issues in milestoneproject:PROJECT - issues in project boardstatus:pending - pull request status checksreview:required - pull requests requiring reviewdraft:true or draft:false - draft pull requestscreated:>YYYY-MM-DD - issues created after dateupdated:>YYYY-MM-DD - issues updated after dateclosed:>YYYY-MM-DD - issues closed after datemerged:>YYYY-MM-DD - pull requests merged after datecomments:>NUMBER - issues with more than NUMBER commentsSearch code content within repositories.
class Github:
def search_code(
self,
query: str,
sort: str = None,
order: str = None
):
"""
Search code.
Args:
query (str): Search query with optional qualifiers
sort (str, optional): Sort field ("indexed" - when file was indexed)
order (str, optional): Sort order ("asc", "desc")
Returns:
PaginatedList[ContentFile]: Search results
"""Code search query qualifiers:
repo:OWNER/NAME - code in specific repositoryuser:USERNAME - code in user's repositoriesorg:ORGNAME - code in organization's repositorieslanguage:LANGUAGE - code in specific programming languagefilename:NAME - code in files with specific nameextension:EXT - code in files with specific extensionpath:PATH - code in specific pathsize:>NUMBER - files larger than NUMBER bytesfork:true or fork:false - include/exclude forksSearch commits across repositories.
class Github:
def search_commits(
self,
query: str,
sort: str = None,
order: str = None
):
"""
Search commits.
Args:
query (str): Search query with optional qualifiers
sort (str, optional): Sort field ("author-date", "committer-date")
order (str, optional): Sort order ("asc", "desc")
Returns:
PaginatedList[Commit]: Search results
"""Commit search query qualifiers:
repo:OWNER/NAME - commits in specific repositoryuser:USERNAME - commits in user's repositoriesorg:ORGNAME - commits in organization's repositoriesauthor:USERNAME - commits authored by usercommitter:USERNAME - commits committed by userauthor-email:EMAIL - commits by author emailcommitter-email:EMAIL - commits by committer emailauthor-date:>YYYY-MM-DD - commits authored after datecommitter-date:>YYYY-MM-DD - commits committed after datemerge:true or merge:false - merge commitshash:SHA - commits with specific SHA prefixtree:SHA - commits with specific tree SHAparent:SHA - commits with specific parent SHASearch repository topics for content discovery.
class Github:
def search_topics(self, query: str):
"""
Search topics.
Args:
query (str): Topic search query
Returns:
PaginatedList[Topic]: Search results
"""
class Topic:
@property
def name(self) -> str: ...
@property
def display_name(self) -> str: ...
@property
def short_description(self) -> str: ...
@property
def description(self) -> str: ...
@property
def created_by(self) -> str: ...
@property
def released(self) -> str: ...
@property
def created_at(self) -> datetime: ...
@property
def updated_at(self) -> datetime: ...
@property
def featured(self) -> bool: ...
@property
def curated(self) -> bool: ...
@property
def score(self) -> float: ...Access comprehensive search functionality through the main Github client.
class Github:
def get_licenses(self):
"""
Get available open source licenses.
Returns:
PaginatedList[License]: List of licenses
"""
def get_license(self, key: str):
"""
Get a specific license.
Args:
key (str): License key (e.g., "mit", "apache-2.0")
Returns:
License: License object
"""
def get_gitignore_templates(self):
"""
Get available .gitignore templates.
Returns:
list: List of template names
"""
def get_gitignore_template(self, name: str):
"""
Get a .gitignore template.
Args:
name (str): Template name
Returns:
GitignoreTemplate: Template object
"""
def get_repos(self, since: int = None):
"""
Get public repositories in order of creation.
Args:
since (int, optional): Repository ID to start from
Returns:
PaginatedList[Repository]: List of repositories
"""
def get_users(self, since: int = None):
"""
Get users in order of sign-up.
Args:
since (int, optional): User ID to start from
Returns:
PaginatedList[NamedUser]: List of users
"""from github import Github, Auth
g = Github(auth=Auth.Token("your_token"))
# Search for Python repositories with many stars
repos = g.search_repositories(
query="language:python stars:>1000",
sort="stars",
order="desc"
)
print(f"Found {repos.totalCount} repositories")
for repo in repos[:10]: # First 10 results
print(f"{repo.full_name}: {repo.stargazers_count} stars")
# Search for repositories by organization
org_repos = g.search_repositories(
query="org:microsoft language:typescript",
sort="updated",
order="desc"
)
for repo in org_repos[:5]:
print(f"{repo.full_name} - Updated: {repo.updated_at}")# Search for users by location and language
users = g.search_users(
query="location:\"San Francisco\" language:python",
sort="followers",
order="desc"
)
for user in users[:5]:
print(f"{user.login}: {user.followers} followers")
# Search for organizations
orgs = g.search_users(
query="type:org location:\"New York\"",
sort="repositories",
order="desc"
)
for org in orgs[:5]:
print(f"{org.login}: {org.public_repos} repos")# Search for open issues with specific label
issues = g.search_issues(
query="is:issue is:open label:bug language:python",
sort="created",
order="desc"
)
print(f"Found {issues.totalCount} open bug issues")
for issue in issues[:5]:
print(f"#{issue.number} in {issue.repository.full_name}: {issue.title}")
# Search for pull requests needing review
prs = g.search_issues(
query="is:pr is:open review:required",
sort="created",
order="asc" # Oldest first
)
for pr in prs[:5]:
print(f"PR #{pr.number} in {pr.repository.full_name}: {pr.title}")# Search for specific function usage
code_results = g.search_code(
query="requests.get language:python",
sort="indexed",
order="desc"
)
print(f"Found {code_results.totalCount} code matches")
for result in code_results[:5]:
print(f"{result.repository.full_name}:{result.path}")
# Search for configuration files
config_files = g.search_code(
query="filename:docker-compose.yml",
sort="indexed",
order="desc"
)
for file in config_files[:3]:
print(f"Docker Compose in: {file.repository.full_name}")# Search for commits by author
commits = g.search_commits(
query="author:octocat repo:octocat/Hello-World",
sort="author-date",
order="desc"
)
for commit in commits[:5]:
print(f"{commit.sha[:8]}: {commit.commit.message}")
# Search for merge commits
merge_commits = g.search_commits(
query="merge:true repo:owner/repo",
sort="committer-date",
order="desc"
)
for commit in merge_commits[:3]:
print(f"Merge commit: {commit.sha[:8]}")# Search for topics
topics = g.search_topics("machine-learning")
for topic in topics[:5]:
print(f"Topic: {topic.name}")
print(f"Description: {topic.short_description}")
print(f"Featured: {topic.featured}")
print("---")# Get trending repositories (approximation using recent activity)
trending = g.search_repositories(
query="created:>2024-01-01 stars:>100",
sort="stars",
order="desc"
)
print("Trending repositories:")
for repo in trending[:10]:
print(f"{repo.full_name}: {repo.stargazers_count} stars, created {repo.created_at}")
# Find repositories with good first issues
good_first_issues = g.search_issues(
query="label:\"good first issue\" is:open is:issue",
sort="created",
order="desc"
)
print("\nGood first issues:")
for issue in good_first_issues[:5]:
print(f"#{issue.number} in {issue.repository.full_name}: {issue.title}")
# Find repositories needing help
help_wanted = g.search_repositories(
query="help-wanted-issues:>0",
sort="help-wanted-issues",
order="desc"
)
print("\nRepositories needing help:")
for repo in help_wanted[:5]:
print(f"{repo.full_name}: {repo.open_issues_count} open issues")# Multi-criteria repository search
complex_search = g.search_repositories(
query=(
"language:javascript "
"stars:>500 "
"pushed:>2024-01-01 "
"size:<10000 "
"NOT archived:true "
"topic:react"
),
sort="updated",
order="desc"
)
print("Active React repositories:")
for repo in complex_search[:5]:
print(f"{repo.full_name}: {repo.stargazers_count} stars, updated {repo.updated_at}")
# Find beginner-friendly projects
beginner_friendly = g.search_repositories(
query=(
"good-first-issues:>5 "
"help-wanted-issues:>0 "
"stars:>100 "
"language:python"
),
sort="stars",
order="desc"
)
print("\nBeginner-friendly Python projects:")
for repo in beginner_friendly[:3]:
print(f"{repo.full_name}: {repo.stargazers_count} stars")Install with Tessl CLI
npx tessl i tessl/pypi-pygithub