Skip to content

Matchmaking API

Pre-requisites

To use the matchmaking API, you need to prepare the following items.

  • Authentication token for API calls (Certification Key): Hive Console App Center > Manage Project > Select your game from the game list > Game Details > Basic Information > Certification Key
  • Game index (gameIndex): Hive Console App Center > Manage Project > Select your game from the game list > Game Details > Basic Information > Game Index
  • Match ID (matchId): You can check this when creating a match in the Hive Console.

Request URL root

Server URL
LIVE api-match.withhive.com
SANDBOX sandbox-api-match.withhive.com

Common response codes

These are the common API response codes.

Code Value Description
200 Success Refer to each API response
400 Bad Request Incorrect request parameters or request body input
401 Unauthorized The authorization header in the request message is missing or invalid
403 Forbidden The authentication token (Certification Key) for the API call is invalid
404 Not Found Incorrect API path
500 Internal Server Error An internal server error occurred

Request match

Call this API when each user requests a match. The match corresponding to matchId must be pre-created in the Hive Console.

Request URL

LIVE URL https://api-match.withhive.com/gameindexes/{gameIndex}/matchmakings/{matchId}/players
SANDBOX URL https://sandbox-api-match.withhive.com/gameindexes/{gameIndex}/matchmakings/{matchId}/players
HTTP METHOD POST
CONTENT-TYPE application/json

Header parameters

Field Name Description Type Required
Authorization Authentication token for API calls (Bearer) string Y

Path parameters

Field Name Description Type Required
gameIndex Project identifier available in the Hive Console App Center int Y
matchId Each match identifier created in the Hive Console int Y

Request body

Field Name Description Type Required
playerId Account identifier long Y
point Score to be used for the match. The input range is 0 ~ 999,999,999. If not entered, `0` will be used. integer N
extraData Additional account information (nickname, level, country, etc.). Up to 256 characters can be entered. It is included in the match result. string N

Response

Field Name Description
playerId Account identifier
matchInfo Request target information
  • gameIndex: gameIndex value
  • matchId: matchId value
requestingStatus Request status information
  • requested: Match requested successfully
  • notRequested: Match was not requested, or the match is already completed so there is no ongoing request for match
requestingInfo Request information
  • requestTimeUtc: Request time in UTC+0
  • point: point entered at the time of request
  • extraData: extraData entered at the time of request
matchingInfo Match status information (status)
  • matchingInProgress: Match in progress
  • timeout: Match did not made within the time limit
  • matched: Match completed

Request sample

curl --location 'https://sandbox-api-match.withhive.com/gameindexes/1/matchmakings/1/request' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJIaXZlIiwiaWF0IjoxNzAyNDU4MTkzLCJqdGkiOiIxMzY2NDk4MjcxIn0.VSwvsTE-tS0sL_e9p9gNvHRkMCbsycSO4ObE4J2ya3a' \
--data '{
   "playerId":100,
   "point": 1000
}'

Response sample

{
   "playerId": 100,
   "matchInfo": {
       "gameIndex": 1,
       "matchId": 1
   },
   "requestingStatus": "requested",
   "requestingInfo": {
       "requestTimeUtc": "2024-06-05T05:09:28.72",
       "point": 1000
   },
   "matchingInfo": {
       "status": "matchingInProgress"
   }
}

Check match status

Check the status of the requested match.

Request URL

LIVE URL https://api-match.withhive.com/gameindexes/{gameIndex}/matchmakings/{matchId}/players
SANDBOX URL https://sandbox-api-match.withhive.com/gameindexes/{gameIndex}/matchmakings/{matchId}/players
HTTP METHOD GET

Header parameters

Field Name Description Type Required
Authorization Authentication token for API call (Bearer) string Y

Path parameters

Field Name Description Type Required
gameIndex Project identifier available in Hive Console App Center int Y
matchId Identifier for each match generated in the Hive Console int Y

