Merge remote-tracking branch 'upstream/dev' into fix/onboarding

This commit is contained in:
Anish Sarkar 2026-07-14 10:18:03 +05:30
commit 2d837ea18c
185 changed files with 4729 additions and 3630 deletions

View file

@ -1,15 +1,15 @@
import {
type ListScraperRunsParams,
type ScraperRunEvent,
type StartAsyncRunResponse,
listCapabilitiesResponse,
listRunsResponse,
type ScraperRunEvent,
type StartAsyncRunResponse,
scraperRunDetail,
startAsyncRunResponse,
} from "@/contracts/types/scraper.types";
import { authenticatedFetch } from "@/lib/auth-fetch";
import { readSSEStream } from "@/lib/chat/streaming-state";
import { buildBackendUrl } from "@/lib/env-config";
import { authenticatedFetch } from "@/lib/auth-fetch";
import { baseApiService } from "./base-api.service";
const base = (workspaceId: number | string) => `/api/v1/workspaces/${workspaceId}/scrapers`;

View file

@ -40,6 +40,7 @@ const PUBLIC_ROUTE_PREFIXES = [
"/external-mcp-connectors",
"/reddit",
"/instagram",
"/tiktok",
"/youtube",
"/google-maps",
"/google-search",

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,154 @@
import { z } from "zod";
import type { MentionedDocumentInfo } from "@/atoms/chat/mentioned-documents.atom";
import type { ToolUIGate } from "@/lib/chat/streaming-state";
/**
* Every tool call renders a card. The sentinel ``"all"`` matches every tool
* the legacy ``BASE_TOOLS_WITH_UI`` allowlist was dropped so unknown tool
* calls route through the generic ``ToolFallback``. Persisted payload size
* stays bounded because the backend's ``format_thinking_step`` summarisation
* and the ``result_length``-only default for unknown tools keep the JSON
* from ballooning.
*/
export const TOOLS_WITH_UI_ALL: ToolUIGate = "all";
export const TURN_CANCELLING_INITIAL_DELAY_MS = 200;
export const TURN_CANCELLING_BACKOFF_FACTOR = 2;
export const TURN_CANCELLING_MAX_DELAY_MS = 1500;
export const RECENT_CANCEL_WINDOW_MS = 5_000;
export function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}
export function computeFallbackTurnCancellingRetryDelay(attempt: number): number {
const safeAttempt = Math.max(1, attempt);
const raw =
TURN_CANCELLING_INITIAL_DELAY_MS * TURN_CANCELLING_BACKOFF_FACTOR ** (safeAttempt - 1);
return Math.min(raw, TURN_CANCELLING_MAX_DELAY_MS);
}
/**
* Generate a synthetic ``toolCallId`` for an action_request that has no
* matching streamed tool-call card (HITL-blocked subagent calls don't surface
* as tool-call events). Suffixes a counter when the base id is already taken
* sequential interrupts for the same tool name otherwise collide on
* ``interrupt-${name}-${i}`` and crash assistant-ui with a duplicate-key error.
*/
export function freshSynthToolCallId(
toolCallIndices: Map<string, number>,
toolName: string,
index: number
): string {
const base = `interrupt-${toolName}-${index}`;
if (!toolCallIndices.has(base)) return base;
let n = 1;
while (toolCallIndices.has(`${base}-${n}`)) n++;
return `${base}-${n}`;
}
/**
* Pair each ``action_request`` to a unique pending tool-call card, preserving
* order so ``decisions[i]`` lines up with ``action_requests[i]`` on the wire.
*
* Same-name bundles (e.g. three ``create_jira_issue``) used to collapse onto
* one card because the matcher keyed by name; this consumes each card via the
* ``claimed`` set and walks forward in DOM order.
*/
export function pairBundleToolCallIds(
toolCallIndices: Map<string, number>,
contentParts: Array<{
type: string;
toolName?: string;
result?: unknown;
}>,
actionRequests: ReadonlyArray<{ name: string }>
): Array<string | null> {
const claimed = new Set<string>();
const paired: Array<string | null> = [];
for (const action of actionRequests) {
let matched: string | null = null;
for (const [tcId, idx] of toolCallIndices) {
if (claimed.has(tcId)) continue;
const part = contentParts[idx];
if (!part || part.type !== "tool-call" || part.toolName !== action.name) continue;
const result = part.result as Record<string, unknown> | undefined | null;
if (result == null || (result.__interrupt__ === true && !result.__decided__)) {
matched = tcId;
claimed.add(tcId);
break;
}
}
paired.push(matched);
}
return paired;
}
/**
* Zod schema for mentioned document info (for type-safe parsing).
*
* ``kind`` defaults to ``"doc"`` so messages persisted before folder
* mentions existed deserialise unchanged.
*/
const MentionedDocumentInfoSchema = z.object({
id: z.number(),
title: z.string(),
document_type: z.string().optional(),
kind: z
.union([z.literal("doc"), z.literal("folder"), z.literal("connector"), z.literal("thread")])
.optional()
.default("doc"),
connector_type: z.string().optional(),
account_name: z.string().optional(),
});
const MentionedDocumentsPartSchema = z.object({
type: z.literal("mentioned-documents"),
documents: z.array(MentionedDocumentInfoSchema),
});
/**
* Extract mentioned documents from message content (type-safe with Zod).
*/
export function extractMentionedDocuments(content: unknown): MentionedDocumentInfo[] {
if (!Array.isArray(content)) return [];
for (const part of content) {
const result = MentionedDocumentsPartSchema.safeParse(part);
if (result.success) {
return result.data.documents.map<MentionedDocumentInfo>((doc) => {
if (doc.kind === "connector") {
return {
id: doc.id,
title: doc.title,
kind: "connector",
connector_type: doc.connector_type ?? doc.document_type ?? "UNKNOWN",
account_name: doc.account_name ?? doc.title,
};
}
if (doc.kind === "folder") {
return {
id: doc.id,
title: doc.title,
kind: "folder",
};
}
if (doc.kind === "thread") {
return {
id: doc.id,
title: doc.title,
kind: "thread",
};
}
return {
id: doc.id,
title: doc.title,
document_type: doc.document_type ?? "UNKNOWN",
kind: "doc",
};
});
}
}
return [];
}

