Build screenshot endpoints with FastAPI. Use async/await for high-performance screenshot proxy routes.
pip install fastapi httpx uvicorn
from fastapi import FastAPI
from fastapi.responses import Response
import httpx
app = FastAPI()
@app.get("/screenshot")
async def screenshot(url: str = "https://example.com"):
async with httpx.AsyncClient() as client:
response = await client.get("https://snapapi.tech/v1/screenshot", params={
"url": url,
"api_key": "YOUR_KEY",
"format": "png"
})
return Response(content=response.content, media_type="image/png")
SnapAPI renders pages in a real Chromium browser, so JavaScript-heavy FastAPI apps render perfectly. You get: