Answers

How can I know what a social data job will cost before I run it?

Short answer

Count the calls, then multiply by each endpoint's published price. A Douyin research job of 30 searches and 150 comment pages costs $0.90 on okdata: search is $0.02 a call and comments $0.002 a page. Per-call prices do not depend on how many items come back, so the estimate is also the most the job can cost.

Before a marketing lead signs off on a data pull, someone has to say what it will cost. With per-call pricing that is arithmetic, done in three steps.

1. Write the job as calls

A typical Douyin category study: 10 keywords, three pages of search each, then the comments on the top 30 videos, five pages per video.

Step Endpoint Calls Cost
Search Douyin video search 10 × 3 = 30 $0.60
Comments Douyin video comments 30 × 5 = 150 $0.30
Total 180 {{cost:douyin.videos.search30+douyin.videos.comments.list150}}

The same shape on YouTube, using YouTube video search, costs $0.12 for the search step.

2. Price it from the price book, then cap it in code

Every price is on the pricing page, which also has a monthly cost calculator, and in machine-readable form at https://okdata.online/prices.json. Agents connected over MCP can call the free describe tool to read an endpoint's price before spending anything.

import os, requests
from decimal import Decimal

book = requests.get("https://okdata.online/prices.json", timeout=30).json()
price = {e["id"]: Decimal(e["price"]) for e in book["endpoints"]}
plan = {"douyin.videos.search": 30, "douyin.videos.comments.list": 150}
estimate = sum(price[k] * n for k, n in plan.items())
print("estimate:", estimate, "USD")

BUDGET, spent = estimate, Decimal("0")
H = {"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"}

def call(endpoint_path, **params):
    global spent
    if spent >= BUDGET:
        raise RuntimeError(f"budget reached: {spent} USD")
    body = requests.get(f"https://api.okdata.online{endpoint_path}", headers=H, params=params, timeout=60).json()
    if body["code"] != "ok":
        raise RuntimeError(f"{body['code']}: {body['message']}")
    spent += Decimal(body["meta"]["billing"]["amount"])
    return body

first_page = call("/v1/douyin/videos/search", query="露营装备")

3. Check the real charge as you go

Each response carries meta.billing.amount and balance_after. GET https://api.okdata.online/v1/account shows the balance at any time, and GET https://api.okdata.online/v1/calls/{request_id} shows what any single call cost.

Why the estimate holds

  • Per-call endpoints charge the same whether a page holds 20 items or 3, so fewer results never cost more.
  • Before each call, the most it can cost is held from your balance. If the balance cannot cover it, the call is refused with insufficient_balance, free.
  • The one per-item endpoint, Official Account search, is capped at $0.58 per call.

What makes estimates drift is the plan, not the price: a keyword with fewer posts than expected stops early and costs less, and an agent told to keep going until it finds something can run long. Give agents a page limit as well as a budget.

Updated