View file

@ -0,0 +1,177 @@
import type { ThreadMessageLike } from "@assistant-ui/react";
import { createTokenUsageStore } from "@/components/assistant-ui/token-usage-context";
import type { PendingInterruptState } from "@/features/chat-messages/hitl";
/**
* Durable, per-thread streaming state for a single in-flight chat turn.
*
* Lives at module scope (see {@link chatStreamStore}) so a running turn's
* messages / interrupts survive the chat page unmounting during in-app
* navigation. The React tree consumes it through ``useChatStream`` via
* ``useSyncExternalStore`` (state lives outside the render cycle).
*/
export interface ThreadStreamState {
threadId: number;
messages: ThreadMessageLike[];
isRunning: boolean;
pendingInterrupts: PendingInterruptState[];
}
type Listener = () => void;
/**
* Module-level singleton external store for chat streaming.
*
* Single-active-stream invariant: at most one turn streams at a time,
* tracked by {@link active}. Per-thread state is still keyed by threadId so
* the currently-streaming thread and the currently-viewed thread can differ
* (e.g. a stream finishes while the user is on another chat).
*
* ponytail: unbounded ``states`` map is bounded in practice by
* ``clearInactive`` (called on navigation) + ``clear`` (called after the DB
* re-hydrates a finished turn). Upgrade path if that ever leaks: LRU cap.
*/
class ChatStreamStore {
private states = new Map<number, ThreadStreamState>();
private listeners = new Set<Listener>();
/** Shared, cross-navigation token-usage store (one instance app-wide). */
readonly tokenUsage = createTokenUsageStore();
/** The one in-flight turn's abort handle, or null when idle. */
private active: { threadId: number; controller: AbortController } | null = null;
/** Timestamp of the last explicit cancel, for the THREAD_BUSY retry window. */
recentCancelRequestedAt = 0;
subscribe = (listener: Listener): (() => void) => {
this.listeners.add(listener);
return () => {
this.listeners.delete(listener);
};
};
private notify(): void {
for (const l of this.listeners) l();
}
/** Snapshot for ``useSyncExternalStore``; stable ref between mutations. */
getSnapshot = (threadId: number | null): ThreadStreamState | null => {
if (threadId == null) return null;
return this.states.get(threadId) ?? null;
};
isRunning(threadId: number | null): boolean {
if (threadId == null) return false;
return this.states.get(threadId)?.isRunning ?? false;
}
getMessages(threadId: number): ThreadMessageLike[] {
return this.states.get(threadId)?.messages ?? [];
}
getPendingInterrupts(threadId: number): PendingInterruptState[] {
return this.states.get(threadId)?.pendingInterrupts ?? [];
}
private ensure(threadId: number): ThreadStreamState {
let s = this.states.get(threadId);
if (!s) {
s = { threadId, messages: [], isRunning: false, pendingInterrupts: [] };
this.states.set(threadId, s);
}
return s;
}
private commit(threadId: number, next: ThreadStreamState): void {
this.states.set(threadId, next);
this.notify();
}
/** Seed a thread's state at the start of a fresh turn (running=true). */
begin(threadId: number, messages: ThreadMessageLike[]): void {
this.commit(threadId, { threadId, messages, isRunning: true, pendingInterrupts: [] });
}
setMessages(threadId: number, updater: (prev: ThreadMessageLike[]) => ThreadMessageLike[]): void {
const prev = this.ensure(threadId);
const messages = updater(prev.messages);
if (messages === prev.messages) return;
this.commit(threadId, { ...prev, messages });
}
setRunning(threadId: number, running: boolean): void {
const prev = this.ensure(threadId);
if (prev.isRunning === running) return;
this.commit(threadId, { ...prev, isRunning: running });
}
setPendingInterrupts(
threadId: number,
updater: (prev: PendingInterruptState[]) => PendingInterruptState[]
): void {
const prev = this.ensure(threadId);
const pendingInterrupts = updater(prev.pendingInterrupts);
if (pendingInterrupts === prev.pendingInterrupts) return;
this.commit(threadId, { ...prev, pendingInterrupts });
}
/**
* A thread whose overlay must survive DB re-hydration / navigation: it is
* either streaming or paused awaiting a HITL decision (the pending
* interrupts + interrupt cards live only in the overlay).
*/
private isPinned(s: ThreadStreamState): boolean {
return s.isRunning || s.pendingInterrupts.length > 0;
}
/** Drop a thread's overlay once the DB is authoritative. No-op while pinned. */
clear(threadId: number): void {
const s = this.states.get(threadId);
if (!s || this.isPinned(s)) return;
this.states.delete(threadId);
this.notify();
}
/** Evict every non-pinned thread except ``exceptThreadId`` (memory bound). */
clearInactive(exceptThreadId: number | null): void {
let changed = false;
for (const [id, s] of this.states) {
if (id === exceptThreadId || this.isPinned(s)) continue;
this.states.delete(id);
changed = true;
}
if (changed) this.notify();
}
// ---- active-stream lifecycle -------------------------------------------
/** Register a new in-flight turn, aborting any previous one first. */
beginActive(threadId: number, controller: AbortController): void {
this.abortActive();
this.active = { threadId, controller };
}
get activeThreadId(): number | null {
return this.active?.threadId ?? null;
}
/** Clear the active handle iff it still points at ``controller``. */
clearActive(controller: AbortController): void {
if (this.active?.controller === controller) this.active = null;
}
/** Abort the in-flight turn's fetch (client disconnect, not a server stop). */
abortActive(): void {
if (this.active) {
this.active.controller.abort();
this.active = null;
}
}
markRecentCancel(): void {
this.recentCancelRequestedAt = Date.now();
}
}
export const chatStreamStore = new ChatStreamStore();

