Code-Beispiele

Fertige Code-Beispiele in curl, Python, Node.js und PHP für alle API-Endpunkte.

Python

Python — requests

import requests

API_TOKEN = "pt_ihr_token_hier"
BASE_URL = "https://provider.tools/api/v1"
HEADERS = {"Authorization": f"Bearer {API_TOKEN}"}

# DNS-Prüfung
resp = requests.get(f"{BASE_URL}/dns-check", params={"domain": "example.com"}, headers=HEADERS)
data = resp.json()
if data["success"]:
    print(f"A-Records: {data['data']['a']}")
    print(f"MX-Records: {data['data']['mx']}")

# SSL-Prüfung
resp = requests.get(f"{BASE_URL}/ssl-check", params={"domain": "example.com"}, headers=HEADERS)
ssl = resp.json()["data"]
print(f"SSL läuft in {ssl['daysRemaining']} Tagen ab")

# Blacklist-Prüfung
resp = requests.get(f"{BASE_URL}/blacklist-check", params={"ip": "1.2.3.4"}, headers=HEADERS)
bl = resp.json()["data"]
print(f"Gelistet auf {bl['listedCount']} von {bl['totalChecked']} Blacklists")

# DMARC-Prüfung
resp = requests.get(f"{BASE_URL}/dmarc-check", params={"domain": "example.com"}, headers=HEADERS)
dmarc = resp.json()["data"]
if dmarc["dmarc"]["found"]:
    print(f"DMARC-Policy: {dmarc['dmarc']['tags'].get('p', 'none')}")

# Überwachte Hosts auflisten
resp = requests.get(f"{BASE_URL}/monitoring/hosts", headers=HEADERS)
for host in resp.json()["data"]:
    print(f"{host['host']}: {host['status']} ({host['listedCount']} gelistet)")

Node.js

Node.js — fetch (eingebaut)

const API_TOKEN = 'pt_ihr_token_hier';
const BASE_URL = 'https://provider.tools/api/v1';
const headers = { 'Authorization': `Bearer ${API_TOKEN}` };

// DNS-Prüfung
const dns = await fetch(`${BASE_URL}/dns-check?domain=example.com`, { headers });
const dnsData = await dns.json();
console.log('A-Records:', dnsData.data.a);

// SSL-Prüfung
const ssl = await fetch(`${BASE_URL}/ssl-check?domain=example.com`, { headers });
const sslData = await ssl.json();
console.log(`SSL läuft in ${sslData.data.daysRemaining} Tagen ab`);

// Blacklist-Prüfung
const bl = await fetch(`${BASE_URL}/blacklist-check?ip=1.2.3.4`, { headers });
const blData = await bl.json();
console.log(`Gelistet: ${blData.data.listedCount}/${blData.data.totalChecked}`);

// DMARC-Domains
const domains = await fetch(`${BASE_URL}/dmarc/domains`, { headers });
const domainData = await domains.json();
domainData.data.forEach(d => console.log(`${d.domain}: ${d.totalReports} Reports`));

curl / Bash

curl — Shell-Einzeiler

# Token einmal setzen
export PT_TOKEN="pt_ihr_token_hier"

# DNS-Prüfung
curl -s -H "Authorization: Bearer $PT_TOKEN" \
  "https://provider.tools/api/v1/dns-check?domain=example.com" | jq .

# SSL-Prüfung
curl -s -H "Authorization: Bearer $PT_TOKEN" \
  "https://provider.tools/api/v1/ssl-check?domain=example.com" | jq '.data.daysRemaining'

# Blacklist-Prüfung
curl -s -H "Authorization: Bearer $PT_TOKEN" \
  "https://provider.tools/api/v1/blacklist-check?ip=1.2.3.4" | jq '.data.listedCount'

# DMARC-Prüfung
curl -s -H "Authorization: Bearer $PT_TOKEN" \
  "https://provider.tools/api/v1/dmarc-check?domain=example.com" | jq .

# Überwachte Hosts
curl -s -H "Authorization: Bearer $PT_TOKEN" \
  "https://provider.tools/api/v1/monitoring/hosts" | jq '.data[] | {host, status, listedCount}'

# DMARC-Domains + Reports
DOMAIN_ID=$(curl -s -H "Authorization: Bearer $PT_TOKEN" \
  "https://provider.tools/api/v1/dmarc/domains" | jq -r '.data[0].id')
curl -s -H "Authorization: Bearer $PT_TOKEN" \
  "https://provider.tools/api/v1/dmarc/domains/$DOMAIN_ID/reports?limit=5" | jq .