pmeerw's blog

28 Apr 2020

Tue, 28 Apr 2020

ECG API

Mit dem API key lässt sich dann die ECG-Liste abfragen... Und eine schöne Beschreibung der API gibt's auch: https://ecg.rtr.at/dev/doc

#!/usr/bin/python3

import requests
import sys
import hashlib

URL = 'https://ecg.rtr.at/dev/api/v1/emails/check/batch'

headers = {'X-API-KEY': 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'}

emails_plain = ['example@example.com', 'example.com']

body_plain = {'emails': emails_plain, 'contained': True, 'hashed': False}
resp = requests.post(URL, headers=headers, json=body_plain)

print(resp.status_code)
print(resp.text)

emails_hashed = [hashlib.sha512(bytes(x, 'ascii')).hexdigest() for x in emails_plain]
body_hashed = {'emails': emails_hashed, 'contained': True, 'hashed': True}
resp = requests.post(URL, headers=headers, json=body_hashed)

print(resp.status_code)
print(resp.text)

Ergebnis: example@example.com und die Domain example.com sind nicht in der ECG-Liste

200
{"emails":[]}
200
{"emails":[]}

posted at: 14:37 | path: /rant | permanent link

Made with PyBlosxom