Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mxrch
GitHub Repository: mxrch/GHunt
Path: blob/master/examples/get_people_name.py
252 views
1
import httpx
2
3
import asyncio
4
import sys
5
6
from ghunt.apis.peoplepa import PeoplePaHttp
7
from ghunt.objects.base import GHuntCreds
8
9
10
async def main():
11
if not sys.argv[1:]:
12
exit("Please give an email address.")
13
email = sys.argv[1]
14
15
ghunt_creds = GHuntCreds()
16
ghunt_creds.load_creds() # Check creds (but it doesn't crash if they are invalid)
17
18
as_client = httpx.AsyncClient() # Async client
19
20
people_api = PeoplePaHttp(ghunt_creds)
21
found, person = await people_api.people_lookup(as_client, email, params_template="just_name")
22
# You can have multiple "params_template" for the GHunt APIs,
23
# for example, on this endpoint, you have "just_gaia_id" by default,
24
# "just_name" or "max_details" which is used in the email CLI module.
25
26
print("Found :", found)
27
if found:
28
if "PROFILE" in person.names: # A specification of People API, there are different containers
29
# A target may not exists globally, but only in your contacts,
30
# so it will show you only the CONTACT container,
31
# with the informations you submitted.
32
# What we want here is the PROFILE container, with public infos.
33
34
print("Name :", person.names["PROFILE"].fullname)
35
else:
36
print("Not existing globally.")
37
38
asyncio.run(main()) # running our async code in a non-async code
39