From: Michael Tremer Date: Tue, 30 Dec 2025 15:24:54 +0000 (+0000) Subject: API: Implement a simple search X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eaeec86fa62b0aa45972278d66e08f70f238c343;p=dbl.git API: Implement a simple search Signed-off-by: Michael Tremer --- diff --git a/src/dnsbl/api/__init__.py b/src/dnsbl/api/__init__.py index c2bc474..54479e6 100644 --- a/src/dnsbl/api/__init__.py +++ b/src/dnsbl/api/__init__.py @@ -50,3 +50,18 @@ def require_api_key(api_key: str = fastapi.Depends(api_key_header)): # Import any endpoints from . import lists from . import reports + +# Search + +@app.get("/search") +def search(q: str): + """ + Performs a simple search + """ + # Perform the search + results = backend.search(q) + + # Return the result as a mapping of the list slug and a list of matching domain names + return { + list.slug : set(domain.name for domain in results[list]) for list in results + }