Skip to main content

Server Intergration

1 SDK Integration​

Please refer to [Android/iOS/PC] Host Runtime SDK Documentation - Quick Start

2 Platform Server Integration​

2.1 Channel API​

For third-party game platforms, Minihost provides Channel API access capabilities to centrally manage game content and game packages hosted on Minihost.

2.1.1 Access Instructions​

Before performing API integration, the platform party needs to obtain the corresponding Channel AccessToken as the secret access key for API access.

If the Channel AccessToken is leaked, please contact us immediately for reset.

The API usage rules for the production environment are as follows:

METHOD PATH HTTP/1.1
Host: minihost.tuanjie.cn
Authorization: Bearer <Channel AccessToken>

Both the request body and response body are in JSON format by default.

When the returned status code is greater than 400, it is considered an interface error, and error handling should be performed through the following response body:

{
"errorCode": "example error", // Used for error type inference
"message": "example message", // Error message (English)
"target": "example" // Field/Object name in error
}
2.1.1.1 Game Management​

After developers choose to submit games to the corresponding platform on Minihost, the platform can use the following APIs to provide corresponding game management capabilities on its own platform.

Backend side:

  1. Get Game List Get a list of all games related to the platform party.

  2. Get Game Information

  3. Edit Game Information After the game is launched on the platform, developers can no longer update game information on the Minihost interface. The platform should call this API at an appropriate time (e.g., after content moderation is approved) to ensure that the Minihost can display correct game information and perform calls that require platform participation, such as payments, during actual operation.

  4. Take Down Games This API can be called when the platform terminates the contract with the developer and needs to unlink the game.

Developer side:

  1. Publish Games When a game developer performs the operation of going live with a game package on the platform, the platform needs to call this API to inform Minihost of the game package ID required for the online version of the game.
2.1.1.1.1 Channel Associate Games​

When the channel party associates a game, it requires the developer to provide the associateKey for game association

  1. The channel party retrieves game information based on the associateKey
GET /api/channel/v1/game_app/associate/:associateKey/info
Parameter TypeValue TypeRequiredInstructions
associateKeypathstringYesTemporary key generated during game association

Response Body Description

{
"id": "string", // gameId
"launchKey": "string", // launchKey
"orgId": "string", // game's organization
"name": "string", // game name
"briefIntro": "string", // game breif introduction
"iconUrl": "string", // game icon
"tags": [ // tags
"string"
],
"createdTime": "createdTime",
"updatedTime": "updatedTime",
}
  • Notify the association after the channel is successfully associated with the game
POST /api/channel/v1/game_app/associate/:associateKey/success

Input Parameter Description

Parameter TypeValue TypeRequiredInstructions
associateKeypathstringYesTemporary key generated during game association

Request Body Description

{
"gameId": "string",
"channelGameId": "string",
}

Response Body Description

{
"id": "string", // gameId
"launchKey": "string", // launchKey
"orgId": "string", // game's organization
"name": "string", // game name
"briefIntro": "string", // game breif introduction
"iconUrl": "string", // game icon
"tags": [ // tags
"string"
],
"createdTime": "createdTime",
"updatedTime": "updatedTime",
}
2.1.1.1.2 Get Game List​
GET /api/channel/v1/game_app_list

Input Parameter Description

Parameter TypeValue TypeRequiredInstructions
pagequeryintNoPage number, starting and default value is 1
pageSizequeryintNoPage size, default value is 100
orderByquerystringNoSorting, you can choose createdTime or updatedTime for sorting
orderquerystringNoOrder, asc or desc

Response Body Description

{
"items": [
{
"id": "string", // gameId
"launchKey": "string", // launchKey
"orgId": "string", // game's organization
"name": "string", // game name
"briefIntro": "string", // game breif introduction
"iconUrl": "string", // game icon
"latestBundleId": "string", // published game package
"tags": [ // tags
"string"
],
"createdTime": "createdTime",
"updatedTime": "updatedTime",
}
],
"total": 0
}
2.1.1.1.3 Get Game Information​
GET /api/channel/v1/game_app/:id/info

Input Parameter Description

Parameter TypeValue TypeRequiredInstructions
idpathstringYesID corresponding to the game to be accessed

