You don't normaly create instances of any class but Github
.
You obtain instances through calls to search_
, get_
and create_
methods.
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
.
rate_limiting
: tuple of two integers: remaining and limit, as explained in Rate Limitingoauth_scopes
: None or list of string: when using oauth, after the first request, the list of scopes of the token (see http://developer.github.com/v3/oauth/#scopes)
get_user()
:AuthenticatedUser
get_user( login )
:NamedUser
get_organization( login )
:Organization
get_repo( full_name )
:Repository
get_gist( id )
:Gist
id
: string
get_gists()
:PaginatedList
ofGist
get_hooks()
:PaginatedList
ofHookDescription
legacy_search_repos( keyword, [language] )
:PaginatedList
ofRepository
keyword
: stringlanguage
: string
legacy_search_users( keyword )
:PaginatedList
ofNamedUser
keyword
: string
legacy_search_user_by_email( email )
:NamedUser
email
: string
render_markdown( text, [context] )
: stringtext
: stringcontext
:Repository
get_gitignore_templates()
: list of stringget_gitignore_template( name )
:GitignoreTemplate
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.
status
: integerdata
: dict
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
:Plan
private_gists
: integerpublic_gists
: integerpublic_repos
: integertotal_private_repos
: integertype
: stringurl
: string
create_authorization( [scopes, note, note_url] )
:Authorization
scopes
: list of stringnote
: stringnote_url
: stringclient_id
: stringclient_secret
: string
get_authorization( id )
:Authorization
id
: integer
get_authorizations()
:PaginatedList
ofAuthorization
add_to_emails( email, ... )
email
: string
get_emails()
: list of stringremove_from_emails( email, ... )
email
: string
get_events()
:PaginatedList
ofEvent
get_organization_events( org )
:PaginatedList
ofEvent
org
:Organization
get_followers()
:PaginatedList
ofNamedUser
add_to_following( following )
following
:NamedUser
get_following()
:PaginatedList
ofNamedUser
has_in_following( following )
: boolfollowing
:NamedUser
remove_from_following( following )
following
:NamedUser
create_fork( repo )
:Repository
repo
:Repository
create_gist( public, files, [description] )
:Gist
public
: boolfiles
: dict of string toInputFileContent
description
: string
get_gists()
:PaginatedList
ofGist
get_starred_gists()
:PaginatedList
ofGist
get_issues()
:PaginatedList
ofIssue
create_key( title, key )
:UserKey
title
: stringkey
: string
get_key( id )
:UserKey
id
: integer
get_keys()
:PaginatedList
ofUserKey
edit( [name, email, blog, company, location, hireable, bio] )
name
: stringemail
: stringblog
: stringcompany
: stringlocation
: stringhireable
: boolbio
: string
get_orgs()
:PaginatedList
ofOrganization
create_repo( name, [description, homepage, private, has_issues, has_wiki, has_downloads, auto_init, gitignore_template] )
:Repository
name
: stringdescription
: stringhomepage
: stringprivate
: boolhas_issues
: boolhas_wiki
: boolhas_downloads
: boolauto_init
: boolgitignore_template
: string
get_repo( name )
:Repository
name
: string
get_repos( [type, sort, direction] )
:PaginatedList
ofRepository
type
: stringsort
: stringdirection
: string
add_to_starred( starred )
starred
:Repository
get_starred()
:PaginatedList
ofRepository
has_in_starred( starred )
: boolstarred
:Repository
remove_from_starred( starred )
starred
:Repository
add_to_subscriptions( subscription )
subscription
:Repository
get_subscriptions()
:PaginatedList
ofRepository
has_in_subscriptions( subscription )
: boolsubscription
:Repository
remove_from_subscriptions( subscription )
subscription
:Repository
add_to_watched( watched )
watched
:Repository
get_watched()
:PaginatedList
ofRepository
has_in_watched( watched )
: boolwatched
:Repository
remove_from_watched( watched )
watched
:Repository
app
:AuthorizationApplication
created_at
: datetime.datetimeid
: integernote
: stringnote_url
: stringscopes
: list of stringtoken
: stringupdated_at
: datetime.datetimeurl
: string
delete()
edit( [scopes, add_scopes, remove_scopes, note, note_url] )
scopes
: list of stringadd_scopes
: list of stringremove_scopes
: list of stringnote
: stringnote_url
: string
name
: stringurl
: string
commit
:Commit
name
: string
author
:NamedUser
commit
:GitCommit
committer
:NamedUser
files
: list ofFile
parents
: list ofCommit
sha
: stringstats
:CommitStats
url
: string
create_comment( body, [line, path, position] )
:CommitComment
body
: stringline
: integerpath
: stringposition
: integer
get_comments()
:PaginatedList
ofCommitComment
create_status( state, [target_url, description] )
:CommitStatus
state
: stringtarget_url
: stringdescription
: string
get_statuses()
:PaginatedList
ofCommitStatus
body
: stringcommit_id
: stringcreated_at
: datetime.datetimehtml_url
: stringid
: integerline
: integerpath
: stringposition
: integerupdated_at
: datetime.datetimeurl
: stringuser
:NamedUser
delete()
edit( body )
body
: string
additions
: integerdeletions
: integertotal
: integer
created_at
: datetime.datetimecreator
:NamedUser
description
: stringid
: integerstate
: stringtarget_url
: stringupdated_at
: datetime.datetime
ahead_by
: integerbase_commit
:Commit
behind_by
: integercommits
: list ofCommit
diff_url
: stringfiles
: list ofFile
html_url
: stringpatch_url
: stringpermalink_url
: stringstatus
: stringtotal_commits
: integerurl
: string
content
: stringencoding
: stringname
: stringpath
: stringsha
: stringsize
: integertype
: string
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
delete()
actor
:NamedUser
created_at
: datetime.datetimeid
: stringorg
:Organization
payload
: dictpublic
: boolrepo
:Repository
type
: string
additions
: integerblob_url
: stringchanges
: integerdeletions
: integerfilename
: stringpatch
: stringraw_url
: stringsha
: stringstatus
: string
comments
: integercreated_at
: datetime.datetimedescription
: stringfiles
: dict of string toGistFile
fork_of
:Gist
forks
: list ofGist
git_pull_url
: stringgit_push_url
: stringhistory
: list ofGistHistoryState
html_url
: stringid
: stringpublic
: boolupdated_at
: datetime.datetimeurl
: stringuser
:NamedUser
create_comment( body )
:GistComment
body
: string
get_comment( id )
:GistComment
id
: integer
get_comments()
:PaginatedList
ofGistComment
delete()
create_fork()
:Gist
edit( [description, files] )
description
: stringfiles
: dict of string toInputFileContent
is_starred()
: boolreset_starred()
set_starred()
body
: stringcreated_at
: datetime.datetimeid
: integerupdated_at
: datetime.datetimeurl
: stringuser
:NamedUser
delete()
edit( body )
body
: string
content
: stringfilename
: stringlanguage
: stringraw_url
: stringsize
: integer
change_status
:CommitStats
committed_at
: datetime.datetimeurl
: stringuser
:NamedUser
version
: string
date
: datetime.datetimeemail
: stringname
: string
content
: stringencoding
: stringsha
: stringsize
: integerurl
: string
author
:GitAuthor
committer
:GitAuthor
message
: stringparents
: list ofGitCommit
sha
: stringtree
:GitTree
url
: string
sha
: stringtype
: stringurl
: string
name
: stringsource
: string
object
:GitObject
ref
: stringurl
: string
delete()
edit( sha, [force] )
sha
: stringforce
: bool
message
: stringobject
:GitObject
sha
: stringtag
: stringtagger
:GitAuthor
url
: string
sha
: stringtree
: list ofGitTreeElement
url
: string
mode
: stringpath
: stringsha
: stringsize
: integertype
: stringurl
: string
active
: boolconfig
: dictcreated_at
: datetime.datetimeevents
: list of stringid
: integerlast_response
:HookResponse
name
: stringupdated_at
: datetime.datetimeurl
: string
delete()
edit( name, config, [events, add_events, remove_events, active] )
name
: stringconfig
: dictevents
: list of stringadd_events
: list of stringremove_events
: list of stringactive
: bool
test()
events
: list of stringname
: stringschema
: list of list of stringsupported_events
: list of string
code
: integermessage
: stringstatus
: string
assignee
:NamedUser
body
: stringclosed_at
: datetime.datetimeclosed_by
:NamedUser
comments
: integercreated_at
: datetime.datetimehtml_url
: stringid
: integerlabels
: list ofLabel
milestone
:Milestone
number
: integerpull_request
:IssuePullRequest
repository
:Repository
state
: stringtitle
: stringupdated_at
: datetime.datetimeurl
: stringuser
:NamedUser
create_comment( body )
:IssueComment
body
: string
get_comment( id )
:IssueComment
id
: integer
get_comments()
:PaginatedList
ofIssueComment
get_events()
:PaginatedList
ofIssueEvent
add_to_labels( label, ... )
label
:Label
delete_labels()
get_labels()
:PaginatedList
ofLabel
remove_from_labels( label )
label
:Label
set_labels( label, ... )
label
:Label
edit( [title, body, assignee, state, milestone, labels] )
title
: stringbody
: stringassignee
:NamedUser
or Nonestate
: stringmilestone
:Milestone
or Nonelabels
: list of string
body
: stringcreated_at
: datetime.datetimeid
: integerupdated_at
: datetime.datetimeurl
: stringuser
:NamedUser
delete()
edit( body )
body
: string
actor
:NamedUser
commit_id
: stringcreated_at
: datetime.datetimeevent
: stringid
: integerissue
:Issue
url
: string
diff_url
: stringhtml_url
: stringpatch_url
: string
color
: stringname
: stringurl
: string
delete()
edit( name, color )
name
: stringcolor
: string
closed_issues
: integercreated_at
: datetime.datetimecreator
:NamedUser
description
: stringdue_on
: datetime.datetimeid
: integernumber
: integeropen_issues
: integerstate
: stringtitle
: stringurl
: string
delete()
get_labels()
:PaginatedList
ofLabel
edit( title, [state, description, due_on] )
title
: stringstate
: stringdescription
: stringdue_on
: date
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
:Plan
private_gists
: integerpublic_gists
: integerpublic_repos
: integertotal_private_repos
: integertype
: stringurl
: string
get_events()
:PaginatedList
ofEvent
get_public_events()
:PaginatedList
ofEvent
get_received_events()
:PaginatedList
ofEvent
get_public_received_events()
:PaginatedList
ofEvent
get_followers()
:PaginatedList
ofNamedUser
get_following()
:PaginatedList
ofNamedUser
create_gist( public, files, [description] )
:Gist
public
: boolfiles
: dict of string toInputFileContent
description
: string
get_gists()
:PaginatedList
ofGist
get_orgs()
:PaginatedList
ofOrganization
get_keys()
:PaginatedList
ofUserKey
get_repo( name )
:Repository
name
: string
get_repos( [type] )
:PaginatedList
ofRepository
type
: string
get_starred()
:PaginatedList
ofRepository
get_subscriptions()
:PaginatedList
ofRepository
get_watched()
:PaginatedList
ofRepository
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
:Plan
private_gists
: integerpublic_gists
: integerpublic_repos
: integertotal_private_repos
: integertype
: stringurl
: string
get_events()
:PaginatedList
ofEvent
create_fork( repo )
:Repository
repo
:Repository
get_members()
:PaginatedList
ofNamedUser
has_in_members( member )
: boolmember
:NamedUser
remove_from_members( member )
member
:NamedUser
edit( [billing_email, blog, company, email, location, name] )
billing_email
: stringblog
: stringcompany
: stringemail
: stringlocation
: stringname
: string
add_to_public_members( public_member )
public_member
:NamedUser
get_public_members()
:PaginatedList
ofNamedUser
has_in_public_members( public_member )
: boolpublic_member
:NamedUser
remove_from_public_members( public_member )
public_member
:NamedUser
create_repo( name, [description, homepage, private, has_issues, has_wiki, has_downloads, team_id, auto_init, gitignore_template] )
:Repository
name
: stringdescription
: stringhomepage
: stringprivate
: boolhas_issues
: boolhas_wiki
: boolhas_downloads
: boolteam_id
:Team
auto_init
: boolgitignore_template
: string
get_repo( name )
:Repository
name
: string
get_repos( [type] )
:PaginatedList
ofRepository
type
: string
create_team( name, [repo_names, permission] )
:Team
name
: stringrepo_names
: list ofRepository
permission
: string
get_team( id )
:Team
id
: integer
get_teams()
:PaginatedList
ofTeam
admin
: boolpull
: boolpush
: bool
collaborators
: integername
: stringprivate_repos
: integerspace
: integer
additions
: integerassignee
:NamedUser
base
:PullRequestPart
body
: stringchanged_files
: integerclosed_at
: datetime.datetimecomments
: integercommits
: integercreated_at
: datetime.datetimedeletions
: integerdiff_url
: stringhead
:PullRequestPart
html_url
: stringid
: integerissue_url
: stringmergeable
: boolmerged
: boolmerged_at
: datetime.datetimemerged_by
:NamedUser
number
: integerpatch_url
: stringreview_comments
: integerstate
: stringtitle
: stringupdated_at
: datetime.datetimeurl
: stringuser
:NamedUser
create_comment( body, commit_id, path, position )
orcreate_review_comment( body, commit_id, path, position )
:PullRequestComment
body
: stringcommit_id
:Commit
path
: stringposition
: integer
get_comment( id )
orget_review_comment( id )
:PullRequestComment
id
: integer
get_comments()
orget_review_comments()
:PaginatedList
ofPullRequestComment
get_commits()
:PaginatedList
ofCommit
get_files()
:PaginatedList
ofFile
create_issue_comment( body )
:IssueComment
body
: string
get_issue_comment( id )
:IssueComment
id
: integer
get_issue_comments()
:PaginatedList
ofIssueComment
is_merged()
: boolmerge( [commit_message] )
:PullRequestMergeStatus
commit_message
: string
edit( [title, body, state] )
title
: stringbody
: stringstate
: string
body
: stringcommit_id
: stringcreated_at
: datetime.datetimeid
: integeroriginal_commit_id
: stringoriginal_position
: integerpath
: stringposition
: integerupdated_at
: datetime.datetimeurl
: stringuser
:NamedUser
delete()
edit( body )
body
: string
merged
: boolmessage
: stringsha
: string
label
: stringref
: stringrepo
:Repository
sha
: stringuser
:NamedUser
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
:Organization
owner
:NamedUser
parent
:Repository
permissions
:Permissions
private
: boolpushed_at
: datetime.datetimesize
: integersource
:Repository
ssh_url
: stringsvn_url
: stringupdated_at
: datetime.datetimeurl
: stringwatchers
: integer
compare( base, head )
:Comparison
base
: stringhead
: string
get_assignees()
:PaginatedList
ofNamedUser
has_in_assignees( assignee )
: boolassignee
:NamedUser
get_branch( branch )
:Branch
branch
: string
get_branches()
:PaginatedList
ofBranch
add_to_collaborators( collaborator )
collaborator
:NamedUser
get_collaborators()
:PaginatedList
ofNamedUser
has_in_collaborators( collaborator )
: boolcollaborator
:NamedUser
remove_from_collaborators( collaborator )
collaborator
:NamedUser
get_comment( id )
:CommitComment
id
: integer
get_comments()
:PaginatedList
ofCommitComment
get_issues_comments([sort, direction, since])
:PaginatedList
ofIssueComment
sort
: stringdirection
: stringsince
: datetime.datetime
get_pulls_comments([sort, direction, since])
orget_pulls_review_comments([sort, direction, since])
:PaginatedList
ofPullRequestComment
sort
: stringdirection
: stringsince
: datetime.datetime
get_commit( sha )
:Commit
sha
: string
get_commits( [sha, path] )
:PaginatedList
ofCommit
sha
: stringpath
: string
get_readme( [ref] )
:ContentFile
ref
: string
get_contents( path, [ref] )
:ContentFile
path
: stringref
: string
get_archive_link( archive_format, [ref] )
: stringarchive_format
: stringref
: string
get_contributors()
:PaginatedList
ofNamedUser
delete()
create_download( name, size, [description, content_type] )
:Download
name
: stringsize
: integerdescription
: stringcontent_type
: string
get_download( id )
:Download
id
: integer
get_downloads()
:PaginatedList
ofDownload
get_events()
:PaginatedList
ofEvent
get_network_events()
:PaginatedList
ofEvent
get_forks()
:PaginatedList
ofRepository
create_git_blob( content, encoding )
:GitBlob
content
: stringencoding
: string
get_git_blob( sha )
:GitBlob
sha
: string
create_git_commit( message, tree, parents, [author, committer] )
:GitCommit
message
: stringtree
:GitTree
parents
: list ofGitCommit
author
:InputGitAuthor
committer
:InputGitAuthor
get_git_commit( sha )
:GitCommit
sha
: string
create_git_ref( ref, sha )
:GitRef
ref
: stringsha
: string
get_git_ref( ref )
:GitRef
ref
: string
get_git_refs()
:PaginatedList
ofGitRef
create_git_tag( tag, message, object, type, [tagger] )
:GitTag
tag
: stringmessage
: stringobject
: stringtype
: stringtagger
:InputGitAuthor
get_git_tag( sha )
:GitTag
sha
: string
create_git_tree( tree, [base_tree] )
:GitTree
tree
: list ofInputGitTreeElement
base_tree
:GitTree
get_git_tree( sha, [recursive] )
:GitTree
sha
: stringrecursive
: bool
create_hook( name, config, [events, active] )
:Hook
name
: stringconfig
: dictevents
: list of stringactive
: bool
get_hook( id )
:Hook
id
: integer
get_hooks()
:PaginatedList
ofHook
create_issue( title, [body, assignee, milestone, labels] )
:Issue
title
: stringbody
: stringassignee
:NamedUser
milestone
:Milestone
labels
: list ofLabel
get_issue( number )
:Issue
number
: integer
get_issues( [milestone, state, assignee, mentioned, labels, sort, direction, since] )
:PaginatedList
ofIssue
milestone
:Milestone
or "none" or "*"state
: stringassignee
:NamedUser
or "none" or "*"mentioned
:NamedUser
labels
: list ofLabel
sort
: stringdirection
: stringsince
: datetime.datetime
legacy_search_issues( state, keyword )
:PaginatedList
ofIssue
state
: "open" or "closed"keyword
: string
get_issues_event( id )
:IssueEvent
id
: integer
get_issues_events()
:PaginatedList
ofIssueEvent
create_key( title, key )
:RepositoryKey
title
: stringkey
: string
get_key( id )
:RepositoryKey
id
: integer
get_keys()
:PaginatedList
ofRepositoryKey
create_label( name, color )
:Label
name
: stringcolor
: string
get_label( name )
:Label
name
: string
get_labels()
:PaginatedList
ofLabel
get_languages()
: dict of string to integer
merge( base, head, [commit_message] )
:Commit
base
: stringhead
: stringcommit_message
: string
create_milestone( title, [state, description, due_on] )
:Milestone
title
: stringstate
: stringdescription
: stringdue_on
: date
get_milestone( number )
:Milestone
number
: integer
get_milestones( [state, sort, direction] )
:PaginatedList
ofMilestone
state
: stringsort
: stringdirection
: string
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
subscribe_to_hub( event, callback, [secret] )
event
: stringcallback
: stringsecret
: string
unsubscribe_from_hub( event, callback )
event
: stringcallback
: string
create_pull( < title, body, base, head > or < issue, base, head > )
:PullRequest
title
: stringbody
: stringissue
:Issue
base
: stringhead
: string
get_pull( number )
:PullRequest
number
: integer
get_pulls( [state] )
:PaginatedList
ofPullRequest
state
: string
get_stargazers()
:PaginatedList
ofNamedUser
get_subscribers()
:PaginatedList
ofNamedUser
get_tags()
:PaginatedList
ofTag
get_teams()
:PaginatedList
ofTeam
get_watchers()
:PaginatedList
ofNamedUser
id
: integerkey
: stringtitle
: stringurl
: stringverified
: bool
delete()
edit( [title, key] )
title
: stringkey
: string
commit
:Commit
name
: stringtarball_url
: stringzipball_url
: string
id
: integermembers_count
: integername
: stringpermission
: stringrepos_count
: integerurl
: string
delete()
add_to_members( member )
member
:NamedUser
get_members()
:PaginatedList
ofNamedUser
has_in_members( member )
: boolmember
:NamedUser
remove_from_members( member )
member
:NamedUser
edit( name, [permission] )
name
: stringpermission
: string
add_to_repos( repo )
repo
:Repository
get_repos()
:PaginatedList
ofRepository
has_in_repos( repo )
: boolrepo
:Repository
remove_from_repos( repo )
repo
:Repository
id
: integerkey
: stringtitle
: stringurl
: stringverified
: bool
delete()
edit( [title, key] )
title
: stringkey
: string