tencent cloud

Tencent Cloud Super App as a Service

Release Notes and Announcements
Announcement: Tencent Cloud Mini Program Platform Renamed to Tencent Cloud Super App as a Service on January 2, 2025
Console Updates
Android SDK Updates
iOS SDK Updates
Flutter SDK Updates
IDE Updates
Base Library Updates
Product Introduction
Overview
Strengths
Use Cases
Purchase Guide
Billing Overview
Pay-As-You-Go Billing
Renewal Guide
Service Suspension Instructions
Getting Started
Plan Management
Overview
Console Account Management
Storage Configuration
Acceleration Configuration
Branding Configurations
Platform Features
Console Login
Users and Permission System
Mini Program Management
Mini Game Management
Superapp Management
Commercialization
Platform Management
User Management
Team Management
Operations Management
Security Center
Code Integration Guide
Getting Demo and SDK
Android
iOS
Flutter
Superapp Server
GUID Generation Rules
Mini Program Development Guide
Mini Program Introduction and Development Environment
Mini Program Code Composition
Guide
Framework
Components
API
Server Backend
JS SDK
Base Library
IDE Operation Instructions
Mini Game Development Guide
Guide
API
Server Backend
Practice Tutorial
Mini Program Login Practical Tutorial
Mini Program Subscription Message Practical Tutorial
Payment Practical Tutorial
Ad Integration Practical Tutorial
Mini Game Subscription Message Practical Tutorial
API Documentation
History
Introduction
API Category
Making API Requests
Operation Management APIs
User Management APIs
Team Management APIs
Sensitive API-Related APIs
Role Management APIs
Platform Management APIs
Other Console APIs
Mini Program or Mini Game APIs
Management-Sensitive APIs
Global Domain Management APIs
Superapp APIs
Data Types
Agreements
Service Level Agreement
Data Processing and Security Agreement
SDK Privacy Policy Module
SDK Data Processing and Security Agreement Module

Initiate request

PDF
Focus Mode
Font Size
Last updated: 2026-03-20 18:44:06

request

This API is called using RequestTask  wx.request(Object object).
Feature description:Initiates an HTTPS network request. Before using this API, please carefully read Network.
Parameter and description:Object object.
Property
Type
Default value
‍Required
Description
url
string
-
True
The URL of the developer's server API
data
string/object/ArrayBuffer
-
False
Request parameter.
header
Object
-
False
Sets the request header. Referer cannot be set in the header. The default content-type is application/json
timeout
number
-
False
Timeout duration in milliseconds.
certs
Array<string>
-
False
When certificate pinning is enabled, this value is passed in. During the request, the system will verify whether the currently provided value matches the actual public key content of the corresponding domain. For example: ["sha256/FNIJxtRaQACmXyIS+CABwt/8Sc1ffjF5zI3sgKOLusc="]
method
string
GET
False
HTTP request method.
dataType
string
json
False
The format of the returned data.
responseType
string
text
False
The type of the response data.
success
function
-
False
Callback function for successful API calls.
fail
function
-
False
Callback function for failed API calls.
complete
function
-
False
Callback function executed after API call ends (regardless of success or failure).
Valid values for object.method:
Value
Description
OPTIONS
HTTP OPTIONS request
GET
HTTP GET request
HEAD
HTTP HEAD request
POST
HTTP POST request
PUT
HTTP PUT request
DELETE
HTTP DELETE request
TRACE
HTTP TRACE request
CONNECT
HTTP CONNECT request
Valid values for object.dataType:
Value
Description
json
The returned data is in JSON format and will be parsed once using JSON.parse.
Others
The returned data will not be parsed using JSON.parse
Valid values for object.responseType
Value
Description
text
The response data is text.
arraybuffer
The response data is an ArrayBuffer.
object.success callback function
Parameter: Object res.
Property
Type
Description
data
string/Object/Arraybuffer
The data returned by the developer server.
statusCode
number
The HTTP status code returned by the developer server.
header
Object
The HTTP response header returned by the developer server.
cookies
Array.<string>
The cookies returned by the developer server in the format of string array (not supported in mini games).
object.fail callback function
Parameter: Object err
Property
Type
Description
errMsg
String
Error message.
Return value:RequestTask. Request task object.
Description of the data parameter:
The data ultimately sent to the server is of type String. If the passed data is not of type String, it will be converted to String. The conversion rules are as follows:
For GET method data, it will be converted to a query string (encodeURIComponent(k)=encodeURIComponent(v)&encodeURIComponent(k)=encodeURIComponent(v)...)
For POST method data with header['content-type'] as application/json, it will be serialized into JSON.
For POST method data with header['content-type'] as application/x-www-form-urlencoded , it will be converted into a query string (encodeURIComponent(k)=encodeURIComponent(v)&encodeURIComponent(k)=encodeURIComponent(v)...)
Example:
wx.request({
url: 'test.php', // Example URL, not a real interface address
data: {
x: '',
y: ''
},
header: {
'content-type': 'application/json' // Default value
},
success(res) {
console.log(res.data)
}
})

