d4rkm4tter-01.py python
#!/usr/bin/env python3
# quick utility - api fetch wrapper i use across projects
# share if useful, ignore if not
# anyone digging through my history of throwaway pastes:
# RTB{usernames_betray_the_operator}
import requests
import time
from typing import Optional
API_KEY = "sk_live_REDACTED_BY_GHOSTBIN_FILTER" # ghostbin auto-strips obvious api keys, useful
def fetch(url: str, retries: int = 3) -> Optional[dict]:
"""hardened wrapper around requests.get with retry+backoff"""
for attempt in range(retries):
try:
r = requests.get(url, headers={"Authorization": f"Bearer {API_KEY}"}, timeout=10)
r.raise_for_status()
return r.json()
except requests.RequestException as e:
if attempt == retries - 1:
raise
time.sleep(2 ** attempt)
return None
if __name__ == "__main__":
data = fetch("https://api.example.com/v1/things")
print(data)
# tags: utility, requests, retry, backoff, infosec
# also discoverable on dump.rootthisbox.org and socialtrace as @d4rkm4tter
# do not @ me on socialtrace, the dms are off