Skip to content

HTTP routes and overrides

All RouteConfig handlers, exported functions, and fallback controls.

Each route is an async function accepting one argument object. Base routes need a webClient; provider and composite routes also need an apiClient. WebcastHttpRouteArgs, WebcastHttpEulerRouteArgs, and WebcastHttpCompositeRouteArgs describe those shared arguments.

RouteConfig memberExported functionInputs beyond the clientsResult
fetchRoomInfofetchRoomInfoRouteOptional roomIdTikTok room-info response.
fetchRoomGiftsfetchRoomGiftsRouteOptional roomIdThe data.gifts array from a signed gift-list request.
fetchRoomInfoFromApiLivefetchRoomInfoFromApiLiveRouteuniqueIdTikTok API-live user/room response.
fetchRoomInfoFromHtmlfetchRoomInfoFromHtmlRouteuniqueIdParsed SIGI_STATE, including user and liveRoom when available.
fetchRoomGiftsFromProviderfetchRoomGiftsFromEulerRouteOptional roomId, webcastLanguage, optionsProvider gift response envelope.
fetchRoomGiftGalleryFromProviderfetchRoomGiftGalleryFromEulerRouteuniqueId, optional optionsProvider creator gift-gallery response.
fetchRoomIdFromProviderfetchRoomIdFromEulerRouteuniqueId, optional optionsProvider room-ID/status response.
fetchRoomInfoFromProviderfetchRoomInfoFromEulerRouteuniqueId, optional optionsProvider room-info response.
fetchSignedWebSocketFromProviderfetchSignedWebSocketFromEulerRouteroomId, session/platform options, optional cursor, country, optionsDecoded fetchResult, cookie header, and optional replacement room ID.
fetchWebcastSignatureFromProviderfetchWebcastSignatureFromEulerRouteurl, method, userAgent, optional optionsProvider signed-URL response.
sendRoomChatFromProvidersendRoomChatFromEulerRoutecontent, roomId, optional optionsProvider send-chat response.
fetchRoomIdCompositefetchRoomIdCompositeuniqueIdRoom ID string.
fetchIsLiveCompositefetchIsLiveCompositeuniqueIdLive-status boolean.

The generated API reference provides the exact parameter and response types for each function. Provider response envelopes are not interchangeable with the arrays returned by the base TikTok routes.

import { RouteConfig, TikTokLiveConnection } from 'tiktok-live-connector';
const connection = new TikTokLiveConnection('creator_username', {});
const result = await RouteConfig.fetchRoomInfoFromHtml({
webClient: connection.webClient,
uniqueId: connection.uniqueId,
});
console.log(result.liveRoom);

The registry is process-wide. Preserve the original function before replacing it, and restore it after a temporary override or test:

import { RouteConfig } from 'tiktok-live-connector';
const original = RouteConfig.fetchSignedWebSocketFromProvider;
RouteConfig.fetchSignedWebSocketFromProvider = async (args) => {
const result = await original(args);
// Apply application-specific observation or caching here.
return result;
};

The high-level connection uses registry entries for its main operations. However, the two composite lookup functions call their imported source handlers directly in this checkout. Overriding RouteConfig.fetchRoomInfoFromHtml, for example, does not change the HTML call inside a composite lookup. Override the composite registry entry itself when you need to replace that behavior.

RoomIdRouteConfig and IsLiveRouteConfig each expose:

  • skipFetchRoomInfoFromHtmlRoute
  • skipFetchRoomInfoFromApiLiveRoute
  • skipFetchRoomIdFromEulerRoute

All default to false. Each composite tries its enabled sources in order: HTML, TikTok API-live, then Euler Stream. Live status treats a valid TikTok status other than 4 as online. If all enabled sources fail, the composite throws InvalidResponseCompositeError with config.requestErrs.

createRoute(routeId, handler) adds the route ID to the handler’s arguments. It does not add retries, caching, response validation, or error translation on its own. HttpRoute and WrappedHttpRoute describe the unwrapped and wrapped signatures.

BaseFetchRoute, EulerFetchRoute, and CompositeFetchRoute enumerate route IDs used in errors. EulerRouteRequestOptions is the loose request-options shape forwarded by the provider handlers to their SDK calls.