fetch_github_user_avatar_url refer to: https://docs.github.com/en/rest/users/users#get-a-user Args: name (str): the name of github user Returns: str: the avatar url of github user
(name: str)
| 20 | |
| 21 | |
| 22 | def fetch_github_user_avatar_url(name: str) -> str: |
| 23 | """fetch_github_user_avatar_url |
| 24 | |
| 25 | refer to: https://docs.github.com/en/rest/users/users#get-a-user |
| 26 | |
| 27 | Args: |
| 28 | name (str): the name of github user |
| 29 | |
| 30 | Returns: |
| 31 | str: the avatar url of github user |
| 32 | """ |
| 33 | source_avatar_url = f'https://api.github.com/users/{name}' |
| 34 | |
| 35 | header = { |
| 36 | "accept": "application/vnd.github.v3+jso" |
| 37 | } |
| 38 | response = requests.get(source_avatar_url, headers=header) |
| 39 | data = response.json() |
| 40 | return data.get('avatar_url', None) |