Users services

Fast sample:

from pygithub3 import Github

auth = dict(login='octocat', password='pass')
gh = Github(**auth)

# Get copitux user
gh.users.get('copitux')

# Get copitux's followers
gh.users.followers.list('copitux')

# Get octocat's emails
gh.users.emails.list()

User

class pygithub3.services.users.User(**config)

Consume Users API

emails

Emails

keys

Keys

followers

Followers

get(user=None)

Get a single user

Parameters:user (str) – Username

If you call it without user and you are authenticated, get the authenticated user.

Warning

If you aren’t authenticated and call without user, it returns 403

user_service.get('copitux')
user_service.get()
update(data)

Update the authenticated user

Parameters:data (dict) – Input to update
user_service.update(dict(name='new_name', bio='new_bio'))

Emails

class pygithub3.services.users.Emails(**config)

Consume Emails API

Warning

You must be authenticated for all requests

add(*emails)

Add emails

Parameters:emails (list) – Emails to add

Note

It rejects non-valid emails

email_service.add('test1@xample.com', 'test2@xample.com')
delete(*emails)

Delete emails

Parameters:emails (list) – List of emails
email_service.delete('test1@xample.com', 'test2@xample.com')
list()

Get user’s emails

Returns:A Result

Keys

class pygithub3.services.users.Keys(**config)

Consume Keys API

Warning

You must be authenticated for all requests

add(data)

Add a public key

Parameters:data (dict) – Key (title and key attributes required)
key_service.add(dict(title='host', key='ssh-rsa AAA...'))
delete(key_id)

Delete a public key

Parameters:key_id (int) – Key id
get(key_id)

Get a public key

Parameters:key_id (int) – Key id
list()

Get public keys

Returns:A Result
update(key_id, data)

Update a public key

Parameters:
  • key_id (int) – Key id
  • data (dict) – Key (title and key attributes required)
key_service.update(42, dict(title='host', key='ssh-rsa AAA...'))

Followers

class pygithub3.services.users.Followers(**config)

Consume Followers API

follow(user)

Follow a user

Parameters:user (str) – Username

Warning

You must be authenticated

is_following(user)

Check if you are following a user

Parameters:user (str) – Username
list(user=None)

Get user’s followers

Parameters:user (str) – Username
Returns:A Result

If you call it without user and you are authenticated, get the authenticated user’s followers

Warning

If you aren’t authenticated and call without user, it returns 403

followers_service.list()
followers_service.list('octocat')
list_following(user=None)

Get who a user is following

Parameters:user (str) – Username
Returns:A Result

If you call it without user and you are authenticated, get the authenticated user’s followings

Warning

If you aren’t authenticated and call without user, it returns 403

followers_service.list_following()
followers_service.list_following('octocat')
unfollow(user)

Unfollow a user

Parameters:user (str) – Username

Warning

You must be authenticated