TikTok for Developers

Developer Docs

Last updated October 5, 2026

Network

Send HTTPS requests and monitor network type and connectivity changes. Check the corresponding CanIUse property before calling network APIs.

TT.Request(url, options, success, fail)

Sends an HTTPS request.

Signature

public static int Request(
    string url,
    TTRequest.InnerOptions options,
    Action<TTRequest.Response> success,
    Action<TTRequest.Response> fail)

Parameters and return value

Parameter

Type

Description

url

string

HTTPS request URL that meets the platform request-domain requirements.

options.UseTTNet

bool

Whether to use TTNet.

options.UseCloud

bool

Whether to use the cloud request path.

success / fail

Action<TTRequest.Response>

Success and failure callbacks.

Return value

int

Task identifier for this request.

Response

Field

Type

Description

Header

Dictionary<string, string>

Response headers.

StatusCode

int

HTTP status code.

Data

string

Response body.

ErrMsg

string

Failure message.

IsPrefetch

bool

Whether the result came from prefetch.

PrefetchDetail

int

Additional prefetch status.

Example

int requestId = TT.Request(
    "https://api.example.com/player",
    new TTRequest.InnerOptions { UseTTNet = true, UseCloud = false },
    response => Debug.Log($"HTTP {response.StatusCode}: {response.Data}"),
    response => Debug.LogError($"Request failed: {response.ErrMsg}")
);

Do not copy the JSSDK request parameter object into C#. The 1.1.6-Beta public C# signature accepts only the parameters above.

TT.GetNetWorkType(param)

Queries the current network type.

Signature

public static void GetNetWorkType(GetNetworkTypeParam param)

Parameters and result

Field

Type

Description

Success

GetNetworkTypeSuccessCallback

Success callback. NetworkType in the result is the current network type.

Fail

Action<ErrorInfo>

Failure callback.

NetWorkType can be NetworkWifi, Network2G, Network3G, Network4G, None, or Unknown.

Example

TT.GetNetWorkType(new GetNetworkTypeParam
{
    Success = result => Debug.Log($"Network: {result.NetworkType}"),
    Fail = error => Debug.LogError(error.ErrMsg)
});

TT.OnNetworkStatusChange(callback)

Registers a listener for network status changes.

Signature

public static void OnNetworkStatusChange(OnNetworkStatusChangeCallback callback)

The callback result contains bool IsConnected and NetWorkType NetworkType.

Example

OnNetworkStatusChangeCallback networkListener = result =>
    Debug.Log($"Connected: {result.IsConnected}, Type: {result.NetworkType}");

TT.OnNetworkStatusChange(networkListener);

TT.OffNetworkStatusChange(callback)

Removes a network status change listener.

Signature

public static void OffNetworkStatusChange(OnNetworkStatusChangeCallback callback)

Example

TT.OffNetworkStatusChange(networkListener);

TT.OnNetworkWeakChange(callback)

Registers a listener for weak network changes.

Signature

public static void OnNetworkWeakChange(OnNetworkWeakChangeCallback callback)

The callback result contains bool WeakNet and NetWorkType NetworkType.

Example

OnNetworkWeakChangeCallback weakListener = result =>
    Debug.Log($"Weak network: {result.WeakNet}, Type: {result.NetworkType}");

TT.OnNetworkWeakChange(weakListener);

TT.OffNetworkWeakChange(callback)

Removes a weak network change listener.

Signature

public static void OffNetworkWeakChange(OnNetworkWeakChangeCallback callback)

Example

TT.OffNetworkWeakChange(weakListener);
TikTok for Developers