Skip to main content

A tool to search GitHub repositories using the GitHub API

Project description

AI GitHub

AI GitHub is a Python package that allows you to search for GitHub repositories using the GitHub API. It provides a simple interface to search for repositories based on different criteria.

Benefits

  • Easily search for GitHub repositories based on various criteria.
  • Simple pagination support for browsing through search results.
  • Easy integration with your Python projects.

Installation

You can install the package using pip:

pip install github-ai

Usage

Basic Search

import github_ai

# Basic search
results = github_ai.search(query="machine learning")

print(f"Found {results['total_count']} repositories.")
for repo in results['items']:
    print(f"Name: {repo['name']}")
    print(f"Owner: {repo['owner']['login']}")
    print(f"Stars: {repo['stargazers_count']}")
    print(f"Forks: {repo['forks_count']}")
    print(f"URL: {repo['html_url']}")
    print('-' * 40)

Search with Pagination

import github_ai

# Search with pagination
results = github_ai.search(query="machine learning", per_page=5, page=1)

print(f"Found {results['total_count']} repositories.")
for repo in results['items']:
    print(f"Name: {repo['name']}")
    print(f"Owner: {repo['owner']['login']}")
    print(f"Stars: {repo['stargazers_count']}")
    print(f"Forks: {repo['forks_count']}")
    print(f"URL: {repo['html_url']}")
    print('-' * 40)

Search by User

import github_ai

# Search repositories by a specific user
results = github_ai.search_by_user(user="username")

print(f"Found {results['total_count']} repositories.")
for repo in results['items']:
    print(f"Name: {repo['name']}")
    print(f"Owner: {repo['owner']['login']}")
    print(f"Stars: {repo['stargazers_count']}")
    print(f"Forks: {repo['forks_count']}")
    print(f"URL: {repo['html_url']}")
    print('-' * 40)

Search by Language

import github_ai

# Search repositories by programming language
results = github_ai.search_by_language(language="python")

print(f"Found {results['total_count']} Python repositories.")
for repo in results['items']:
    print(f"Name: {repo['name']}")
    print(f"Owner: {repo['owner']['login']}")
    print(f"Stars: {repo['stargazers_count']}")
    print(f"Forks: {repo['forks_count']}")
    print(f"URL: {repo['html_url']}")
    print('-' * 40)

Search by Topic

import github_ai

# Search repositories by topic
results = github_ai.search_by_topic(topic="data science")

print(f"Found {results['total_count']} Data Science repositories.")
for repo in results['items']:
    print(f"Name: {repo['name']}")
    print(f"Owner: {repo['owner']['login']}")
    print(f"Stars: {repo['stargazers_count']}")
    print(f"Forks: {repo['forks_count']}")
    print(f"URL: {repo['html_url']}")
    print('-' * 40)

Cloning a Repository

import github_ai
import os

try:
    # Search with pagination
    results = github_ai.search(query="machine learning", per_page=5, page=1)

    def format_search_results(results):
        formatted_results = []
        for index, repo in enumerate(results['items'], start=1):
            formatted_result = f"[{index:02d}] {repo['name']} - {repo['html_url']}"
            print(formatted_result)
            formatted_results.append(repo['html_url'])
        return formatted_results

    formatted_results = format_search_results(results)
    
except Exception as e:
    print(f"An error occurred: {e}")

# Get user input
git_index = input("Enter the number of the repository to download: ")

try:
    git_index = int(git_index)
    if 1 <= git_index <= len(formatted_results):
        repo_url = formatted_results[git_index - 1]
        os.system(f"git clone {repo_url}")
    else:
        print("Invalid number entered.")
except ValueError:
    print("Please enter a valid number.")

Additional Usage Example

import github_ai

# Search repositories by stars
results = github_ai.search(query="stars:>1000", per_page=10)

print(f"Found {results['total_count']} repositories with more than 1000 stars.")
for repo in results['items']:
    print(f"Name: {repo['name']}")
    print(f"Owner: {repo['owner']['login']}")
    print(f"Stars: {repo['stargazers_count']}")
    print(f"Forks: {repo['forks_count']}")
    print(f"URL: {repo['html_url']}")
    print('-' * 40)

Acknowledgements

Thank you for using AI GitHub! If you find it useful, consider starring the repository on GitHub.

Thanks

Thank you for using AI GitHub! If you find it useful, consider starring the repository on GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

github-ai-1.0.1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

github_ai-1.0.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file github-ai-1.0.1.tar.gz.

File metadata

  • Download URL: github-ai-1.0.1.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.2

File hashes

Hashes for github-ai-1.0.1.tar.gz
Algorithm Hash digest
SHA256 3e8ba65cc326b0dffc2f6bddd4cc43a622863abde7ea36abdec340bce54ad33e
MD5 819168119a7453d50b9037e4b2253267
BLAKE2b-256 6bb69c700578f3758060f195ca8ac0aa0fae95ed0ecc5315ca1a3189641d18ab

See more details on using hashes here.

File details

Details for the file github_ai-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: github_ai-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.2

File hashes

Hashes for github_ai-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0b7dac9e08c44cebf5410682d567c99ffa0eaf64b8d8d7e9d914fec437703395
MD5 31f76e3737c6bc591ef624d02a812e59
BLAKE2b-256 536545c065c4ee5397294c2f666c098a0b5a690084eac7fbf3fa67c926a4eaf8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page