Run a fair comparison of SocialTap with another social media API: send both the same inputs, count what each successful result cost, and read every answer the same way. This page is for the developer or the agent running the test.
The shortest test is one request. This calls the TikTok Profile API with its example input; send the same input to the
other API, then compare the two answers and what each cost (meta.credits_charged here):
curl 'https://socialtap.dev/v1/tiktok/profile?handle=nasa' \
-H "x-api-key: $SOCIALTAP_API_KEY"// Save this as app.mjs (an ES module) and run: node app.mjs
import { SocialTap } from "socialtap";
const client = new SocialTap(); // apiKey defaults to process.env.SOCIALTAP_API_KEY
const res = await client.tiktok.profile.get({ handle: "nasa" });
console.log(res.data);
console.log(res.credits.charged, res.meta.request_id);from socialtap import SocialTap
client = SocialTap() # api_key defaults to os.environ["SOCIALTAP_API_KEY"]
res = client.tiktok.profile.get(handle="nasa")
print(res.data)
print(res.credits.charged, res.meta.request_id)package main
import (
"context"
"fmt"
"log"
socialtap "socialtap.dev/sdk/go"
)
func main() {
ctx := context.Background()
client, err := socialtap.NewClient() // the API key defaults to $SOCIALTAP_API_KEY
if err != nil {
log.Fatal(err)
}
res, err := client.TikTok.Profile.Get(ctx, socialtap.TikTokProfileParams{Handle: "nasa"})
if err != nil {
log.Fatal(err)
}
fmt.Println(res.Data)
fmt.Println(res.Credits.Charged, res.Meta.RequestID)
}// Node 18+: save this as app.mjs (an ES module) and run: node app.mjs
const params = new URLSearchParams({
handle: "nasa",
});
const res = await fetch(`https://socialtap.dev/v1/tiktok/profile?${params}`, {
headers: { "x-api-key": process.env.SOCIALTAP_API_KEY ?? "" },
});
const body = await res.json();
if (!res.ok) throw new Error(`${body.error.code}: ${body.error.message}`);
const { data, meta } = body;
console.log(data, meta.credits_charged);import os
import requests
res = requests.get(
"https://socialtap.dev/v1/tiktok/profile",
params={"handle": "nasa"},
headers={"x-api-key": os.environ["SOCIALTAP_API_KEY"]},
)
body = res.json()
if not res.ok:
raise RuntimeError(f"{body['error']['code']}: {body['error']['message']}")
data, meta = body["data"], body["meta"]
print(data, meta["credits_charged"])package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"net/url"
"os"
)
func main() {
q := url.Values{}
q.Set("handle", "nasa")
req, err := http.NewRequest("GET", "https://socialtap.dev/v1/tiktok/profile?"+q.Encode(), nil)
if err != nil {
log.Fatal(err)
}
req.Header.Set("x-api-key", os.Getenv("SOCIALTAP_API_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
var body struct {
Data json.RawMessage `json:"data"`
Meta map[string]any `json:"meta"`
Error *struct {
Code string `json:"code"`
Message string `json:"message"`
} `json:"error"`
}
if err := json.NewDecoder(res.Body).Decode(&body); err != nil {
log.Fatal(err)
}
if body.Error != nil {
log.Fatalf("%s: %s", body.Error.Code, body.Error.Message)
}
fmt.Println(string(body.Data), body.Meta["credits_charged"])
}<?php
$query = http_build_query([
'handle' => 'nasa',
]);
$ch = curl_init('https://socialtap.dev/v1/tiktok/profile?' . $query);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['x-api-key: ' . getenv('SOCIALTAP_API_KEY')],
]);
$body = json_decode(curl_exec($ch), true);
if (curl_getinfo($ch, CURLINFO_RESPONSE_CODE) >= 400) {
throw new RuntimeException($body['error']['code'] . ': ' . $body['error']['message']);
}
print_r($body['data']);
echo $body['meta']['credits_charged'], PHP_EOL;require "json"
require "net/http"
uri = URI("https://socialtap.dev/v1/tiktok/profile")
uri.query = URI.encode_www_form('handle' => 'nasa')
req = Net::HTTP::Get.new(uri)
req["x-api-key"] = ENV.fetch("SOCIALTAP_API_KEY")
res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
body = JSON.parse(res.body)
raise "#{body["error"]["code"]}: #{body["error"]["message"]}" unless res.is_a?(Net::HTTPSuccess)
pp body["data"]
puts body["meta"]["credits_charged"]import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
public class Main {
public static void main(String[] args) throws Exception {
String query = "handle=" + encode("nasa");
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://socialtap.dev/v1/tiktok/profile?" + query))
.header("x-api-key", System.getenv("SOCIALTAP_API_KEY"))
.GET()
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
// An error is {"error": {"code", "message", ...}}; success is {data, meta}, meta.credits_charged its price.
if (response.statusCode() >= 400) throw new RuntimeException(response.body());
System.out.println(response.body());
}
static String encode(String value) {
return URLEncoder.encode(value, StandardCharsets.UTF_8);
}
}using System.Text.Json;
using var http = new HttpClient();
http.DefaultRequestHeaders.Add("x-api-key", Environment.GetEnvironmentVariable("SOCIALTAP_API_KEY"));
var query = string.Join("&",
"handle=" + Uri.EscapeDataString("nasa"));
var res = await http.GetAsync("https://socialtap.dev/v1/tiktok/profile?" + query);
using var body = JsonDocument.Parse(await res.Content.ReadAsStringAsync());
if (!res.IsSuccessStatusCode)
{
var error = body.RootElement.GetProperty("error");
throw new Exception($"{error.GetProperty("code")}: {error.GetProperty("message")}");
}
Console.WriteLine(body.RootElement.GetProperty("data"));
Console.WriteLine(body.RootElement.GetProperty("meta").GetProperty("credits_charged"));// Cargo.toml: reqwest = { version = "0.12", features = ["blocking", "json"] }, serde_json = "1"
use std::env;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let res = reqwest::blocking::Client::new()
.get("https://socialtap.dev/v1/tiktok/profile")
.query(&[("handle", "nasa")])
.header("x-api-key", env::var("SOCIALTAP_API_KEY")?)
.send()?;
let ok = res.status().is_success();
let body: serde_json::Value = res.json()?;
if !ok {
return Err(format!("{}: {}", body["error"]["code"], body["error"]["message"]).into());
}
println!("{} {}", body["data"], body["meta"]["credits_charged"]);
Ok(())
}Start with the endpoints people use most
Each row is a kind of data people ask for most, on the platform they ask for it most. Every other endpoint is in the API reference.
| Data | Try first | Price |
|---|---|---|
| Posts | TikTok Post API | 1 credit |
| Profiles | TikTok Profile API | 1 credit |
| Comments | TikTok Comments API | 1 credit per page |
| Transcripts | TikTok Transcript API | 1 credit (captions) or 2 credits + 2 per started minute of media (speech-to-text, automatic up to 3 minutes, longer with transcribe_audio=true) |
| Ads | TikTok Ad Library Search API | 1 credit per page |
| Hashtags | TikTok Hashtag API | 1 credit |
For any other need, ask the MCP server's find_endpoint tool in plain words or with a link. It names the endpoint,
its arguments and its price, free and without a key. The script below uses it.
Send every vendor the same inputs
- Pick the inputs first. Use real links, handles and searches from your own product. Mix large and small accounts, new and old posts, and a few that should fail (a deleted post, a private account).
- Send each input to every vendor within minutes. Counts change by the minute, so a test run hours apart compares two different moments.
- Send links the way your users paste them. Mobile, short and tracking links included. Each endpoint's reference lists the link forms and IDs it takes.
Measure the cost of each successful result
Failed requests are free here, so the number that matters is what you paid divided by the results you can use, not by the requests you sent.
- Read what each answer cost in
meta.credits_charged, or thex-credits-chargedheader, and add them up. A retry after a failure adds nothing. - An empty answer that succeeds is charged, such as a search with no results. Count it as a request, not a result.
- Convert credits to money with the price per credit of the plan or pack you would buy, on the pricing page.
Read null as unknown, never as zero
nullmeans the platform doesn't show the value. Another API's0for the same field is not more data. Compare a field only where both answers know it, and count how often each one knows it.approximate_fieldslists the values the platform rounded or showed as display text ("1.5M"). Compare those with a tolerance.unknown_fieldslists the lists whose[]means unknown, not none.
The Requests guide has every rule.
Compare the full answer
A REST answer has every field of the schema. An MCP tool's result is concise: it leaves out null fields and empty
objects. Pass detail="full" to a tool for every field, so you compare the same answer another API sends whole.
Leave caching out while you measure
max_age accepts a stored answer up to that many seconds old, and a cache hit is free, with
meta.is_cached true. Leave it out while you measure, so every answer is read live. Add it in production, where a
free repeat is what you want.
Compare lists by the item
A list is priced per page. A smaller limit costs the same per page, so leave it out. Walk the same
number of pages on each API and divide what you paid by the items you got. A page with page.has_more true
and no items is not the end of the list: the Pagination guide says why.
Time requests on your side
Time each request from the same machine for every vendor, with the same inputs, at the same time of day. The first
request for an item reads the platform; a repeat with max_age can come from the cache, much faster, so keep
cached answers out of a speed test.
Keep the request ID of anything odd
A success carries meta.request_id, an error error.request_id, and both the x-request-id header. When an answer looks wrong, send the ID and what you expected to support: we can see that
exact request.
Common pitfalls
| Pitfall | Do this instead |
|---|---|
Scoring another API's 0 higher than a null | Compare a field only where both answers know it |
| Comparing a concise MCP result with a full answer | Pass detail="full" |
| Counting failed requests in the cost | Add up meta.credits_charged: failures add nothing |
Leaving max_age set | Leave it out while you measure: cache hits are free and fast |
Lowering limit to save | Leave it out: a page costs the same at any size |
| Typing an input differently per vendor | Send the same string to each |
| Reading rounded values as exact | Check approximate_fields |
| Testing only inputs that work | Include a deleted post and a private account, and compare the error codes: not_found and private_or_unavailable here |
A comparison script
The script finds the endpoint for each need with find_endpoint and calls it with your inputs. It prints one line per
answer: whether it succeeded, the error code, the credits it cost and the seconds it took. It uses the Python SDK
(pip install socialtap) and its agent tools, which call the MCP server's tools, and reads the key from
SOCIALTAP_API_KEY.
import json, time
from socialtap import SocialTap
from socialtap.tools import call_tool
client = SocialTap()
# Each need in plain words, and the inputs you also send every other vendor.
TESTS = [
("<your need, in plain words>", [{"<param>": "<your link, handle or search>"}]),
]
for need, inputs in TESTS:
match = call_tool(client, "find_endpoint", {"query": need, "limit": 1}).output["results"][0]
for args in inputs:
started = time.monotonic()
r = call_tool(client, match["tool"], {**match["arguments"], **args, "detail": "full"})
print(json.dumps({
"need": need,
"endpoint": match["endpoint"],
"input": args,
"ok": not r.is_error,
"error": r.output["error"]["code"] if r.is_error else None,
"credits": r.output.get("credits_charged", 0),
"seconds": round(time.monotonic() - started, 2),
}))match["params"] names the parameters the endpoint takes, and match["example_arguments"] shows the kind of input
each one wants.