Response Body Description

{
"id": "string", // gameId
"launchKey": "string", // launchKey
"orgId": "string", // game's organization
"name": "string", // game name
"briefIntro": "string", // game breif introduction
"iconUrl": "string", // game icon
"latestBundleId": "string", // published game package
"tags": [ // tags
"string"
],
"createdTime": "createdTime",
"updatedTime": "updatedTime",
}
2.1.1.1.4 Edit Game Information​
PUT /api/channel/v1/game_app/:id/info

Input Parameter Description

Parameter TypeValue TypeRequiredInstructions
idpathstringYesID corresponding to the game to be accessed

Request Body Description

{
"name": "game name",
"iconUrl": "https://example.cdn.com/example.png", // publicly accessible icon URL
"briefIntro": "game brief introduction",
}

Provide the fields that need to be updated for the update (e.g., if you do not intend to update the name field, then this field should not exist in the JSON).

Response Body Description

{
"id": "string", // gameId
"launchKey": "string", // launchKey
"orgId": "string", // game's organization
"name": "string", // game name
"briefIntro": "string", // game breif introduction
"iconUrl": "string", // game icon
"latestBundleId": "string", // published game package
"tags": [ // tags
"string"
],
"createdTime": "createdTime",
"updatedTime": "updatedTime",
}
2.1.1.1.5 Publish Games​
POST /api/channel/v1/game_app/:id/publish

Input Parameter Description

Parameter TypeValue TypeRequiredInstructions
idpathstringYesID corresponding to the game to be accessed

Request Body Description

{
"bundleId": "example_id"
}

Response Body Description

{
"id": "string", // gameId
"launchKey": "string", // launchKey
"orgId": "string", // game's organization
"name": "string", // game name
"briefIntro": "string", // game breif introduction
"iconUrl": "string", // game icon
"latestBundleId": "string", // published game package
"tags": [ // tags
"string"
],
"createdTime": "createdTime",
"updatedTime": "updatedTime",
}
2.1.1.1.6 Take down Games​
DELETE /api/channel/v1/game_app/:id

Input Parameter Description

Parameter TypeValue TypeRequiredInstructions
idpathstringYesID corresponding to the game to be accessed

Response Body Description

After successful delisting, "OK" will be returned

2.1.1.2 Game Package Management​

After developers choose to submit the game package to the platform in Minihost (they need to associate the game with the platform Channel first), the platform can use the following APIs to provide corresponding game package management capabilities on its own platform.

Backend side:

  1. Get Game Package ListThis API can be used to view all submitted game packages, and the review list can be implemented by filtering the review status.

  2. Obtain Temporary Session for Game Package provides the function of reviewing and trial-playing games. The access link of the temporary session can be made into a QR code, which can be scanned using the platform's APP for review and trial play.

  3. Update Game Package Review Information records the final review results of the game package and supports revocation.

Developer side:

  1. Get Game Package List This API carries the gameId parameter, allowing developers to view the review status of game packages for the corresponding game on the platform and use Publish Games to launch versions that have passed review.
2.1.1.2.1 Get Game Package List​
GET /api/channel/v1/game_bundle_list

Input Parameter Description

Parameter TypeValue TypeRequiredInstructions
pagequeryintNoPage number, starting and default value is 1
pageSizequeryintNoPage size, default value is 100
gameIdquerystringNoID of the game to which the game package belongs
auditStatusquerystringNoGame Package Review Status
publishStatusquerystringNoGame package online status
orderByquerystringNoSorting, you can choose createdTime or updatedTime for sorting
orderquerystringNoOrder, asc or desc

Explanation of Game Package Review Status

StatusInstructions
pendingInitial state after successful game package upload
reviewingStatus after the game package starts review
acceptedStatus after the game package passes the review
deniedStatus after the game package fails the review
cancelledStatus after the game package is cancelled for review

Game package online status

StatusInstructions
onlineStatus of the game package after going live
offlineHistorical released versions of the game package

Response Body Description

{
"items": [
{
"id": "string", // bundleId
"gameId": "string", // gameId
"auditStatus": "pending", // game package audit status
"publishStatus": "online", // game package release status
"description": "string", // description
"version": "string", // version
"createdTime": "createdTime",
"updatedTime": "updatedTime",
}
],
"total": 0
}
2.1.1.2.2 Obtain Temporary Session for Game Package​
POST /api/channel/v1/game_bundle/:id/temp_session

Input Parameter Description

Parameter TypeValue TypeRequiredInstructions
idpathstringYesID corresponding to the game package to be accessed

Response Body Description

{
"url": "https://minihost.tuanjie.cn/api/game_app/example_id/temp_session/example_session_id/start", // 临时会话的访问 URL,制成二维码后可以使用宿主扫码
"expiresIn": 180 // temporary session expires in (seconds)
}
2.1.1.2.3 Update game package review information​
PUT /api/channel/v1/game_bundle/:id/audit_info

Input Parameter Description

Parameter TypeValue TypeRequiredInstructions
idpathstringYesID corresponding to the game package to be accessed

Request Body Description

{
"auditStatus": "accepted" // one of reviewing/accepted/denied/cancelled
}

Response Body Description

{
"id": "string", // bundleId
"gameId": "string", // gameId
"auditStatus": "pending", // game package audit status
"publishStatus": "online", // game package release status
"description": "string", // description
"version": "string", // version
"createdTime": "createdTime",
"updatedTime": "updatedTime",
}
2.1.1.3 Game Package Upload and Push​

After the developer associates the game with the channel provider, once the game package is successfully uploaded, it will be automatically pushed to the channel provider, and the channel provider needs to provide an interface to receive the push.

Request Body Description

{
"id": "string", // bundleId
"gameId": "string", // gameId
"auditStatus": "pending", // game package audit status
"publishStatus": "online", // game package release status
"description": "string", // description
"version": "string", // version
"createdTime": "createdTime",
"updatedTime": "updatedTime",
}

Response Body Description

{
"code": 200,
"message": "success"
}

2.2 Server Token Integration Specification​

2.2.1 Using Token to Retrieve Mini Game List​

Platform parties can use server tokens to retrieve the list of mini games from the host application.

Request Example:

GET /api/game/list?appId={appId} HTTP/1.1
Host: minihost.tuanjie.cn
Authorization: Bearer {service_token}

Request Parameter Description:

ParameterDescription
appIdHost Application ID
AuthorizationServer token in the format Bearer {service_token}

Response Example:

HTTP/1.1 200 OK
Content-Type: application/json
[
{
"id": "67b*********************",
"appId": "67b*********************",
"name": "Game Name",
"briefIntro": "Brief Introduction",
"gameType": "weixinminigame",
"iconUrl": "https://minihost.cdn.tuanjie.cn/game_app/67b6eb506ffcda2559ecd19d/app_icon/********.png",
"launchKey": "67b*********************",
}
]

Response Field Description:

FieldDescription
idGame ID
appIdHost Application ID
nameGame Name
briefIntroGame Brief Intro
gameTypeGame Type
iconUrlGame Icon URL
launchKeyValue returned is Game ID
For usage of launchKey, please refer to Game Launch Parameters

2.2.2 Server API Access Specification​

note

This access specification is the implementation specification for platform party APIs. If you are a game-side developer, please refer to Mini Game API for integration.

2.2.2.1 ping​

Used to test network connectivity between the host backend and the platform party. Only after successful connectivity verification can the URL be configured in the host backend. Request Example:

GET /ping HTTP/1.1

Response Example:

HTTP/1.1 200 OK
Content-Type: text/plain
pong
2.2.2.2 jscode2session​

Provides the login capability of the platform party. The host backend will pass the user's login credential (code) to the platform party, which needs to return the user's login information based on this credential. The host backend will map the uid returned by the platform party to openid and unionid available on the game side based on the request context, and forward the session_key to the game side as a login credential. Request Example:

GET /jscode2session?js_code={code} HTTP/1.1
Authorization: Bearer {service_token}

Request Parameter Description:

ParameterDescription
js_codePlatform party login credential
AuthorizationServer token in the format Bearer {service_token}
Response Example:
HTTP/1.1 200 OK
Content-Type: application/json
{
"uid": "123456"
"session_key": "abcdefg",
"errcode": 0,
"errmsg": "ok"
}

