gh-core

raw JSON →
2.3.1 verified Sat May 09 auth: no python

GitHub Collaboration Relation Extraction is a library for extracting collaboration relationships from GitHub data (e.g., issues, commits, pull requests). It provides tools to analyze and visualize contributor networks. Current version is 2.3.1, requires Python <3.12,>=3.9. Release cadence is irregular.

pip install gh-core
error ModuleNotFoundError: No module named 'gh_core'
cause Old import path or not installed.
fix
Run 'pip install gh-core' and import using 'from gh_core import ...'.
error AttributeError: module 'gh_core' has no attribute 'GitHubCollaboration'
cause Incorrect import syntax or outdated version.
fix
Use 'from gh_core import GitHubCollaboration' and ensure version >=1.0.0.
error requests.exceptions.HTTPError: 401 Client Error: Unauthorized
cause Invalid or missing GitHub token.
fix
Set GITHUB_TOKEN environment variable with a valid token with repo scope.
error KeyError: 'extract_relations'
cause Using deprecated method name.
fix
Upgrade to latest version and use 'extract_relations' instead of 'get_relations'. Reinstall with 'pip install --upgrade gh-core'.
breaking In version 2.0, the import path changed from ghcore to gh_core. Old code 'from ghcore import ...' will fail.
fix Use 'from gh_core import ...'
deprecated The method 'get_relations' is deprecated in 2.3.0; use 'extract_relations' instead.
fix Replace get_relations with extract_relations.
gotcha A GitHub token is required with repo scope. Without it, API calls will fail with 401.
fix Set GITHUB_TOKEN environment variable or pass token parameter.
gotcha Rate limiting: default GitHub API limit is 60 requests/hour for unauthenticated requests. Use a token to increase (5000/hour).
fix Authenticate with a token.
gotcha Library only supports public repositories for data extraction. Private repos require appropriate token and may have limited access.
fix Ensure token has access to the target repository.

Initialize with a GitHub token and extract relations from a repository.

from gh_core import GitHubCollaboration
import os

token = os.environ.get('GITHUB_TOKEN', '')
if not token:
    print('Set GITHUB_TOKEN environment variable')
else:
    gc = GitHubCollaboration(token)
    repo='octocat/Hello-World'
    relations = gc.extract_relations(repo)
    print(relations)