Tutorial

How to Choose Between Queue and Live SERP Modes

Decide when queue SERP APIs save money vs when live mode is worth the premium. Decision framework with cost calculations.

DataForSEO charges $0.0006/query in queue mode versus $0.002 live. Scavio charges $0.005 with instant results. The choice depends on your use case: agents need live results, daily rank tracking can use queues, batch analysis benefits most from queues. This tutorial provides a decision framework with exact cost math.

Prerequisites

  • Python 3.8+
  • requests library
  • A Scavio API key from scavio.dev
  • Understanding of your latency needs

Walkthrough

Step 1: Map use cases to latency requirements

Categorize queries by urgency.

Python
USE_CASES = {
    'agent_search': {'mode': 'live', 'reason': 'Agents block on results'},
    'daily_rank_tracking': {'mode': 'queue', 'reason': 'Processed overnight'},
    'content_research': {'mode': 'live', 'reason': 'Writer waits for data'},
    'competitor_monitoring': {'mode': 'queue', 'reason': 'Scheduled checks'},
}
for uc, info in USE_CASES.items():
    print(f'{uc:25} -> {info["mode"]:5} ({info["reason"]})')

Step 2: Calculate cost savings

Compute exact savings for your volume.

Python
def compare(queries, pct_queue=0.7):
    q = int(queries * pct_queue)
    l = queries - q
    scavio = queries * 0.005
    dfs_mixed = q * 0.0006 + l * 0.002
    print(f'{queries:,} queries ({pct_queue*100:.0f}% queue):')
    print(f'  Scavio (all live):  ${scavio:.2f}')
    print(f'  DFS (queue+live):   ${dfs_mixed:.2f}')
    print(f'  Savings:            ${scavio - dfs_mixed:.2f}')
    print(f'  Note: Scavio = 6 platforms, DFS = Google-focused')

compare(10000)
compare(100000, 0.9)

Step 3: Build a dual-mode client

Route queries to the right mode based on context.

Python
import os, requests
API_KEY = os.environ['SCAVIO_API_KEY']
H = {'x-api-key': API_KEY, 'Content-Type': 'application/json'}

def search(query, mode='live'):
    # Scavio is always live; for queue you'd use DataForSEO
    data = requests.post('https://api.scavio.dev/api/v1/search',
        headers=H, json={'query': query, 'country_code': 'us'}).json()
    return data

def auto_route(query, context='default'):
    if context in ('agent', 'interactive'): return 'live'
    if context in ('batch', 'scheduled'): return 'queue'
    return 'live'

for q, ctx in [('trending apis', 'agent'), ('rank check kw1', 'batch')]:
    mode = auto_route(q, ctx)
    print(f'  [{mode}] ({ctx}) "{q}"')

Step 4: Implement cost tracking

Track spend across modes for budget visibility.

Python
class CostTracker:
    def __init__(self):
        self.live = 0
        self.queue = 0
    def log(self, mode):
        if mode == 'live': self.live += 1
        else: self.queue += 1
    def report(self):
        live_cost = self.live * 0.005
        queue_cost = self.queue * 0.0006
        print(f'Live: {self.live} (${live_cost:.3f}), Queue: {self.queue} (${queue_cost:.3f})')
        print(f'Total: ${live_cost + queue_cost:.3f}')

tracker = CostTracker()
tracker.log('live'); tracker.log('queue'); tracker.log('queue')
tracker.report()

Python Example

Python
def compare(queries, pct_queue=0.7):
    q = int(queries * pct_queue)
    scavio = queries * 0.005
    mixed = q * 0.0006 + (queries - q) * 0.002
    print(f'{queries:,} queries: Scavio=${scavio:.2f}, DFS mixed=${mixed:.2f}, Save=${scavio-mixed:.2f}')

compare(10000)
compare(100000, 0.9)

JavaScript Example

JavaScript
function compare(queries, pctQueue = 0.7) {
  const q = Math.floor(queries * pctQueue);
  const scavio = queries * 0.005;
  const mixed = q * 0.0006 + (queries - q) * 0.002;
  console.log(`${queries}: Scavio=$${scavio.toFixed(2)}, DFS=$${mixed.toFixed(2)}, Save=$${(scavio-mixed).toFixed(2)}`);
}
compare(10000); compare(100000, 0.9);

Expected Output

JSON
agent_search              -> live  (Agents block on results)
daily_rank_tracking       -> queue (Processed overnight)

10,000 queries (70% queue):
  Scavio (all live):  $50.00
  DFS (queue+live):   $7.20
  Savings:            $42.80
  Note: Scavio = 6 platforms, DFS = Google-focused

Related Tutorials

Frequently Asked Questions

Most developers complete this tutorial in 15 to 30 minutes. You will need a Scavio API key (free tier works) and a working Python or JavaScript environment.

Python 3.8+. requests library. A Scavio API key from scavio.dev. Understanding of your latency needs. A Scavio API key gives you 250 free credits per month.

Yes. The free tier includes 250 credits per month, which is more than enough to complete this tutorial and prototype a working solution.

Scavio has a native LangChain package (langchain-scavio), an MCP server, and a plain REST API that works with any HTTP client. This tutorial uses the raw REST API, but you can adapt to your framework of choice.

Start Building

Decide when queue SERP APIs save money vs when live mode is worth the premium. Decision framework with cost calculations.