Using the API

Analyses

Add typed values to each item you fetch, such as its sentiment or buying intent, filter a list on them, and know what each costs.

On this page
  1. What each analysis returns
  2. Parameters
  3. Filter a list with where
  4. Price
  5. Null values
  6. Languages

An analysis is a typed value we add to each item an endpoint returns. It is one of a list of values, true or false, a score from 0 to 1, or a list of objects. Ask for it with analysis and read it under data.analysis:

cURL
curl -G 'https://socialtap.dev/v1/tiktok/post' \
  --data-urlencode 'url=https://www.tiktok.com/@scout2015/video/6718335390845095173' \
  --data-urlencode 'analysis=sentiment' \
  -H "x-api-key: $SOCIALTAP_API_KEY"
Node.js
// Node 18+: save this as app.mjs (an ES module) and run: node app.mjs
const params = new URLSearchParams({
  url: "https://www.tiktok.com/@scout2015/video/6718335390845095173",
  analysis: "sentiment",
});
const res = await fetch(`https://socialtap.dev/v1/tiktok/post?${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);
Python
import os

import requests

res = requests.get(
    "https://socialtap.dev/v1/tiktok/post",
    params={"url": "https://www.tiktok.com/@scout2015/video/6718335390845095173", "analysis": "sentiment"},
    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"])
Go
package main

import (
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"net/url"
	"os"
)

func main() {
	q := url.Values{}
	q.Set("url", "https://www.tiktok.com/@scout2015/video/6718335390845095173")
	q.Set("analysis", "sentiment")
	req, err := http.NewRequest("GET", "https://socialtap.dev/v1/tiktok/post?"+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
<?php

$query = http_build_query([
    'url' => 'https://www.tiktok.com/@scout2015/video/6718335390845095173',
    'analysis' => 'sentiment',
]);
$ch = curl_init('https://socialtap.dev/v1/tiktok/post?' . $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;
Ruby
require "json"
require "net/http"

uri = URI("https://socialtap.dev/v1/tiktok/post")
uri.query = URI.encode_www_form('url' => 'https://www.tiktok.com/@scout2015/video/6718335390845095173', 'analysis' => 'sentiment')
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"]
Java
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 = "url=" + encode("https://www.tiktok.com/@scout2015/video/6718335390845095173")
            + "&analysis=" + encode("sentiment");
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://socialtap.dev/v1/tiktok/post?" + 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);
    }
}
.NET
using System.Text.Json;

using var http = new HttpClient();
http.DefaultRequestHeaders.Add("x-api-key", Environment.GetEnvironmentVariable("SOCIALTAP_API_KEY"));

var query = string.Join("&",
    "url=" + Uri.EscapeDataString("https://www.tiktok.com/@scout2015/video/6718335390845095173"),
    "analysis=" + Uri.EscapeDataString("sentiment"));
var res = await http.GetAsync("https://socialtap.dev/v1/tiktok/post?" + 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"));
Rust
// 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/post")
        .query(&[("url", "https://www.tiktok.com/@scout2015/video/6718335390845095173"), ("analysis", "sentiment")])
        .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(())
}
Shape of data.analysis
{
  "sentiment": "positive",
  "sentiment_probability": 0.85
}

Values are examples.

The item's own fields come back as always, with an analysis object beside them holding only the analyses you asked for, each under its own name. Ask for several at once, comma-separated: they cost what one costs when they read the same thing (see Price).

What each analysis returns

Each analysis has a reference page with its meaning, its values, the inputs it reads, the languages it answers in and the endpoints that offer it. Each endpoint's reference page lists the analyses it offers.

AnalysisWhat it answersPrice
account_kindWho runs the account: a creator, a brand, a local business, a media publisher, a public figure, an organization, a fan or aggregator page, or a private person.Text
aspectsThe aspects a review judges (quality, value, customer service, delivery, food, cleanliness, …), each with its sentiment and the probability that is right.Text
attack_targetWhom the item attacks, if anyone: an individual, an identity group (by race, religion, gender, sexuality, nationality or disability), an organization, another group, or none.Text
authenticity_riskHow likely the review is fake, paid or incentivized rather than a customer's own experience (0 to 1): generic praise or attack with no specifics, marketing language, a rating its words contradict, or a product received free.Text
brand_mentionsFor each of the caller's brands (brand=Notion,Linear, or JSON with aliases, handles and domains): whether the item mentions it, not something else of that name, and how it speaks of it.Text
brand_safetyThe item's risk for an advertiser in each of the 12 categories of GARM's brand safety framework, every category with its level (none, low, medium, high, floor) and the probability that is right.Text
buying_intentHow likely the author is looking to buy, hire or switch to a product or service (0 to 1); with about, one like the caller's.Text
comment_kindWhat kind of comment it is: a genuine reaction or question, a low-effort generic one, self-promotion, spam, or a scam.Text
criteriaThe caller's own yes/no questions answered for the item (criteria=["asks for a refund?"]), each true or false with its probability.Text
disclosureWhether the item clearly discloses a commercial relationship (#ad, #sponsored, paid partnership, affiliate link, gifted), with its probability; read with promotion_type, an undisclosed promotion.Text
entitiesThe people, organizations, products, places, events and works the item names, each with what it is and the probability that is right.Text
formatThe video's format: talking to camera, tutorial, product demo, unboxing, review, vlog, skit, meme, music or dance, slideshow, screen recording, interview or podcast, news, gameplay, animation, a produced ad, or other.Per video
image_safety_labelsWhat a moderator would flag in the item's images: sexual content, violence, self-harm, hate, harassment, drugs, weapons, profanity or a scam; each that applies, with its probability.Per image
labelsWhich of the caller's own labels fit the item (labels=bug,feature_request,praise), most likely first, each with its probability.Text
languageThe language the item is written in (BCP 47 code: en, pt, ja), as the platform states it or read from its words; null when too short to tell.Free
maintenance_statusWhether the repository is archived, active (pushed to within 30 days), maintained (within 6 months), stale (6 months to 2 years) or abandoned (over 2 years); null when the platform shows neither.Free
near_duplicate_ofThe ID of an earlier item on the same page with nearly the same words (copy-pasted or lightly edited); null when the page holds none.Free
nichesThe content niches the account works in (beauty, fitness, food, gaming, tech, finance, …), each that applies, with its probability.Text
outlier_scoreThe post's views divided by the median views of its creator's latest posts: 1 is typical, 5 is five times their usual; null when views aren't shown.Pages it reads
owner_response_rateThe share of the place's newest reviews its owner replied to, from 0 to 1 (the newest page of reviews the platform shows anyone); null without reviews.Pages it reads
promotion_typeWhat the item promotes, if anything: a paid partnership, affiliate links or codes, a gifted product, the author's own business, or none.Text
rating_trendThe average rating of the place's newest reviews minus its overall rating, in stars: -0.8 means recent reviewers rate it 0.8 stars below its average; null without both.Pages it reads
relevanceHow likely the item is about what the caller's about describes: the same need, problem or kind of product (0 to 1).Text
safety_labelsWhat a moderator would flag in the item's words: sexual content, violence, self-harm, hate, harassment, drugs, weapons, profanity or a scam; each that applies, with its probability.Text
segmentsThe spans of a transcript that aren't the video's own content: sponsor reads, self-promotion, reminders to like and subscribe, intros and outros, each with its start and end and its probability.Text
sentimentThe overall feeling the author expresses: positive, negative, neutral, or mixed (clearly both).Text
themesWhat the item does: a pain point, a request for a fix or advice, money talk, an idea, praise, news or self-promotion; each that applies, with its probability.Text
topicsWhat the item is about, as categories of the IAB Content Taxonomy's top level (most likely first; at most three), each with its probability.Text
toxicityHow likely the item is rude, insulting, harassing, hateful, threatening or profane toward someone (0 to 1).Text
video_brand_safetyThe video's risk for an advertiser (what it shows, writes and says) in each of the 12 categories of GARM's brand safety framework, every category with its level and the probability that is right.Per video
video_safety_labelsWhat a moderator would flag in the item's video (what it shows, writes and says): sexual content, violence, self-harm, hate, harassment, drugs, weapons, profanity or a scam; each that applies, with its probability.Per video

A classification (one value, true or false, or a list of values) has a <name>_probability sibling: how sure the answer is, from 0 to 1. A list of objects whose entries are classifications carries a probability on each entry. A score is itself a probability, and a value computed from the item's fields is certain: neither has a sibling.

A value's list only grows. Treat a value you don't know as "other".

Parameters

ParameterRead byDescription
analysisevery analysisAnalyses to add to each item, comma-separated (sentiment,buying_intent): each answers under data.analysis.<name>, with <name>_probability beside a classification. Priced by what they read: text analyses add a flat extra per page, image analyses per image, video analyses per video. Omit for none.
aboutbuying_intent, relevanceWhat you sell or look for, in a sentence: the relevance and buying_intent analyses judge each item against it.
brandbrand_mentionsBrands for brand_mentions: names, comma-separated (Notion,Linear), or a JSON array of names or {"name", "aliases", "handles", "domains"} objects.
labelslabelsYour own categories for the labels analysis, comma-separated or a JSON array: each item gets the ones that fit.
criteriacriteriaYour yes/no questions for the criteria analysis, as a JSON array of strings (["asks for a refund?"]): each item gets true or false per question, with its probability.

The inputs are yours: send them only with the analyses that read them. A request is refused with invalid_input, free, when it:

  • asks for an analysis the endpoint doesn't offer,
  • leaves out an input an analysis needs,
  • or sends an input none of its analyses reads.

criteria, and brand with aliases, take a JSON array, URL-encoded in a query.

Filter a list with where

On a list endpoint, where keeps only the items that pass every condition. Each condition is <path><op><value> over the paths fields takes, analysis.<name> included, with >=, <=, =, != or ~ (contains). Separate conditions with commas, or send a JSON array when a value has a comma.

cURL
curl -G 'https://socialtap.dev/v1/amazon/reviews' \
  --data-urlencode 'url=https://www.amazon.co.uk/dp/0735211299' \
  --data-urlencode 'analysis=authenticity_risk' \
  --data-urlencode 'where=analysis.authenticity_risk>=0.7' \
  -H "x-api-key: $SOCIALTAP_API_KEY"
Node.js
// Node 18+: save this as app.mjs (an ES module) and run: node app.mjs
const params = new URLSearchParams({
  url: "https://www.amazon.co.uk/dp/0735211299",
  analysis: "authenticity_risk",
  where: "analysis.authenticity_risk>=0.7",
});
const res = await fetch(`https://socialtap.dev/v1/amazon/reviews?${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, page, meta } = body;
console.log(data, meta.credits_charged);
Python
import os

import requests

res = requests.get(
    "https://socialtap.dev/v1/amazon/reviews",
    params={"url": "https://www.amazon.co.uk/dp/0735211299", "analysis": "authenticity_risk", "where": "analysis.authenticity_risk>=0.7"},
    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, page, meta = body["data"], body["page"], body["meta"]
print(data, meta["credits_charged"])
Go
package main

import (
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"net/url"
	"os"
)

func main() {
	q := url.Values{}
	q.Set("url", "https://www.amazon.co.uk/dp/0735211299")
	q.Set("analysis", "authenticity_risk")
	q.Set("where", "analysis.authenticity_risk>=0.7")
	req, err := http.NewRequest("GET", "https://socialtap.dev/v1/amazon/reviews?"+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"`
		Page  json.RawMessage `json:"page"`
		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
<?php

$query = http_build_query([
    'url' => 'https://www.amazon.co.uk/dp/0735211299',
    'analysis' => 'authenticity_risk',
    'where' => 'analysis.authenticity_risk>=0.7',
]);
$ch = curl_init('https://socialtap.dev/v1/amazon/reviews?' . $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;
Ruby
require "json"
require "net/http"

uri = URI("https://socialtap.dev/v1/amazon/reviews")
uri.query = URI.encode_www_form('url' => 'https://www.amazon.co.uk/dp/0735211299', 'analysis' => 'authenticity_risk', 'where' => 'analysis.authenticity_risk>=0.7')
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"]
Java
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 = "url=" + encode("https://www.amazon.co.uk/dp/0735211299")
            + "&analysis=" + encode("authenticity_risk")
            + "&where=" + encode("analysis.authenticity_risk>=0.7");
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://socialtap.dev/v1/amazon/reviews?" + 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);
    }
}
.NET
using System.Text.Json;

using var http = new HttpClient();
http.DefaultRequestHeaders.Add("x-api-key", Environment.GetEnvironmentVariable("SOCIALTAP_API_KEY"));

var query = string.Join("&",
    "url=" + Uri.EscapeDataString("https://www.amazon.co.uk/dp/0735211299"),
    "analysis=" + Uri.EscapeDataString("authenticity_risk"),
    "where=" + Uri.EscapeDataString("analysis.authenticity_risk>=0.7"));
var res = await http.GetAsync("https://socialtap.dev/v1/amazon/reviews?" + 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"));
Rust
// 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/amazon/reviews")
        .query(&[("url", "https://www.amazon.co.uk/dp/0735211299"), ("analysis", "authenticity_risk"), ("where", "analysis.authenticity_risk>=0.7")])
        .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(())
}
  • A null value never passes: an item whose analysis is unknown is dropped.
  • A list passes when one of its values does, so analysis.<name>=<value> keeps the items that have that value.
  • limit counts the items fetched, not the items kept, and page.next_cursor continues after the last item fetched.

where filters on any field, not only analyses (metrics.comment_count>=5). A monitor carries where in its params, so it reports only the new items that pass.

Price

An analysis is priced by what it reads, on top of the endpoint's own price. Each class has one rule:

Price classWhat it adds to a request
TextA flat extra per page, however many text analyses you ask for; a single item is a page of one. Each endpoint's reference page states it.
Per image3 credits per image, up to 4 images an item.
Per video30 credits per video, up to 3 minutes long.
Pages it readsThe pages it reads, each at its endpoint's price, once per request.
FreeNothing: computed from the item's own fields.
  • Text is a flat extra per page whatever text analyses you ask for, sized for a full page of the endpoint. A page with fewer items judged (a smaller limit, items whose values were already computed) costs proportionally less.
  • Image analyses judge an item's first 4 images.
  • Video analyses read videos up to 3 minutes long.

max_credits still caps the whole request, analyses included. The credits guide has how a request is charged.

What is free

  • An analysis that couldn't be computed this time.
  • An item in a language the analysis doesn't answer in.
  • An item without what the analysis reads: no words, image or video.
  • A video longer than 3 minutes.
  • An analysis while analyses are paused.
  • A value already computed for the same item, analysis and inputs.

A request answered from the cache with max_age still pays for the analyses it computes.

Null values

A requested analysis is null on an item when its value is unknown. The answer's meta.warnings then carries an analysis_unavailable warning that names the analysis, how many items it is null on and why, and lists the paths in its fields:

WhyWhat to do
It couldn't be computed this timeRepeat the request.
Analyses are paused for nowRepeat the request later.
The item's language isn't one the analysis answers inNothing: the same item gets null again.
The item's video is longer than 3 minutesNothing: the same video gets null again.
The item has nothing the analysis readsNothing: an item without words, images or a video has no value.

None of these is charged. A list analysis with no value that applies is [], not null.

Languages

Each analysis answers for items in the languages listed on its reference page. We read the item's language from the platform when it states one, else from its words. An analysis computed from the item's fields answers in any language.

Last updated