Skip to content

Instantly share code, notes, and snippets.

@rezkyfm
Last active February 18, 2023 15:20
Show Gist options
  • Save rezkyfm/8543249d2c764e4e0bdd7cd9a9052077 to your computer and use it in GitHub Desktop.
Save rezkyfm/8543249d2c764e4e0bdd7cd9a9052077 to your computer and use it in GitHub Desktop.
Check if user in github follow you back or not
'''
Check if user in github follow you back or not
'''
import requests
username = input("Enter your username: ")
def main(username):
# Get followers data
followers_api = requests.get(
'https://api.github.com/users/'+username+'/followers')
followers_json = followers_api.json()
followers = []
for f in range(len(followers_json)):
followers.append(followers_json[f]['login'])
# Get Following data
following_api = requests.get(
'https://api.github.com/users/'+username+'/following')
following_json = following_api.json()
following = []
for f in range(len(following_json)):
following.append(following_json[f]['login'])
# Get the result
result = list(set(following) - set(followers))
# Return result data
for r in result:
print(r)
if __name__ == "__main__":
main(username)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment