User

This part of the documentation covers:

None of these objects should ever be instantiated by the user (developer).

When listing users, GitHub only sends a handful of the object’s attributes. To retrieve all of the object’s attributes, you must call the refresh() method. This unfortunately requires another call to the API, so use it sparingly if you have a low limit

User Modules

class github3.users.User(user, session=None)

The User object. This handles and structures information in the User section.

Two user instances can be checked like so:

u1 == u2
u1 != u2

And is equivalent to:

u1.id == u2.id
u1.id != u2.id
add_email_address(address)

Add the single email address to the authenticated user’s account.

Parameters:address (str) – (required), email address to add
Returns:list of email addresses
add_email_addresses(addresses=[])

Add the email addresses in addresses to the authenticated user’s account.

Parameters:addresses (list) – (optional), email addresses to be added
Returns:list of email addresses
delete_email_address(address)

Delete the email address from the user’s account.

Parameters:address (str) – (required), email address to delete
Returns:bool
delete_email_addresses(addresses=[])

Delete the email addresses in addresses from the authenticated user’s account.

Parameters:addresses (list) – (optional), email addresses to be removed
Returns:bool
disk_usage = None

How much disk consumed by the user

events_urlt = None

Events URL Template. Expands with privacy

followers_url = None

Followers URL (not a template)

following_urlt = None

Following URL Template. Expands with other_user

from_json(json)

Return an instance of cls formed from json.

gists_urlt = None

Gists URL Template. Expands with gist_id

gravatar_id = None

ID of the user’s image on Gravatar

hireable = None

True – for hire, False – not for hire

is_assignee_on(login, repository)

Checks if this user can be assigned to issues on login/repository.

Returns:bool
is_following(login)

Checks if this user is following login.

Parameters:login (str) – (required)
Returns:bool
iter_events(public=False, number=-1, etag=None)

Iterate over events performed by this user.

Parameters:
  • public (bool) – (optional), only list public events for the authenticated user
  • number (int) – (optional), number of events to return. Default: -1 returns all available events.
  • etag (str) – (optional), ETag from a previous request to the same endpoint
Returns:

list of Events

iter_followers(number=-1, etag=None)

Iterate over the followers of this user.

Parameters:
  • number (int) – (optional), number of followers to return. Default: -1 returns all available
  • etag (str) – (optional), ETag from a previous request to the same endpoint
Returns:

generator of Users

iter_following(number=-1, etag=None)

Iterate over the users being followed by this user.

Parameters:
  • number (int) – (optional), number of users to return. Default: -1 returns all available users
  • etag (str) – (optional), ETag from a previous request to the same endpoint
Returns:

generator of Users

iter_keys(number=-1, etag=None)

Iterate over the public keys of this user.

New in version 0.5.

Parameters:
  • number (int) – (optional), number of keys to return. Default: -1 returns all available keys
  • etag (str) – (optional), ETag from a previous request to the same endpoint
Returns:

generator of Keys

iter_org_events(org, number=-1, etag=None)

Iterate over events as they appear on the user’s organization dashboard. You must be authenticated to view this.

Parameters:
  • org (str) – (required), name of the organization
  • number (int) – (optional), number of events to return. Default: -1 returns all available events
  • etag (str) – (optional), ETag from a previous request to the same endpoint
Returns:

list of Events

iter_orgs(number=-1, etag=None)

Iterate over organizations the user is member of

Parameters:
  • number (int) – (optional), number of organizations to return. Default: -1 returns all available organization
  • etag (str) – (optional), ETag from a previous request to the same endpoint
Returns:

list of Events

iter_received_events(public=False, number=-1, etag=None)

Iterate over events that the user has received. If the user is the authenticated user, you will see private and public events, otherwise you will only see public events.

Parameters:
  • public (bool) – (optional), determines if the authenticated user sees both private and public or just public
  • number (int) – (optional), number of events to return. Default: -1 returns all events available
  • etag (str) – (optional), ETag from a previous request to the same endpoint
Returns:

generator of Events

iter_starred(sort=None, direction=None, number=-1, etag=None)

