Perplexity's answer engine returns sources inline with every answer. For brands, the question is which sources get cited and how often. This tutorial walks through building a daily citation monitor that queries Perplexity with your prompts and extracts the cited URLs.
Prerequisites
- Python 3.8+
- A Scavio API key
- A list of brand-relevant prompts
Walkthrough
Step 1: Define monitored prompts
Curate a list of prompts that represent how users describe your category.
PROMPTS = [
'best AI agent framework in 2026',
'top Claude Code alternatives',
'best search API for LangGraph'
]Step 2: Query Perplexity via Scavio
Scavio's ask endpoint supports Perplexity as a platform.
import requests, os
def ask_perplexity(prompt):
r = requests.post('https://api.scavio.dev/api/v1/ask',
headers={'x-api-key': os.environ['SCAVIO_API_KEY']},
json={'platform': 'perplexity', 'prompt': prompt})
return r.json()Step 3: Extract citations
Perplexity returns citations as a list of source URLs.
def extract_citations(response):
return response.get('citations', [])Step 4: Aggregate by domain
Group citations by domain to see which sites dominate.
from urllib.parse import urlparse
from collections import Counter
def top_domains(all_citations):
domains = [urlparse(c).netloc for c in all_citations]
return Counter(domains).most_common(10)Step 5: Log and compare
Run daily and compare against prior runs to spot gains and losses.
import json
all_cites = []
for p in PROMPTS:
resp = ask_perplexity(p)
all_cites.extend(extract_citations(resp))
print(top_domains(all_cites))Python Example
import os, requests
from urllib.parse import urlparse
from collections import Counter
API_KEY = os.environ['SCAVIO_API_KEY']
PROMPTS = ['best AI agent framework 2026', 'top SerpAPI alternatives']
def ask(prompt):
r = requests.post('https://api.scavio.dev/api/v1/ask',
headers={'x-api-key': API_KEY},
json={'platform': 'perplexity', 'prompt': prompt})
return r.json().get('citations', [])
all_cites = []
for p in PROMPTS:
all_cites.extend(ask(p))
domains = Counter(urlparse(c).netloc for c in all_cites)
print(domains.most_common(5))JavaScript Example
const API_KEY = process.env.SCAVIO_API_KEY;
const PROMPTS = ['best AI agent framework 2026'];
const allCites = [];
for (const p of PROMPTS) {
const r = await fetch('https://api.scavio.dev/api/v1/ask', {
method: 'POST',
headers: { 'x-api-key': API_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({ platform: 'perplexity', prompt: p })
});
allCites.push(...((await r.json()).citations || []));
}
const domains = {};
allCites.forEach(c => { const d = new URL(c).hostname; domains[d] = (domains[d] || 0) + 1; });
console.log(Object.entries(domains).sort((a, b) => b[1] - a[1]).slice(0, 5));Expected Output
A list of top-cited domains for your monitored prompts, e.g. [('github.com', 12), ('langchain.com', 8), ('anthropic.com', 7), ('scavio.dev', 5)]. Over time, track your own domain's citation rate vs competitors.