Query parameters

Field Name Description Type Required
id User ID (`playerId`) long Y

Response

Field Name Description
playerId Account identifier
matchInfo Requested information
  • gameIndex: gameIndex value
  • matchId: matchId value
requestingStatus Request status information
  • requested: Match requested successfully
  • notRequested: Match was not requested, or the match is already completed so there is no ongoing request for match
requestingInfo Request information
  • requestTimeUtc: Request time in UTC+0
  • point: point entered at the time of request
  • extraData: extraData entered at the time of request
matchingInfo Match status information (status)
  • matchingInProgress: Match in progress
  • timeout: Match not completed within the time limit
  • matched: Match completed

Request sample

curl --location --request GET 'https://sandbox-api-match.withhive.com/gameindexes/1/matchmakings/1/players?id=100' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJIaXZlIiwiaWF0IjoxNzAyNDU4MTkzLCJqdGkiOiIxMzY2NDk4MjcxIn0.VSwvsTE-tS0sL_e9p9gNvHRkMCbsycSO4ObE4J2ya3a'

Response sample

The match status when you have not yet made a match request is as follows.

{
   "playerId": 100,
   "matchInfo": {
       "gameIndex": 1,
       "matchId": 1
   },
   "requestingStatus": "notRequested"
}


Request Match returns requested and matchingInProgress statuses when the match is still in progress.

{
   "playerId": 100,
   "matchInfo": {
       "gameIndex": 1,
       "matchId": 1
   },
   "requestingStatus": "requested",
   "requestingInfo": {
       "requestTimeUtc": "2024-06-05T05:09:28.72",
       "point": 1000
   },
   "matchingInfo": {
       "status": "matchingInProgress"
   }
}


When checking the request status after the match is completed, it returns matched or timeout results. This is the state where the match is completed but the match result callback has not yet been received.

    {
       "playerId": 100,
       "matchInfo": {
           "gameIndex": 1,
           "matchId": 1
       },
       "requestingStatus": "requested",
       "requestingInfo": {
           "requestTimeUtc": "2024-06-05T05:09:28.72",
           "point": 1000
       },
       "matchingInfo": {
           "status": "matched"
       }
   }


Once the match is completed, the Hive Server sends the match result callback to your server. If your server receives the match result callback, returns HTTPStatus 200 to the Hive Server, and if you check the match request status again, it will change to notRequested and the matchingInfo key will be deleted as shown below. This is because the Hive Server considers your match request is completed upon receiving HTTPStatus 200 in response to the callback and deletes the match request transaction.

{
   "playerId": 100,
   "matchInfo": {
       "gameIndex": 1,
       "matchId": 1
   },
   "requestingStatus": "notRequested"
}


Before Match Request After Match Request After Match Result Created After Callback Reception
requestingStatus notRequested requested requested notRequested
matchingInfo > Status N/A matchingInProgress matched or timeout N/A
Remarks match in progress before callback reception

Cancel match request

Cancel the match request. When you cancel the match request, the match request transaction will be deleted from the Hive Server.

If the match is completed after Request Match and you have received the Match Result Callback and responded with HTTPStatus 200, the Hive Server will consider the match completed and delete the match request transaction. In this state, even if you call to cancel the match request, as the match request transaction has already been deleted, the cancellation operation will not be executed and no exception will be returned.

Request URL

LIVE URL https://api-match.withhive.com/gameindexes/{gameIndex}/matchmakings/{matchId}/players/{playerId}
SANDBOX URL https://sandbox-api-match.withhive.com/gameindexes/{gameIndex}/matchmakings/{matchId}/players/{playerId}
HTTP METHOD DELETE

Header parameters

Field Name Description Type Required
Authorization Authentication token for API call (Bearer) string Y

Path parameters

Field Name Description Type Required
gameIndex Project identifier available in the Hive Console App Center int Y
matchId Identifier for each match created in the Hive Console int Y
playerId User ID long Y