Iterate over repositories starred by this user.

Changed in version 0.5: Added sort and direction parameters (optional) as per the change in GitHub’s API.

Parameters:
  • number (int) – (optional), number of starred repos to return. Default: -1, returns all available repos
  • sort (str) – (optional), either ‘created’ (when the star was created) or ‘updated’ (when the repository was last pushed to)
  • direction (str) – (optional), either ‘asc’ or ‘desc’. Default: ‘desc’
  • etag (str) – (optional), ETag from a previous request to the same endpoint
Returns:

generator of Repository

iter_subscriptions(number=-1, etag=None)

Iterate over repositories subscribed to by this user.

Parameters:
  • number (int) – (optional), number of subscriptions to return. Default: -1, returns all available
  • etag (str) – (optional), ETag from a previous request to the same endpoint
Returns:

generator of Repository

organizations_url = None

Organizations URL (not a template)

owned_private_repos = None

Number of private repos owned by this user

plan = None

Which plan this user is on

public_gists = None

Number of public gists

ratelimit_remaining

Number of requests before GitHub imposes a ratelimit.

Returns:int
received_events_url = None

Received Events URL (not a template)

refresh(conditional=False)

Re-retrieve the information for this object and returns the refreshed instance.

Parameters:conditional (bool) – If True, then we will search for a stored header (‘Last-Modified’, or ‘ETag’) on the object and send that as described in the Conditional Requests section of the docs
Returns:self

The reasoning for the return value is the following example:

repos = [r.refresh() for r in g.iter_repos('kennethreitz')]

Without the return value, that would be an array of None‘s and you would otherwise have to do:

repos = [r for i in g.iter_repos('kennethreitz')]
[r.refresh() for r in repos]

Which is really an anti-pattern.

Changed in version 0.5.

repos_url = None

Repostories URL (not a template)

starred_urlt = None

Starred URL Template. Expands with owner and repo

subscriptions_url = None

Subscriptions URL (not a template)

to_json()

Return the json representing this object.

total_private_gists = None

Number of private gists owned by this user

total_private_repos = None

Total number of private repos

update(name=None, email=None, blog=None, company=None, location=None, hireable=False, bio=None)

If authenticated as this user, update the information with the information provided in the parameters.

Parameters:
Returns:

bool


class github3.users.Key(key, session=None)

The Key object. Please see GitHub’s Key Documentation for more information.

Two key instances can be checked like so:

k1 == k2
k1 != k2

And is equivalent to:

k1.id == k2.id
k1.id != k2.id
delete()

Delete this Key

from_json(json)

Return an instance of cls formed from json.

id = None

The unique id of the key at GitHub

key = None

The text of the actual key

ratelimit_remaining

Number of requests before GitHub imposes a ratelimit.

Returns:int
refresh(conditional=False)

Re-retrieve the information for this object and returns the refreshed instance.

Parameters:conditional (bool) – If True, then we will search for a stored header (‘Last-Modified’, or ‘ETag’) on the object and send that as described in the Conditional Requests section of the docs
Returns:self

The reasoning for the return value is the following example:

repos = [r.refresh() for r in g.iter_repos('kennethreitz')]

Without the return value, that would be an array of None‘s and you would otherwise have to do:

repos = [r for i in g.iter_repos('kennethreitz')]
[r.refresh() for r in repos]

Which is really an anti-pattern.

Changed in version 0.5.

title = None

The title the user gave to the key

to_json()

Return the json representing this object.

update(title, key)

Update this key.

Parameters:
  • title (str) – (required), title of the key
  • key (str) – (required), text of the key file
Returns:

bool


class github3.users.Plan(plan)

The Plan object. This makes interacting with the plan information about a user easier. Please see GitHub’s Authenticated User documentation for more specifics.

collaborators = None

Number of collaborators

from_json(json)

Return an instance of cls formed from json.

is_free()

Checks if this is a free plan.

Returns:bool
name = None

Name of the plan

private_repos = None

Number of private repos

space = None

Space allowed

to_json()

Return the json representing this object.