CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-pygithub

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

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

search-discovery.mddocs/

Search and Discovery

Search functionality across repositories, users, issues, code, commits, and topics. Provides comprehensive search capabilities with filtering and sorting options to discover GitHub content.

Capabilities

Repository Search

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 user
  • org:ORGNAME - repositories owned by specific organization
  • language:LANGUAGE - repositories primarily written in language
  • stars:>NUMBER - repositories with more than NUMBER stars
  • forks:>NUMBER - repositories with more than NUMBER forks
  • size:>NUMBER - repositories larger than NUMBER KB
  • created:>YYYY-MM-DD - repositories created after date
  • pushed:>YYYY-MM-DD - repositories pushed after date
  • is:public or is:private - public or private repositories
  • archived:true or archived:false - archived status
  • fork:true or fork:false - include/exclude forks
  • mirror:true or mirror:false - include/exclude mirrors
  • topic:TOPIC - repositories tagged with topic

User Search

Search 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 users
  • type:org - search only organizations
  • location:LOCATION - users in specific location
  • language:LANGUAGE - users with repositories in language
  • created:>YYYY-MM-DD - users joined after date
  • followers:>NUMBER - users with more than NUMBER followers
  • repos:>NUMBER - users with more than NUMBER repositories

Issue and Pull Request Search

Search 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 repository
  • user:USERNAME - issues involving specific user
  • assignee:USERNAME - issues assigned to user
  • mentions:USERNAME - issues mentioning user
  • author:USERNAME - issues created by user
  • commenter:USERNAME - issues commented on by user
  • involves:USERNAME - issues involving user in any way
  • state:open or state:closed - issue state
  • is:issue or is:pr - filter by type
  • is:public or is:private - repository visibility
  • label:LABEL - issues with specific label
  • milestone:MILESTONE - issues in milestone
  • project:PROJECT - issues in project board
  • status:pending - pull request status checks
  • review:required - pull requests requiring review
  • draft:true or draft:false - draft pull requests
  • created:>YYYY-MM-DD - issues created after date
  • updated:>YYYY-MM-DD - issues updated after date
  • closed:>YYYY-MM-DD - issues closed after date
  • merged:>YYYY-MM-DD - pull requests merged after date
  • comments:>NUMBER - issues with more than NUMBER comments

Code Search

Search 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 repository
  • user:USERNAME - code in user's repositories
  • org:ORGNAME - code in organization's repositories
  • language:LANGUAGE - code in specific programming language
  • filename:NAME - code in files with specific name
  • extension:EXT - code in files with specific extension
  • path:PATH - code in specific path
  • size:>NUMBER - files larger than NUMBER bytes
  • fork:true or fork:false - include/exclude forks

Commit Search

Search 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 repository
  • user:USERNAME - commits in user's repositories
  • org:ORGNAME - commits in organization's repositories
  • author:USERNAME - commits authored by user
  • committer:USERNAME - commits committed by user
  • author-email:EMAIL - commits by author email
  • committer-email:EMAIL - commits by committer email
  • author-date:>YYYY-MM-DD - commits authored after date
  • committer-date:>YYYY-MM-DD - commits committed after date
  • merge:true or merge:false - merge commits
  • hash:SHA - commits with specific SHA prefix
  • tree:SHA - commits with specific tree SHA
  • parent:SHA - commits with specific parent SHA

Topic Search

Search 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: ...

Advanced Search with Github Instance

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
        """

Usage Examples

Repository Search

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}")

User Search

# 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")

Issue and Pull Request Search

# 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}")

Code Search

# 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}")

Commit Search

# 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]}")

Topic Discovery

# 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("---")

Advanced Discovery

# 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")

Complex Search Queries

# 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

docs

authentication.md

git-operations.md

index.md

issues-pull-requests.md

repository-management.md

search-discovery.md

user-organization-management.md

workflows-actions.md

tile.json