71 lines
1.9 KiB
Python
71 lines
1.9 KiB
Python
import pprint
|
|
import requests
|
|
import Apikeys
|
|
|
|
pp = pprint.PrettyPrinter(indent=4)
|
|
BASEURL = "https://api.northpass.com/v2/people/"
|
|
BASEURLNAME = "https://api.northpass.com/v2/people?filter[name][eq]="
|
|
BASEURLEMAIL = "https://api.northpass.com/v2/people?filter[email][cont]="
|
|
APIKEY = Apikeys.DATASNIPPER
|
|
|
|
|
|
def getfromName(BASEURLNAME, APIKEY):
|
|
name = "Someone else"
|
|
url = BASEURLNAME + f"{name}"
|
|
headers = {
|
|
"accept": "*/*",
|
|
"x-api-key": APIKEY,
|
|
"content-type": "application/json",
|
|
}
|
|
response = requests.get(url, headers=headers)
|
|
if response.status_code == 200:
|
|
print("200 Response!")
|
|
else:
|
|
print("Another error! ")
|
|
print(response.status_code)
|
|
response = response.json()
|
|
# print(response)
|
|
# uuid = response["data"][0]["id"]
|
|
# print("Learner ID:" )
|
|
# print(uuid)
|
|
|
|
|
|
def getfromEmail(BASEURLEMAIL, APIKEY):
|
|
# email = "norm2test@northpass.com" # The %2B encodes the + sign in the URL. Using the + sign won't work.
|
|
email = "datasnipper.com"
|
|
url = BASEURLEMAIL + f"{email}"
|
|
headers = {
|
|
"accept": "*/*",
|
|
"x-api-key": APIKEY,
|
|
"content-type": "application/json",
|
|
}
|
|
response = requests.get(url, headers=headers)
|
|
if response.status_code == 200:
|
|
print("200 Error!")
|
|
else:
|
|
print("Another Error!")
|
|
response = response.json()
|
|
# print(response)
|
|
email = response["data"]
|
|
# print("Learner ID:" )
|
|
pp.pprint(email)
|
|
|
|
|
|
def getfromUuid(BASEURL, APIKEY):
|
|
uuid = "57b2b5eb-aa56-4cee-bb32-8c678a2de1b7"
|
|
url = BASEURL + uuid
|
|
headers = {
|
|
"accept": "*/*",
|
|
"x-api-key": APIKEY,
|
|
"content-type": "application/json",
|
|
}
|
|
response = requests.get(url, headers=headers)
|
|
print(response.status_code)
|
|
print(response.text)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
# getfromUuid(BASEURL, APIKEY)
|
|
getfromEmail(BASEURLEMAIL, APIKEY)
|
|
# getfromName(BASEURLNAME, APIKEY)
|