31 KiB
You don't normaly create instances of any class but Github.
You obtain instances through calls to search_, get_ and create_ methods.
Class Github
Constructed from user's login and password or OAuth token or nothing:
g = Github( login, password )
g = Github( token )
g = Github()
You can also use your client_id and client_secret: g = github.Github(client_id="YourClientId", client_secret="YourClientSecret")
You can add an argument base_url = "http://my.enterprise.com:8080/path/to/github" to connect to a local install of Github (ie. Github Enterprise).
You can add an argument user_agent to send a custom User-Agent header to Github.
Another argument, that can be passed is timeout which has default value 10.
Attributes
rate_limiting: tuple of two integers: remaining and limit, as explained in Rate Limiting
Methods
get_user():AuthenticatedUserget_user( login ):NamedUserget_organization( login ):Organizationget_repo( full_name ):Repositoryget_gist( id ):Gistid: string
get_gists():PaginatedListofGistget_hooks():PaginatedListofHookDescriptionlegacy_search_repos( keyword, [language] ):PaginatedListofRepositorykeyword: stringlanguage: string
legacy_search_users( keyword ):PaginatedListofNamedUserkeyword: string
legacy_search_user_by_email( email ):NamedUseremail: string
render_markdown( text, [context] ): stringtext: stringcontext:Repository
Class PaginatedList
This class implements lazy pagination requests and hides pagination from you. It is the return type of get_ methods that return a collection.
You can iterate on it in a for f in user.get_followers(): loop or with any itertools functions.
You cannot know the number of objects returned before the end of the iteration. If that's really what you need, you cant use len( list( user.get_followers() ) ),
which does all the requests needed to enumerate the user's followers. Note that there is often an attribute giving this value (in that case user.followers).
You can also call get_page( page ) where page is an integer starting at 0, to explicitely get a specific page if you don't want to hide pagination.
Class GithubException
Attributes
status: integerdata: dict
Class AuthenticatedUser
Attributes
avatar_url: stringbio: stringblog: stringcollaborators: integercompany: stringcreated_at: datetime.datetimedisk_usage: integeremail: stringfollowers: integerfollowing: integergravatar_id: stringhireable: boolhtml_url: stringid: integerlocation: stringlogin: stringname: stringowned_private_repos: integerplan:Planprivate_gists: integerpublic_gists: integerpublic_repos: integertotal_private_repos: integertype: stringurl: string
Authorizations
create_authorization( [scopes, note, note_url] ):Authorizationscopes: list of stringnote: stringnote_url: string
get_authorization( id ):Authorizationid: integer
get_authorizations():PaginatedListofAuthorization
Emails
add_to_emails( email, ... )email: string
get_emails(): list of stringremove_from_emails( email, ... )email: string
Events
get_events():PaginatedListofEventget_organization_events( org ):PaginatedListofEventorg:Organization
Followers
get_followers():PaginatedListofNamedUser
Following
add_to_following( following )following:NamedUser
get_following():PaginatedListofNamedUserhas_in_following( following ): boolfollowing:NamedUser
remove_from_following( following )following:NamedUser
Forking
create_fork( repo ):Repositoryrepo:Repository
Gists
create_gist( public, files, [description] ):Gistpublic: boolfiles: dict of string toInputFileContentdescription: string
get_gists():PaginatedListofGistget_starred_gists():PaginatedListofGist
Issues
get_issues():PaginatedListofIssue
Keys
create_key( title, key ):UserKeytitle: stringkey: string
get_key( id ):UserKeyid: integer
get_keys():PaginatedListofUserKey
Modification
edit( [name, email, blog, company, location, hireable, bio] )name: stringemail: stringblog: stringcompany: stringlocation: stringhireable: boolbio: string
Orgs
get_orgs():PaginatedListofOrganization
Repos
create_repo( name, [description, homepage, private, has_issues, has_wiki, has_downloads, auto_init, gitignore_template] ):Repositoryname: stringdescription: stringhomepage: stringprivate: boolhas_issues: boolhas_wiki: boolhas_downloads: boolauto_init: boolgitignore_template: string
get_repo( name ):Repositoryname: string
get_repos( [type, sort, direction] ):PaginatedListofRepositorytype: stringsort: stringdirection: string
Starred
add_to_starred( starred )starred:Repository
get_starred():PaginatedListofRepositoryhas_in_starred( starred ): boolstarred:Repository
remove_from_starred( starred )starred:Repository
Subscriptions
add_to_subscriptions( subscription )subscription:Repository
get_subscriptions():PaginatedListofRepositoryhas_in_subscriptions( subscription ): boolsubscription:Repository
remove_from_subscriptions( subscription )subscription:Repository
Watched
add_to_watched( watched )watched:Repository
get_watched():PaginatedListofRepositoryhas_in_watched( watched ): boolwatched:Repository
remove_from_watched( watched )watched:Repository
Class Authorization
Attributes
app:AuthorizationApplicationcreated_at: datetime.datetimeid: integernote: stringnote_url: stringscopes: list of stringtoken: stringupdated_at: datetime.datetimeurl: string
Deletion
delete()
Modification
edit( [scopes, add_scopes, remove_scopes, note, note_url] )scopes: list of stringadd_scopes: list of stringremove_scopes: list of stringnote: stringnote_url: string
Class AuthorizationApplication
Attributes
name: stringurl: string
Class Branch
Attributes
commit:Commitname: string
Class Commit
Attributes
author:NamedUsercommit:GitCommitcommitter:NamedUserfiles: list ofFileparents: list ofCommitsha: stringstats:CommitStatsurl: string
Comments
create_comment( body, [line, path, position] ):CommitCommentbody: stringline: integerpath: stringposition: integer
get_comments():PaginatedListofCommitComment
Statuses
create_status( state, [target_url, description] ):CommitStatusstate: stringtarget_url: stringdescription: string
get_statuses():PaginatedListofCommitStatus
Class CommitComment
Attributes
body: stringcommit_id: stringcreated_at: datetime.datetimehtml_url: stringid: integerline: integerpath: stringposition: integerupdated_at: datetime.datetimeurl: stringuser:NamedUser
Deletion
delete()
Modification
edit( body )body: string
Class CommitStats
Attributes
additions: integerdeletions: integertotal: integer
Class CommitStatus
Attributes
created_at: datetime.datetimecreator:NamedUserdescription: stringid: integerstate: stringtarget_url: stringupdated_at: datetime.datetime
Class Comparison
Attributes
ahead_by: integerbase_commit:Commitbehind_by: integercommits: list ofCommitdiff_url: stringfiles: list ofFilehtml_url: stringpatch_url: stringpermalink_url: stringstatus: stringtotal_commits: integerurl: string
Class ContentFile
Attributes
content: stringencoding: stringname: stringpath: stringsha: stringsize: integertype: string
Class Download
Attributes
accesskeyid: stringacl: stringbucket: stringcontent_type: stringcreated_at: datetime.datetimedescription: stringdownload_count: integerexpirationdate: datetime.datetimehtml_url: stringid: integermime_type: stringname: stringpath: stringpolicy: stringprefix: stringredirect: bools3_url: stringsignature: stringsize: integerurl: string
Deletion
delete()
Class Event
Attributes
actor:NamedUsercreated_at: datetime.datetimeid: stringorg:Organizationpayload: dictpublic: boolrepo:Repositorytype: string
Class File
Attributes
additions: integerblob_url: stringchanges: integerdeletions: integerfilename: stringpatch: stringraw_url: stringsha: stringstatus: string
Class Gist
Attributes
comments: integercreated_at: datetime.datetimedescription: stringfiles: dict of string toGistFilefork_of:Gistforks: list ofGistgit_pull_url: stringgit_push_url: stringhistory: list ofGistHistoryStatehtml_url: stringid: stringpublic: boolupdated_at: datetime.datetimeurl: stringuser:NamedUser
Comments
create_comment( body ):GistCommentbody: string
get_comment( id ):GistCommentid: integer
get_comments():PaginatedListofGistComment
Deletion
delete()
Forking
create_fork():Gist
Modification
edit( [description, files] )description: stringfiles: dict of string toInputFileContent
Starring
is_starred(): boolreset_starred()set_starred()
Class GistComment
Attributes
body: stringcreated_at: datetime.datetimeid: integerupdated_at: datetime.datetimeurl: stringuser:NamedUser
Deletion
delete()
Modification
edit( body )body: string
Class GistFile
Attributes
content: stringfilename: stringlanguage: stringraw_url: stringsize: integer
Class GistHistoryState
Attributes
change_status:CommitStatscommitted_at: datetime.datetimeurl: stringuser:NamedUserversion: string
Class GitAuthor
Attributes
date: datetime.datetimeemail: stringname: string
Class GitBlob
Attributes
content: stringencoding: stringsha: stringsize: integerurl: string
Class GitCommit
Attributes
author:GitAuthorcommitter:GitAuthormessage: stringparents: list ofGitCommitsha: stringtree:GitTreeurl: string
Class GitObject
Attributes
sha: stringtype: stringurl: string
Class GitRef
Attributes
object:GitObjectref: stringurl: string
Deletion
delete()
Modification
edit( sha, [force] )sha: stringforce: bool
Class GitTag
Attributes
message: stringobject:GitObjectsha: stringtag: stringtagger:GitAuthorurl: string
Class GitTree
Attributes
sha: stringtree: list ofGitTreeElementurl: string
Class GitTreeElement
Attributes
mode: stringpath: stringsha: stringsize: integertype: stringurl: string
Class Hook
Attributes
active: boolconfig: dictcreated_at: datetime.datetimeevents: list of stringid: integerlast_response:HookResponsename: stringupdated_at: datetime.datetimeurl: string
Deletion
delete()
Modification
edit( name, config, [events, add_events, remove_events, active] )name: stringconfig: dictevents: list of stringadd_events: list of stringremove_events: list of stringactive: bool
Testing
test()
Class HookDescription
Attributes
events: list of stringname: stringschema: list of list of stringsupported_events: list of string
Class HookResponse
Attributes
code: integermessage: stringstatus: string
Class Issue
Attributes
assignee:NamedUserbody: stringclosed_at: datetime.datetimeclosed_by:NamedUsercomments: integercreated_at: datetime.datetimehtml_url: stringid: integerlabels: list ofLabelmilestone:Milestonenumber: integerpull_request:IssuePullRequestrepository:Repositorystate: stringtitle: stringupdated_at: datetime.datetimeurl: stringuser:NamedUser
Comments
create_comment( body ):IssueCommentbody: string
get_comment( id ):IssueCommentid: integer
get_comments():PaginatedListofIssueComment
Events
get_events():PaginatedListofIssueEvent
Labels
add_to_labels( label, ... )label:Label
delete_labels()get_labels():PaginatedListofLabelremove_from_labels( label )label:Label
set_labels( label, ... )label:Label
Modification
edit( [title, body, assignee, state, milestone, labels] )title: stringbody: stringassignee:NamedUseror Nonestate: stringmilestone:Milestoneor Nonelabels: list of string
Class IssueComment
Attributes
body: stringcreated_at: datetime.datetimeid: integerupdated_at: datetime.datetimeurl: stringuser:NamedUser
Deletion
delete()
Modification
edit( body )body: string
Class IssueEvent
Attributes
actor:NamedUsercommit_id: stringcreated_at: datetime.datetimeevent: stringid: integerissue:Issueurl: string
Class IssuePullRequest
Attributes
diff_url: stringhtml_url: stringpatch_url: string
Class Label
Attributes
color: stringname: stringurl: string
Deletion
delete()
Modification
edit( name, color )name: stringcolor: string
Class Milestone
Attributes
closed_issues: integercreated_at: datetime.datetimecreator:NamedUserdescription: stringdue_on: datetime.datetimeid: integernumber: integeropen_issues: integerstate: stringtitle: stringurl: string
Deletion
delete()
Labels
get_labels():PaginatedListofLabel
Modification
edit( title, [state, description, due_on] )title: stringstate: stringdescription: stringdue_on: date
Class NamedUser
Attributes
avatar_url: stringbio: stringblog: stringcollaborators: integercompany: stringcontributions: integercreated_at: datetime.datetimedisk_usage: integeremail: stringfollowers: integerfollowing: integergravatar_id: stringhireable: boolhtml_url: stringid: integerlocation: stringlogin: stringname: stringowned_private_repos: integerplan:Planprivate_gists: integerpublic_gists: integerpublic_repos: integertotal_private_repos: integertype: stringurl: string
Events
get_events():PaginatedListofEventget_public_events():PaginatedListofEventget_received_events():PaginatedListofEventget_public_received_events():PaginatedListofEvent
Followers
get_followers():PaginatedListofNamedUser
Following
get_following():PaginatedListofNamedUser
Gists
create_gist( public, files, [description] ):Gistpublic: boolfiles: dict of string toInputFileContentdescription: string
get_gists():PaginatedListofGist
Orgs
get_orgs():PaginatedListofOrganization
Repos
get_repo( name ):Repositoryname: string
get_repos( [type] ):PaginatedListofRepositorytype: string
Starred
get_starred():PaginatedListofRepository
Subscriptions
get_subscriptions():PaginatedListofRepository
Watched
get_watched():PaginatedListofRepository
Class Organization
Attributes
avatar_url: stringbilling_email: stringblog: stringcollaborators: integercompany: stringcreated_at: datetime.datetimedisk_usage: integeremail: stringfollowers: integerfollowing: integergravatar_id: stringhtml_url: stringid: integerlocation: stringlogin: stringname: stringowned_private_repos: integerplan:Planprivate_gists: integerpublic_gists: integerpublic_repos: integertotal_private_repos: integertype: stringurl: string
Events
get_events():PaginatedListofEvent
Forking
create_fork( repo ):Repositoryrepo:Repository
Members
get_members():PaginatedListofNamedUserhas_in_members( member ): boolmember:NamedUser
remove_from_members( member )member:NamedUser
Modification
edit( [billing_email, blog, company, email, location, name] )billing_email: stringblog: stringcompany: stringemail: stringlocation: stringname: string
Public_members
add_to_public_members( public_member )public_member:NamedUser
get_public_members():PaginatedListofNamedUserhas_in_public_members( public_member ): boolpublic_member:NamedUser
remove_from_public_members( public_member )public_member:NamedUser
Repos
create_repo( name, [description, homepage, private, has_issues, has_wiki, has_downloads, team_id, auto_init, gitignore_template] ):Repositoryname: stringdescription: stringhomepage: stringprivate: boolhas_issues: boolhas_wiki: boolhas_downloads: boolteam_id:Teamauto_init: boolgitignore_template: string
get_repo( name ):Repositoryname: string
get_repos( [type] ):PaginatedListofRepositorytype: string
Teams
create_team( name, [repo_names, permission] ):Teamname: stringrepo_names: list ofRepositorypermission: string
get_team( id ):Teamid: integer
get_teams():PaginatedListofTeam
Class Permissions
Attributes
admin: boolpull: boolpush: bool
Class Plan
Attributes
collaborators: integername: stringprivate_repos: integerspace: integer
Class PullRequest
Attributes
additions: integerassignee:NamedUserbase:PullRequestPartbody: stringchanged_files: integerclosed_at: datetime.datetimecomments: integercommits: integercreated_at: datetime.datetimedeletions: integerdiff_url: stringhead:PullRequestParthtml_url: stringid: integerissue_url: stringmergeable: boolmerged: boolmerged_at: datetime.datetimemerged_by:NamedUsernumber: integerpatch_url: stringreview_comments: integerstate: stringtitle: stringupdated_at: datetime.datetimeurl: stringuser:NamedUser
Review comments
create_comment( body, commit_id, path, position )orcreate_review_comment( body, commit_id, path, position ):PullRequestCommentbody: stringcommit_id:Commitpath: stringposition: integer
get_comment( id )orget_review_comment( id ):PullRequestCommentid: integer
get_comments()orget_review_comments():PaginatedListofPullRequestComment
Commits
get_commits():PaginatedListofCommit
Files
get_files():PaginatedListofFile
Issue_comments
create_issue_comment( body ):IssueCommentbody: string
get_issue_comment( id ):IssueCommentid: integer
get_issue_comments():PaginatedListofIssueComment
Merging
is_merged(): boolmerge( [commit_message] ):PullRequestMergeStatuscommit_message: string
Modification
edit( [title, body, state] )title: stringbody: stringstate: string
Class PullRequestComment
Attributes
body: stringcommit_id: stringcreated_at: datetime.datetimeid: integeroriginal_commit_id: stringoriginal_position: integerpath: stringposition: integerupdated_at: datetime.datetimeurl: stringuser:NamedUser
Deletion
delete()
Modification
edit( body )body: string
Class PullRequestMergeStatus
Attributes
merged: boolmessage: stringsha: string
Class PullRequestPart
Attributes
label: stringref: stringrepo:Repositorysha: stringuser:NamedUser
Class Repository
Attributes
clone_url: stringcreated_at: datetime.datetimedescription: stringfork: boolforks: integerfull_name: stringgit_url: stringhas_downloads: boolhas_issues: boolhas_wiki: boolhomepage: stringhtml_url: stringid: integerlanguage: stringmaster_branch: stringname: stringopen_issues: integerorganization:Organizationowner:NamedUserparent:Repositorypermissions:Permissionsprivate: boolpushed_at: datetime.datetimesize: integersource:Repositoryssh_url: stringsvn_url: stringupdated_at: datetime.datetimeurl: stringwatchers: integer
Comparison
compare( base, head ):Comparisonbase: stringhead: string
Assignees
get_assignees():PaginatedListofNamedUserhas_in_assignees( assignee ): boolassignee:NamedUser
Branches
get_branch( branch ):Branchbranch: string
get_branches():PaginatedListofBranch
Collaborators
add_to_collaborators( collaborator )collaborator:NamedUser
get_collaborators():PaginatedListofNamedUserhas_in_collaborators( collaborator ): boolcollaborator:NamedUser
remove_from_collaborators( collaborator )collaborator:NamedUser
Comments
get_comment( id ):CommitCommentid: integer
get_comments():PaginatedListofCommitComment
Commits
get_commit( sha ):Commitsha: string
get_commits( [sha, path] ):PaginatedListofCommitsha: stringpath: string
Contents
get_readme():ContentFileget_contents( path ):ContentFilepath: string
get_archive_link( archive_format, [ref] ): stringarchive_format: stringref: string
Contributors
get_contributors():PaginatedListofNamedUser
Deletion
delete()
Downloads
create_download( name, size, [description, content_type] ):Downloadname: stringsize: integerdescription: stringcontent_type: string
get_download( id ):Downloadid: integer
get_downloads():PaginatedListofDownload
Events
get_events():PaginatedListofEventget_network_events():PaginatedListofEvent
Forks
get_forks():PaginatedListofRepository
Git_blobs
create_git_blob( content, encoding ):GitBlobcontent: stringencoding: string
get_git_blob( sha ):GitBlobsha: string
Git_commits
create_git_commit( message, tree, parents, [author, committer] ):GitCommitmessage: stringtree:GitTreeparents: list ofGitCommitauthor:InputGitAuthorcommitter:InputGitAuthor
get_git_commit( sha ):GitCommitsha: string
Git_refs
create_git_ref( ref, sha ):GitRefref: stringsha: string
get_git_ref( ref ):GitRefref: string
get_git_refs():PaginatedListofGitRef
Git_tags
create_git_tag( tag, message, object, type, [tagger] ):GitTagtag: stringmessage: stringobject: stringtype: stringtagger:InputGitAuthor
get_git_tag( sha ):GitTagsha: string
Git_trees
create_git_tree( tree, [base_tree] ):GitTreetree: list ofInputGitTreeElementbase_tree:GitTree
get_git_tree( sha, [recursive] ):GitTreesha: stringrecursive: bool
Hooks
create_hook( name, config, [events, active] ):Hookname: stringconfig: dictevents: list of stringactive: bool
get_hook( id ):Hookid: integer
get_hooks():PaginatedListofHook
Issues
create_issue( title, [body, assignee, milestone, labels] ):Issuetitle: stringbody: stringassignee:NamedUsermilestone:Milestonelabels: list ofLabel
get_issue( number ):Issuenumber: integer
get_issues( [milestone, state, assignee, mentioned, labels, sort, direction, since] ):PaginatedListofIssuemilestone:Milestoneor "none" or "*"state: stringassignee:NamedUseror "none" or "*"mentioned:NamedUserlabels: list ofLabelsort: stringdirection: stringsince: datetime.datetime
legacy_search_issues( state, keyword ):PaginatedListofIssuestate: "open" or "closed"keyword: string
Issues_events
get_issues_event( id ):IssueEventid: integer
get_issues_events():PaginatedListofIssueEvent
Keys
create_key( title, key ):RepositoryKeytitle: stringkey: string
get_key( id ):RepositoryKeyid: integer
get_keys():PaginatedListofRepositoryKey
Labels
create_label( name, color ):Labelname: stringcolor: string
get_label( name ):Labelname: string
get_labels():PaginatedListofLabel
Languages
get_languages(): dict of string to integer
Merging
merge( base, head, [commit_message] ):Commitbase: stringhead: stringcommit_message: string
Milestones
create_milestone( title, [state, description, due_on] ):Milestonetitle: stringstate: stringdescription: stringdue_on: date
get_milestone( number ):Milestonenumber: integer
get_milestones( [state, sort, direction] ):PaginatedListofMilestonestate: stringsort: stringdirection: string
Modification
edit( name, [description, homepage, public, has_issues, has_wiki, has_downloads, default_branch] )name: stringdescription: stringhomepage: stringpublic: boolhas_issues: boolhas_wiki: boolhas_downloads: booldefault_branch: string
Pulls
create_pull( < title, body, base, head > or < issue, base, head > ):PullRequesttitle: stringbody: stringissue:Issuebase: stringhead: string
get_pull( number ):PullRequestnumber: integer
get_pulls( [state] ):PaginatedListofPullRequeststate: string
Stargazers
get_stargazers():PaginatedListofNamedUser
Subscribers
get_subscribers():PaginatedListofNamedUser
Tags
get_tags():PaginatedListofTag
Teams
get_teams():PaginatedListofTeam
Watchers
get_watchers():PaginatedListofNamedUser
Class RepositoryKey
Attributes
id: integerkey: stringtitle: stringurl: stringverified: bool
Deletion
delete()
Modification
edit( [title, key] )title: stringkey: string
Class Tag
Attributes
commit:Commitname: stringtarball_url: stringzipball_url: string
Class Team
Attributes
id: integermembers_count: integername: stringpermission: stringrepos_count: integerurl: string
Deletion
delete()
Members
add_to_members( member )member:NamedUser
get_members():PaginatedListofNamedUserhas_in_members( member ): boolmember:NamedUser
remove_from_members( member )member:NamedUser
Modification
edit( name, [permission] )name: stringpermission: string
Repos
add_to_repos( repo )repo:Repository
get_repos():PaginatedListofRepositoryhas_in_repos( repo ): boolrepo:Repository
remove_from_repos( repo )repo:Repository
Class UserKey
Attributes
id: integerkey: stringtitle: stringurl: stringverified: bool
Deletion
delete()
Modification
edit( [title, key] )title: stringkey: string