Response Field Description:

FieldDescription
uidUnique user identifier returned by platform
session_keySession_key returned by platform
errcodeError code, 0 indicates success
errmsgError message

2.2.3 Payment Signature Verification​

The platform uses SHA1 method to encrypt and verify parameters

2.2.3.1 Signature Rules​
  1. Parameters are case-sensitive
  2. Multiple parameters are concatenated using '&' as separator
  3. Parameters with null or empty string ("") values do not participate in signing
  4. The signature parameter (sign) itself does not participate in signing
  5. Parameter signing order follows ASCII code from smallest to largest
  6. After concatenating all business parameters in order, append the secret parameter at the end
  7. Signature value: Perform SHA1 encryption on the concatenated string, extract the last 32 characters, and convert to uppercase
Sample Parameters for Signing​
{
"amount": 1,
"appId": "692ee200dc0f40766a42504f",
"count": 1,
"couponDeductAmount": 0,
"cpOrderId": "27308454202512031028289635",
"currency": "CNY",
"extra": "{\"orderId\":\"27308454202512031028289635\",\"userId\":\"693003df1cf21a89eacc8366\"}",
"nonce": "20251203183012fd2948",
"productCode": "1001",
"productName": "Product For Demo",
"productPrice": 1,
"tradeNo": "20251203182830033010000117646468"
}
Sample Signature String​
amount=1&appId=692ee200dc0f40766a42504f&count=1&couponDeductAmount=0&cpOrderId=27308454202512031028289635&currency=CNY&extra={"orderId":"27308454202512031028289635","userId":"693003df1cf21a89eacc8366"}&nonce=20251203183012fd2948&productCode=1001&productName=Product For Demo&productPrice=1&tradeNo=20251203182830033010000117646468&secret=Qaf2xQ56XnLUw5bgelfvPAbQnn8
Final Signature Value​
69D48E7D9AF3EB7680570894B6D07845
2.2.3.2 Payment Notification API​

Platform Payment Process

POST /game-api/v2/payment/callback
Host: minihost.tuanjie.cn
Authorization: Bearer {service_token}

Request Parameter Description:

ParameterDescription
AuthorizationServer token in the format Bearer {service_token}
Request Body Description​
{
"appId": "appId", // Game ID
"tradeNo": "tradeNo", // Transaction Number
"cpOrderId": "cpOrderId", // Mini Game Order Number
"amount": 1, // Payment Amount
"count": 1, // Product Quantity
"currency": "currency", // Currency Type
"productCode": "productCode", // Product Code
"productName": "productName", // Product Name
"productPrice": 1, // Product Price
"couponDeductAmount": 0, // Coupon Deduction Amount
"extra": "extra", // Additional Information
"nonce": "nonce", // Random String
"sign": "sign" // Signature Information, refer to above signature rules
}
Response Body Description​
{
"code": 200, // Response Status Code
"message": "message" // Status Code Description
}

Code Response Code Description

Status CodeDescription
200Business processing successful, delivery successful
22100Data signature incorrect
22101Interface parameter validation failed
22102Order failed (e.g., due to out of stock, product delisting, etc., clearly indicating that the order cannot be executed)
22103Unknown business error
2.2.3.3 Refund Notification API​
POST /game-api/v2/payment/callback/refund
Host: minihost.tuanjie.cn
Authorization: Bearer {service_token}

Request Parameter Description:

ParameterDescription
AuthorizationServer token in the format Bearer {service_token}
Request Body Description
{
"appId": "appId", // Game ID
"tradeNo": "tradeNo", // Transaction Number
"cpOrderId": "cpOrderId", // Mini Game Order Number
"refundNo": "refundNo", // Refund Number
"refundAmount": 1, // Refund Amount
"nonce": "nonce", // Random String
"sign": "sign" // Signature Information, refer to above signature rules
}

Response Body Description

{
"code": 200, // Response Status Code
"message": "message" // Status Code Description
}

Code Response Code Description

Status CodeDescription
200Business processing successful, refund processed successfully
22100Data signature incorrect
22101Interface parameter validation failed
22103Unknown business error