Response

If it is 200 OK, the body is empty.

Request sample

curl --location --request DELETE 'https://sandbox-api-match.withhive.com/gameindexes/1/matchmakings/1/players/100' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJIaXZlIiwiaWF0IjoxNzAyNDU4MTkzLCJqdGkiOiIxMzY2NDk4MjcxIn0.VSwvsTE-tS0sL_e9p9gNvHRkMCbsycSO4ObE4J2ya3a'

Response sample

There is no specific response if the request is canceled normally.

Match result callback

When a match is completed, the Hive Server sends the match result to the your server as a callback. If your server received the match result callback without any issue, your server should respond with HttpStatus 200. By registering the desired server URL in the Hive Console, the match result will be sent to this address as a callback. The address must be a publicly accessible URL. The API information is as follows.

Callback reception URL (Hive Server → Your server)

When your server API endpoint is registered in the Hive Console, the Hive Server sends the callback result to this endpoint when the match is completed.

Header parameters

Field Name Description Type Required
X-Match-Signature The signature value of the encrypted body contents with the HMAC SHA-256 algorithm string Y

Values passed with the callback

Field Name Description Type
gameIndex The gameIndex value of the completed match int
matchId The matchId value of the completed match int
matchingInfos An array of information of the app users who are matched. Users with a `playerId` field value of `0` are considered bots.
  • matchingId: The match id
  • privateInfos: An array of information of users matched in a solo game (the same format as timeoutPlayerInfos)
  • teamInfos: An array of information of users matched in a team game (teamIndex: team number, playerInfos: An array of team members' information, the same format as timeoutPlayerInfos)
json
timeoutPlayerInfos An array of information of app users who were not matched and timed out
  • extraData: The extraData entered when the match was requested
  • point: The point entered when the match was requested
  • playerId: The playerId entered when the match was requested
json

Callback example (Hive Server → Your server)

curl --location 'The API endpoint of your server registered in the Hive Console.' --header 'Content-Type: application/json' --header 'X-Match-Signature: nj2YlgGTlLXcAhrl6ijSgfD71gTWokBiM8WPn72xxg8=' --data '{
   "gameIndex": 1,
   "matchId": 1,
   "matchingInfos": [
       {
           "matchingId": "1:1_2024-06-05T05:43:28.91_1",
           "privateInfos": [
               {
                   "playerId": 100,
                   "point": 1000
               },
               {
                   "playerId": 101,
                   "point": 1000
               }
           ]
       }
   ],
   "timeoutPlayerInfos": []
}'


You can verify the authenticity of the callback result using the value of the Header Parameter X-Match-Signature, and the key to be used for the algorithm calculation can be found in the Hive Console. Below is an example of Java code to obtain the Signature.

import java.nio.charset.StandardCharsets;
import java.util.Base64;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
public class MatchSignature {  
   private static final String HMAC_SHA_256 = "HmacSHA256";
   private static final String UTF_8 = "UTF-8";
   public String getSignature(String secret, String httpRequestBody) throws Exception {
       SecretKeySpec key = new SecretKeySpec(secret.getBytes(), HMAC_SHA_256);
       Mac mac = Mac.getInstance(HMAC_SHA_256);
       mac.init(key);
       byte[] source = httpRequestBody.getBytes(UTF_8);

       return new String(Base64.getEncoder().encode(mac.doFinal(source)), StandardCharsets.UTF_8);
   }
}


If the callback sent from the Hive Server is successfully received, you should return an HTTP status 200 as a response.

  • Response with HttpStatus 200: It is considered that the match has been successfully completed, so the match request will be canceled.
  • Response with a value other than HttpStatus 200 or Timeout: The match result callback will be resent at regular intervals.

If the Hive Server can't receive HTTP status 200 response continuously, the match result call back will not be delivered for a certain period for system management purposes.