View file

@ -0,0 +1,18 @@
"use client";
import { useCallback, useSyncExternalStore } from "react";
import { chatStreamStore, type ThreadStreamState } from "./store";
/**
* Subscribe to the durable streaming state for a given thread.
*
* Returns the live ``ThreadStreamState`` while a turn is streaming (or
* pending re-hydration from the DB), or ``null`` when the thread has no
* active overlay in which case the page falls back to its DB-hydrated
* messages. State lives in the module-level {@link chatStreamStore}, so it
* survives the chat page unmounting during in-app navigation.
*/
export function useChatStream(threadId: number | null): ThreadStreamState | null {
const getSnapshot = useCallback(() => chatStreamStore.getSnapshot(threadId), [threadId]);
return useSyncExternalStore(chatStreamStore.subscribe, getSnapshot, () => null);
}

View file

@ -6,28 +6,32 @@ export const instagram: ConnectorPageContent = {
name: "Instagram",
icon: IconBrandInstagram,
metaTitle: "Instagram Scraper API for Creator Research | SurfSense",
metaTitle: "Instagram Scraper API for Profiles and Reels | SurfSense",
metaDescription:
"Scrape public Instagram posts, reels, and profiles at scale with the SurfSense Instagram Scraper API. No login, no official API, plus a free tier. Start now.",
"Instagram scraper API for public profiles, posts, and reels. No login or Graph API review. Structured data for AI agents, plus a free tier. Start now.",
keywords: [
"instagram scraper",
"instagram scraper api",
"instagram api",
"instagram api alternative",
"scrape instagram",
"instagram scraping",
"instagram graph api alternative",
"instagram profile scraper",
"instagram post scraper",
"instagram posts scraper",
"instagram reel scraper",
"instagram reels scraper",
"instagram data scraper",
"instagram data api",
"instagram mcp server",
"creator research",
"social listening",
],
h1: "Instagram Scraper API for Creator Research and Social Listening",
h1: "Instagram Scraper API for Profiles, Posts, and Reels",
heroLede:
"The SurfSense Instagram API extracts public posts, reels, and profile details without logging in or registering for the Instagram Graph API. Give your AI agents a live feed of what creators post, so you spot trends and shifts in engagement first.",
"The SurfSense Instagram scraper extracts public profiles, posts, and reels without logging in or registering for the Instagram Graph API. Give your AI agents a live feed of what creators post, so you spot trends and shifts in engagement first.",
transcript: {
prompt: "Pull recent reels from @competitor and summarize what they're posting",
@ -54,48 +58,48 @@ export const instagram: ConnectorPageContent = {
},
extractIntro:
"Every call returns structured items keyed by type. Point the API at a public profile, post, or reel URL, or discover creators with a search query.",
"Every Instagram scraper call returns structured items keyed by type. Point the API at a public profile, post, or reel URL, or discover creators with a search query.",
extractFields: [
{
label: "Posts & Reels",
label: "Posts and reels",
description:
"Caption, hashtags, mentions, like and comment counts, media URLs, dimensions, and timestamp.",
"Caption, hashtags, mentions, like and comment counts, media URLs, dimensions, and timestamp from any public post or reel.",
},
{
label: "Profiles",
label: "Profile data",
description:
"Follower, following, and post counts, bio, external URL, verified and business flags.",
"Follower, following, and post counts, bio, external URL, verified and business flags for public Instagram profiles.",
},
{
label: "Owner & Media",
label: "Owner and media",
description:
"Owner username and id on every item, plus image and video URLs, alt text, and view counts.",
},
],
useCasesHeading: "What teams do with the Instagram API",
useCasesHeading: "What teams do with the Instagram scraper API",
useCases: [
{
title: "Creator and competitor monitoring",
description:
"Track what your competitors and target creators post, and how engagement moves. Feed the stream to an agent that flags viral formats, launches, and shifts in cadence the moment they land.",
"Scrape Instagram profiles and feeds to track what competitors and target creators post, and how engagement moves. Feed the stream to an agent that flags viral formats, launches, and shifts in cadence the moment they land.",
},
{
title: "Content and format research",
description:
"Study a creator's recent posts and reels to see which formats earn the most likes and comments, and turn that into a content calendar your team can act on.",
"Pull a creator's recent posts and reels to see which formats earn the most likes and comments, and turn that into a content calendar your team can act on.",
},
{
title: "Influencer vetting and outreach",
description:
"Verify a creator's follower count, post cadence, and real engagement from public data before you pay for a partnership.",
"Use the Instagram profile scraper to verify follower count, post cadence, and real engagement from public data before you pay for a partnership.",
},
],
comparison: {
heading: "An Instagram API alternative built for agents",
heading: "An Instagram Graph API alternative built for agents",
intro:
"The official Instagram Graph API requires a Business account, app review, and access tokens, and it can't read arbitrary public profiles. Here is how SurfSense compares.",
"The official Instagram Graph API requires a Business account, app review, and access tokens, and it cannot read arbitrary public profiles. SurfSense is an Instagram API alternative for public data. Here is how it compares.",
columnLabel: "Instagram Graph API",
rows: [
{
@ -259,7 +263,12 @@ export const instagram: ConnectorPageContent = {
{
question: "Do I need an Instagram account or the Graph API?",
answer:
"No. This is an independent alternative to the Instagram Graph API, not a wrapper. You do not create a Business account, pass app review, or manage access tokens. You call the SurfSense API with one key, or add the MCP server to your agent, and get structured data back.",
"No. This Instagram scraper API is an independent alternative to the Instagram Graph API, not a wrapper. You do not create a Business account, pass app review, or manage access tokens. You call SurfSense with one key, or add the MCP server to your agent, and get structured profile, post, and reel data back.",
},
{
question: "What Instagram data can I scrape?",
answer:
"Public profiles, posts, and reels. Each item includes captions, hashtags, mentions, engagement counts, media URLs, and owner metadata. Point the Instagram profile scraper at a handle, or pass post and reel URLs directly. Discover creators with search queries when you do not have a URL yet.",
},
{
question: "What are the rate limits?",
@ -274,11 +283,11 @@ export const instagram: ConnectorPageContent = {
],
related: [
{ label: "Reddit API", href: "/reddit" },
{ label: "TikTok API", href: "/tiktok" },
{ label: "YouTube API", href: "/youtube" },
{ label: "Reddit API", href: "/reddit" },
{ label: "Google Maps API", href: "/google-maps" },
{ label: "SERP API", href: "/google-search" },
{ label: "SurfSense MCP Server", href: "/mcp-server" },
{ label: "Read the docs", href: "/docs" },
],
};

View file

@ -6,30 +6,33 @@ export const tiktok: ConnectorPageContent = {
name: "TikTok",
icon: IconBrandTiktok,
metaTitle: "TikTok Scraper API for Trend and Creator Research | SurfSense",
metaTitle: "TikTok Scraper API for Videos and Comments | SurfSense",
metaDescription:
"Scrape public TikTok videos, comments, accounts, and trending feeds by hashtag, profile, or URL with the SurfSense TikTok Scraper API. No approval process or research-API gatekeeping, plus a free tier. Start now.",
"TikTok scraper API for public videos, comments, hashtags, and profiles. No Research API approval. Structured data for AI agents, plus a free tier. Start now.",
keywords: [
"tiktok scraper",
"tiktok scraper api",
"tiktok api",
"tiktok api alternative",
"scrape tiktok",
"tiktok scraping",
"tiktok research api alternative",
"tiktok data api",
"tiktok hashtag scraper",
"tiktok comments scraper",
"tiktok comment scraper",
"tiktok hashtag scraper",
"tiktok profile scraper",
"tiktok video scraper",
"tiktok trending scraper",
"tiktok user search",
"tiktok trend tracking",
"tiktok mcp",
"social listening",
"influencer research tool",
"short-form video analytics",
],
h1: "TikTok Scraper API for Trend and Creator Research",
h1: "TikTok Scraper API for Videos, Comments, and Trend Research",
heroLede:
"The SurfSense TikTok API extracts public videos by hashtag, creator profile, or URL without TikTok's approval-gated Research API. Give your AI agents a live feed of what your market watches and shares, so you catch a trend while it is still rising.",
"The SurfSense TikTok scraper extracts public videos by hashtag, creator profile, or URL, plus comment threads and trending feeds, without TikTok's approval-gated Research API. Give your AI agents a live feed of what your market watches and shares, so you catch a trend while it is still rising.",
transcript: {
prompt: "Find trending TikToks about meal prep this week",
@ -55,46 +58,48 @@ export const tiktok: ConnectorPageContent = {
},
extractIntro:
"Every call returns structured items. Scrape videos from a hashtag, creator profile, or video URL or switch verbs to pull a video's comments, discover accounts by keyword, or fetch the current trending feed.",
"Every TikTok scraper call returns structured items. Scrape videos from a hashtag, creator profile, or video URL, or switch verbs to pull a video's comments, discover accounts by keyword, or fetch the current trending feed.",
extractFields: [
{
label: "Videos",
description: "Caption text, canonical web URL, duration, and cover image for each video.",
description:
"Caption text, canonical web URL, duration, and cover image for each TikTok video.",
},
{
label: "Engagement",
description:
"Play, like, comment, share, and save counts the signal for what is breaking out.",
"Play, like, comment, share, and save counts, the signal for what is breaking out.",
},
{
label: "Authors",
label: "Authors and profiles",
description: "Creator handle, nickname, follower and heart counts, and verified status.",
},
{
label: "Comments",
description:
"Public comment threads on any video URL, so you can read audience reaction beyond vanity views.",
},
{
label: "Music",
description: "Track name, artist, and whether the sound is original — the seed of a trend.",
description: "Track name, artist, and whether the sound is original, the seed of a trend.",
},
{
label: "Hashtags",
description: "Every hashtag on a video, so you can map a topic cluster or campaign.",
},
{
label: "Timestamps",
description: "Created and scraped times so you can track a video's momentum over runs.",
},
],
useCasesHeading: "What teams do with the TikTok API",
useCasesHeading: "What teams do with the TikTok scraper API",
useCases: [
{
title: "Trend and hashtag monitoring",
description:
"Track a hashtag and feed the stream to an agent that flags breakout videos, rising sounds, and formats before they saturate. Catch the wave while it is still rising, not after.",
"Use the TikTok hashtag scraper to track a topic and feed the stream to an agent that flags breakout videos, rising sounds, and formats before they saturate. Catch the wave while it is still rising, not after.",
},
{
title: "Creator and influencer discovery",
description:
"Surface the creators driving a topic, ranked by real engagement, so your team shortlists partners from data instead of a manager's pitch deck.",
"Scrape TikTok profiles and search users by keyword to surface the creators driving a topic, ranked by real engagement, so your team shortlists partners from data instead of a manager's pitch deck.",
},
{
title: "Competitor content analysis",
@ -102,16 +107,16 @@ export const tiktok: ConnectorPageContent = {
"Watch what your category posts and what actually lands. Turn a competitor's best-performing formats and hooks into your own content brief.",
},
{
title: "Campaign and sentiment tracking",
title: "Campaign and comment sentiment",
description:
"Measure how a launch or branded hashtag spreads across TikTok — video count, reach, and engagement over time — then pull the comments on top videos to read how the audience actually reacts, not just a vanity view count.",
"Measure how a launch or branded hashtag spreads across TikTok, then use the TikTok comments scraper on top videos to read how the audience actually reacts, not just a vanity view count.",
},
],
comparison: {
heading: "A TikTok API alternative built for agents",
heading: "A TikTok Research API alternative built for agents",
intro:
"TikTok's official Research API is approval-gated and largely limited to academic and nonprofit use. If you cannot get access or need it for commercial research, here is how SurfSense compares.",
"TikTok's official Research API is approval-gated and largely limited to academic and nonprofit use. If you cannot get access or need commercial TikTok scraping, SurfSense is a TikTok API alternative. Here is how it compares.",
columnLabel: "Official TikTok API",
rows: [
{
@ -154,7 +159,7 @@ export const tiktok: ConnectorPageContent = {
schema: {
requestNote:
"Provide at least one source: urls, profiles, hashtags, or search_queries. Up to 20 sources per call.",
"Provide at least one source: urls, profiles, or hashtags. Up to 20 sources per call. To find accounts by keyword, use the user search verb.",
request: [
{
name: "urls",
@ -175,13 +180,6 @@ export const tiktok: ConnectorPageContent = {
defaultValue: "[]",
description: "Hashtag names to scrape, without the # prefix. Max 20.",
},
{
name: "search_queries",
type: "string[]",
defaultValue: "[]",
description:
"Keyword search terms. Keyword video search is login-walled and returns no videos — use hashtags/profiles/urls for videos, or user_search for accounts. Max 20.",
},
{
name: "results_per_page",
type: "integer",
@ -253,9 +251,19 @@ export const tiktok: ConnectorPageContent = {
"SurfSense reads only public TikTok data, the same videos any logged-out visitor can see. It never logs in and cannot access private or deleted content. As always, review TikTok's terms and your own compliance needs before you run at scale.",
},
{
question: "Does this need the official TikTok API?",
question: "Does this need the official TikTok Research API?",
answer:
"No. It is an independent alternative, not a wrapper on the Research API, so there is no application or approval process. You call the SurfSense API with one key, or add the MCP server to your agent, and get structured videos back.",
"No. This TikTok scraper API is an independent alternative, not a wrapper on the Research API, so there is no application or approval process. You call SurfSense with one key, or add the MCP server to your agent, and get structured videos, comments, and profile data back.",
},
{
question: "What TikTok data can I scrape?",
answer:
"Four verbs: scrape (videos by hashtag, profile, or URL), comments (a video's public comment thread), user search (find accounts by keyword), and trending (the current Explore feed). Each returns structured items and is billed per item returned.",
},
{
question: "Can I scrape TikTok comments and hashtags?",
answer:
"Yes. Pass a video URL to the comments endpoint for the public comment thread. Pass hashtag names or /tag/ URLs to the TikTok hashtag scraper to pull videos under that tag. Keyword video search is login-walled on TikTok, so hashtags and direct URLs are the reliable discovery paths; to find accounts by keyword, use the user search verb.",
},
{
question: "What are the rate limits?",
@ -265,18 +273,14 @@ export const tiktok: ConnectorPageContent = {
{
question: "Can I scrape a specific creator's videos?",
answer:
"Pass a profile or profile URL and you always get the account's metadata — name, followers, bio, verification. TikTok often withholds the profile video list from automated clients, so that list can come back empty even for a public account; for reliable video results, scrape by hashtag or by a direct video URL.",
},
{
question: "What TikTok data can I scrape?",
answer:
"Four verbs: scrape (videos by hashtag, profile, or URL), comments (a video's public comment thread), user search (find accounts by keyword — the reliable discovery path, since keyword video search is login-walled), and trending (the current Explore feed). Each returns structured items and is billed per item returned.",
"Pass a profile or profile URL and you always get the account's metadata: name, followers, bio, verification. TikTok often withholds the profile video list from automated clients, so that list can come back empty even for a public account. For reliable video results, scrape by hashtag or by a direct video URL.",
},
],
related: [
{ label: "Reddit API", href: "/reddit" },
{ label: "Instagram API", href: "/instagram" },
{ label: "YouTube API", href: "/youtube" },
{ label: "Reddit API", href: "/reddit" },
{ label: "Google Maps API", href: "/google-maps" },
{ label: "SERP API", href: "/google-search" },
{ label: "Web Crawl API", href: "/web-crawl" },

View file

@ -68,3 +68,17 @@ export function formatRelativeFutureDate(dateString: string): string {
export function formatThreadTimestamp(dateString: string): string {
return format(new Date(dateString), "MMM d, yyyy 'at' h:mm a");
}
/**
* Format a chat message timestamp for inline display under a bubble.
* Locale-aware, 12-hour clock. Example: "Jul 13, 10:42 PM".
*/
export function formatMessageTimestamp(date: Date): string {
return date.toLocaleDateString(undefined, {
month: "short",
day: "numeric",
hour: "numeric",
minute: "2-digit",
hour12: true,
});
}

View file

@ -23,7 +23,11 @@ assert.deepEqual(payload, {
query: "<query>",
});
const snippets = buildSnippets("https://api.example.com", "/api/v1/workspaces/1/scrapers/x/y", payload);
const snippets = buildSnippets(
"https://api.example.com",
"/api/v1/workspaces/1/scrapers/x/y",
payload
);
// Every popular language is present.
assert.deepEqual(

View file

@ -11,9 +11,7 @@ export function formatCost(costMicros: number | null | undefined): string {
/** One meter as a per-1k rate, e.g. 3500 micros/place -> "$3.50 / 1k places". */
export function formatRate(meter: ScraperPricingMeter): string {
const perThousand = (meter.micros_per_unit * 1000) / 1_000_000;
const dollars = Number.isInteger(perThousand)
? perThousand.toString()
: perThousand.toFixed(2);
const dollars = Number.isInteger(perThousand) ? perThousand.toString() : perThousand.toFixed(2);
return `$${dollars} / 1k ${meter.unit}s`;
}

View file

@ -8,13 +8,7 @@
type JsonObject = Record<string, unknown>;
export type FieldKind =
| "string"
| "string_array"
| "integer"
| "number"
| "boolean"
| "enum";
export type FieldKind = "string" | "string_array" | "integer" | "number" | "boolean" | "enum";
export interface FormField {
name: string;

View file

@ -29,6 +29,7 @@ import {
QwenIcon,
RecraftIcon,
ReplicateIcon,
RequestyIcon,
SambaNovaIcon,
TogetherAiIcon,
VertexAiIcon,
@ -117,6 +118,8 @@ export function getProviderIcon(
return <RecraftIcon className={cn(className)} />;
case "REPLICATE":
return <ReplicateIcon className={cn(className)} />;
case "REQUESTY":
return <RequestyIcon className={cn(className)} />;
case "SAMBANOVA":
return <SambaNovaIcon className={cn(className)} />;
case "TOGETHER_AI":