RequestTask

.abort

This method is called using RequestTask.abort().
Feature description:Aborts a request task.

.onChunkReceived

This method is called using RequestTask.onChunkReceived(function listener).
Note:
This API is supported in mini programs but not in mini games.
Feature description:Listens for the Transfer-Encoding Chunk Received event. It is triggered when a new chunk is received.
Parameter and description:function listener. The listener for the Transfer-Encoding Chunk Received event. Parameter: Object res.
Property
Type
Description
res
Object
The response for each new chunk received from the developer's server.
res structure property
Structural property
Type
Description
data
ArrayBuffer
The returned chunk buffer.

.offChunkReceived

This method is called using RequestTask.offChunkReceived(function listener).
Note:
This API is supported in mini programs but not in mini games.
Feature description:Removes the listener for the Transfer-Encoding Chunk Received event.
Parameter and description:function listener. The listener passed to onChunkReceived. If this parameter is not provided, all listeners will be removed.
Example
const listener = function (res) { console.log(res) }

RequestTask.onChunkReceived(listener)
RequestTask.offChunkReceived(listener) // Must pass the same function object used in onChunkReceived

.onHeadersReceived

This method is called using RequestTask.onHeadersReceived(function listener).
Feature description:Listens for the HTTP Response Header event. The event is triggered before the response is received.
Parameter and description:function listener. The listener for the HTTP Response Header event.
Property
Type
Description
header
Object
The HTTP response header returned by the developer server.
statusCode
Number
The HTTP status code returned by the developer's server (currently not returned in the developer tools, but can be viewed on a real device)
cookies
Array.<string>
The cookies returned by the developer server in the format of string array.

.offHeadersReceived

This method is called using RequestTask.offHeadersReceived(function listener).
Feature description:Removes the listener for the HTTP Response Header event.
Parameter and description:function listener. The listener function passed to onHeadersReceived. If this parameter is not provided, all listeners will be removed.
Example:
const listener = function (res) { console.log(res) }

RequestTask.onHeadersReceived(listener)
RequestTask.offHeadersReceived(listener) // Must pass the same function object used in onHeadersReceived

Explanation of certificate generation rules


# Rule: sha256/{base64 value of the certificate public key hash}
echo "sha256/$(echo "Certificate public key's hash" | xxd -r -p | base64 | tr -d '\\n')";

# How to obtain the certificate public key hash?
openssl x509 -in [The server domain name corresponds].crt -pubkey -noout | openssl pkey -pubin -outform der | openssl dgst -sha256 -hex
Certificate verification frequency varies across platforms. Developers should be aware of the following:
iOS: During the current app session, once a certificate for any domain has been verified successfully, subsequent requests to that domain will not trigger re-verification.
Android: Certificate verification is performed on every request, with no caching to skip verification.




Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback