DataLook Docs
Install guides

FastAPI

Install DataLook on FastAPI — the plain script tag, or the first-party proxy that beats ad blockers. Both on one page.

Add the tag to whatever HTML template you serve.

Add the script to your template <head>

<script defer src="https://cdn.datalook.app/s.js" data-site="YOUR_SITE_ID"></script>

The proxy install serves both s.js and the collector from your own domain, so ad blockers — which match on domain, not path — can't see us. You rewrite one innocuous path prefix to our CDN; the script figures out the rest.

A catch-all route forwards the prefix with httpx.

Add the router

datalook_proxy.py
import httpxfrom fastapi import APIRouter, Request, ResponseTARGET = "https://cdn.datalook.app"router = APIRouter()client = httpx.AsyncClient()@router.api_route("/_axis/{path:path}", methods=["GET", "POST"])async def proxy(path: str, request: Request):    headers = {"X-Forwarded-For": request.client.host if request.client else ""}    if request.method == "POST":        up = await client.post(f"{TARGET}/{path}", content=await request.body(),            headers={**headers, "Content-Type": request.headers.get("content-type", "text/plain")})    else:        up = await client.get(f"{TARGET}/{path}", headers=headers)    return Response(up.content, status_code=up.status_code,                    media_type=up.headers.get("content-type"))

Include it

app.include_router(router)

Point the script at the prefix

<script defer src="/_axis/s.js" data-site="YOUR_SITE_ID"></script>

Heads up

Your server now sits between the visitor and us, so forward the visitor IP (X-Forwarded-For) or your country breakdown will collapse to your server location. The DNS proxy avoids this entirely — see the proxy overview.