2.3 Login API​

2.3.1 Login Process Overview​

In the above diagram, the API that needs to be integrated by the platform is the code2session in Step 10.

2.3.2 Platform Code2Session​

Provides the login capability of the platform. The host backend will pass the user's login credential (code) to the platform, which needs to return the user's login information based on this credential.

The host backend will map the uid returned by the platform to the openid and unionid available on the game side, based on the context of the request, and forward the session_key to the game side as a login credential.

Example of request:

GET /jscode2session?js_code={code} HTTP/1.1
Authorization: Bearer {service_token}

Request Parameter Description:

parameterDescription
js_codePlatform Login Credentials
AuthorizationServer token, formatted as Bearer {service_token}

Response Example:

HTTP/1.1 200 OK
Content-Type: application/json

{
"uid": "123456"
"session_key": "abcdefg",
"errcode": 0,
"errmsg": "ok"
}

Response field description:

FieldDescription
uidUnique user identifier returned by the platform
session_keysession_key returned by the platform
errcodeError code, 0 indicates success
errmsgError Message

2.4 Payment API​

2.4.1 Payment Process Overview​

2.4.1.1 Minigame Payment​

2.4.1.2 Game Servers Actively Query Order​

2.4.2 Platform API in Minigame Payment​

After the payment is successful, the platform server sends a payment success callback to the host server. After verifying the signature, the host server sends the callback to the game server. Align with Step 6 in the diagram above.

2.4.2.1 Callback Address​

POST https://minihost.tuanjie.cn/game-api/v1/payment/callback

2.4.2.2 Request Parameters​
Parameter NameTypeDescription
timestampstringTimestamp
noncestringRandom Number
msgstringPayment result information of Json string type, see 2.4.2.3 PaymentInfo object
signaturestringSignature, see Section 2.4.2.4 Signature for the signature algorithm
2.4.2.3 PaymentInfo​
Parameter NameTypeDescription
appidstringPlatform-side minigame appid
cp_ordernostringDeveloper-defined order number, the customId parameter in the tj.requestPayment method
cp_extrastringExtra parameters passed by the developer, the extra parameter in the tj.requestPayment method
order_no_channelstringMinigame Backend Transaction Order Number
amount_centint64Order amount, in RMB cents
amount_coinint64The quantity of game coins purchased is not involved in the platform's integration process and can be ignored.
currencystringPayment currency, CNY Renminbi, DIAMOND Diamond
2.4.2.4 Signature​

Generate a signature using the SHA1 algorithm based on token, timestamp, nonce, and msg, and compare it with the signature returned by the platform's server.

Precondition: When associating a game, the platform party needs to pass token to the host for signature verification

Sample Golang code:

sortedString := make([]string, 4)
sortedString = append(sortedString, token)
sortedString = append(sortedString, timestamp)
sortedString = append(sortedString, nonce)
sortedString = append(sortedString, string(msg))
sort.Strings(sortedString)h := sha1.New()
h.Write([]byte(strings.Join(sortedString, "")))_signature := h.Sum(nil)
2.4.2.5 Response​

The host server returns a 200 status code as a successful response. If the returned HTTP status code is not 200, it indicates that the notification has failed and a retry is required.

2.4.3 Platform API in Game Servers Actively Query Order​

Server-side payment callbacks may fail to reach 100% due to reasons such as network anomalies. Developers can use this interface to actively check the order status to prevent over-delivery or under-delivery. Developers send a query order request to the host server, which then encapsulates and sends the query order request to the platform server. Align with Step 3 in the diagram above.

2.4.3.1 Interface Address​

Provided by the platform

2.4.3.2 Request Parameters​
Parameter NameTypeDescription
tokenstringThe two parties agree on the server token
ordernostringcp Custom Order Number, passed in when placing an order, the customId parameter in the tj.requestPayment method
2.4.3.3 Response​
Parameter NameTypeDescription
statusstringPayment status. "success" indicates successful payment and coin arrival, "unsuccess" indicates payment failure
2.4.3.4 Authentication​

The request must include the server token agreed upon by both parties, placed in the Authorization header, with a format like

Bearer {service_token}