The script
import json
import os
import urllib.request
API = "https://indizio.rexago.com/api/v1"
KEY = os.environ["INDIZIO_API_KEY"]
def indizio(path, body=None):
req = urllib.request.Request(
API + path,
data=json.dumps(body).encode() if body is not None else None,
method="POST" if body is not None else "GET",
headers={
"Authorization": "Bearer " + KEY,
"Content-Type": "application/json",
"Accept": "application/json",
"User-Agent": "my-system/1.0",
},
)
with urllib.request.urlopen(req, timeout=60) as res:
print("charged:", res.headers.get("X-Indizio-Credits-Charged"),
"| remaining:", res.headers.get("X-Indizio-Credits-Remaining"))
return json.load(res)
company = indizio("/enrich/company", {"domain": "goldbachkirchner.de"})
print(company["data"]["name"], "-", company["data"]["address"]["city"])
account = indizio("/account")
print("Balance:", account["data"]["account"]["credit_balance"])
Run it with:
INDIZIO_API_KEY=<YOUR-API-KEY> python3 indizio.py
Recommended: your own User-Agent
The line "User-Agent": "my-system/1.0" is not required — without it Python
sends Python-urllib/…, and that works too. Still, ideally use the name of
your system: it helps us if you ever have a question about a specific call.