FastAPI Integration

Backlink data in FastAPI. Async. Type-safe.

Call RankParse from async FastAPI endpoints using httpx. Add domain authority, tech stack detection, and backlink data to any Python backend in 10 minutes.

Patterns

Async proxy endpoint

Proxy RankParse behind your own FastAPI endpoint. Add your own auth, caching, and rate limiting without changing client code.

Concurrent enrichment

Use asyncio.gather() to call multiple RankParse endpoints in parallel — authority + tech stack in one response time.

Background enrichment task

Use FastAPI BackgroundTasks or Celery to enrich a domain list asynchronously after a form submission.

Pydantic response models

Wrap RankParse JSON in Pydantic models for type-safe responses and auto-generated OpenAPI docs.

Example: async FastAPI integration

Async domain info endpoint that calls authority and tech stack in parallel.

# main.py — FastAPI app with RankParse integration
import httpx
from fastapi import FastAPI, Query, HTTPException
from functools import lru_cache

app = FastAPI()
RANKPARSE_KEY = "rp_your_key"
BASE = "https://api.rankparse.com/v1"


async def rp_get(path: str, params: dict) -> dict:
    """Async helper for RankParse API calls."""
    async with httpx.AsyncClient() as client:
        resp = await client.get(
            f"{BASE}{path}",
            headers={"X-API-Key": RANKPARSE_KEY},
            params=params,
            timeout=10.0,
        )
        resp.raise_for_status()
        return resp.json()


@app.get("/domain-info")
async def domain_info(domain: str = Query(..., description="Domain to analyze")):
    """Return authority score and tech stack for a domain."""
    try:
        authority, tech = await asyncio.gather(
            rp_get("/domain-authority", {"domain": domain}),
            rp_get("/tech-stack", {"domain": domain}),
        )
    except httpx.HTTPStatusError as e:
        raise HTTPException(status_code=502, detail=f"RankParse error: {e.response.status_code}")

    return {
        "domain": domain,
        "authority_score": authority["data"]["authority_score"],
        "referring_domains": authority["data"]["referring_domains"],
        "tech_stack": [t["name"] for t in tech["data"].get("technologies", [])],
    }


@app.get("/backlinks")
async def backlinks(
    domain: str = Query(...),
    limit: int = Query(20, ge=1, le=1000),
):
    """Proxy the RankParse backlinks endpoint."""
    result = await rp_get("/backlinks", {"domain": domain, "limit": limit})
    return result["data"]

Add SEO data to your FastAPI app.

100 free credits. No credit card. 10-minute integration.

Get API key — free