ChatGPT citations are the new organic rankings. If your domain is not in the 3-5 URLs ChatGPT cites for a prompt, you are invisible. This tutorial sets up a daily citation tracker that runs your target prompts, extracts cited URLs, and logs share-of-citation per domain over time.
Prerequisites
- Python 3.10+
- A Scavio API key
- SQLite or Postgres for logs
- A list of 10-50 target prompts
Walkthrough
Step 1: Define target prompts
Prompts your buyers are likely to ask ChatGPT.
PROMPTS = [
'best SERP API for AI agents 2026',
'how to replace SerpAPI',
'cheapest google search api'
]Step 2: Query Scavio ChatGPT endpoint
Scavio forwards prompts to ChatGPT and returns the answer with structured citations.
import requests, os
API_KEY = os.environ['SCAVIO_API_KEY']
def ask(prompt):
r = requests.post('https://api.scavio.dev/api/v1/search',
headers={'x-api-key': API_KEY},
json={'platform': 'chatgpt', 'query': prompt})
return r.json()Step 3: Extract citations
Scavio returns a citations array with url and title per source.
def extract_citations(response):
return [c['url'] for c in response.get('citations', [])]Step 4: Log to database
One row per prompt per day per citation.
import sqlite3
conn = sqlite3.connect('citations.db')
conn.execute('CREATE TABLE IF NOT EXISTS citations (date TEXT, prompt TEXT, url TEXT)')
def log_citations(prompt, urls):
for u in urls:
conn.execute('INSERT INTO citations VALUES (date(\'now\'), ?, ?)', (prompt, u))
conn.commit()Step 5: Compute share-of-citation
Percent of prompts where your domain appears.
def share_of_citation(domain):
total = conn.execute('SELECT COUNT(DISTINCT prompt) FROM citations').fetchone()[0]
hits = conn.execute('SELECT COUNT(DISTINCT prompt) FROM citations WHERE url LIKE ?', (f'%{domain}%',)).fetchone()[0]
return hits / total if total else 0Python Example
import os, requests, sqlite3
API_KEY = os.environ['SCAVIO_API_KEY']
PROMPTS = ['best SERP API for AI agents 2026', 'how to replace SerpAPI']
conn = sqlite3.connect('citations.db')
conn.execute('CREATE TABLE IF NOT EXISTS citations (date TEXT, prompt TEXT, url TEXT)')
for p in PROMPTS:
r = requests.post('https://api.scavio.dev/api/v1/search',
headers={'x-api-key': API_KEY},
json={'platform': 'chatgpt', 'query': p})
for c in r.json().get('citations', []):
conn.execute('INSERT INTO citations VALUES (date(\'now\'), ?, ?)', (p, c['url']))
conn.commit()
print('logged')JavaScript Example
const API_KEY = process.env.SCAVIO_API_KEY;
const PROMPTS = ['best SERP API for AI agents 2026', 'how to replace SerpAPI'];
for (const p of PROMPTS) {
const r = await fetch('https://api.scavio.dev/api/v1/search', {
method: 'POST',
headers: { 'x-api-key': API_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({ platform: 'chatgpt', query: p })
});
const data = await r.json();
console.log(p, data.citations?.map(c => c.url));
}Expected Output
Per-prompt citation list. Share-of-citation for your domain across 30 prompts, trended daily. Example: scavio.dev cited in 12/30 prompts = 40% share-of-citation.