Receive data on match winners
Gamezop can post data on winners of multiplayer games on your webhook. This document details out how.
You need to build an API endpoint for this to work:
And then to receive data on the match winners, you can use either or both of the following options:
Receive Winners API (webhook created by you where we push data)
Gamezop Get Match Result API (Gamezop API endpoint from which you can pull data for any match)
Create Match API
You will have to give us a POST API endpoint where we will send the user objects and the room_id
when our servers group players into a match. Once we are able to find a match honouring the details you send in the roomDetails
object, we will make a request to this endpoint, and you will have to return a match_id
.
Here's the difference between a room_id
and a match_id
. Let's say Alice and Bob are playing a Tic Tac Toe game in room ABC01
. Alice wins. Now both Alice and Bob see an option to play again. They do so and now Bob wins. In this manner, players with the same room_id
may play the game multiple times. While the room_id
will remain same each time, the winners may differ across matches. That is why winners are scoped against a match_id
and not against a room_id
.
Your API endpoint
POST
https://api.publisher-xyz.com/games/create-match
You must build and maintain this endpoint. This receives user-objects from Gamezop, and returns a unique match_id
.
Headers
Authorization: Bearer
String
We can add in a bearer token in the authorization headers if you require us to.
Request body
room_id*
String
roomId
passed by you in the encoded roomDetails
object
status*
String
One of 2 options will be passed: MATCH_FOUND
or
players*
String
Array of matched together.
HTTP response codes
You must respond with a 200 when you return a match_id
Expected response body:
Receive Winners API
This will be another POST API endpoint that you create where, at the end of each match, we will send the user objects along with their ranks and scores back to your system. If you need to reward a player or take any other action on the basis of this data, you can do so upon receiving our hit on this endpoint.
Your API endpoint
POST
https://api.publisher-xyz.com/games/receive-winners
You must build and maintain this endpoint. Gamezop posts data on match winners to your system at the end of each multiplayer match via this endpoint.
Headers
Authorization: Bearer
String
We can add in a bearer token in the authorization headers if you require us to.
Request body
match_id*
String
match_id
generated by you uniquely identifying this match.
scores*
String
Array of JSON objects, each containing: , ,
HTTP response codes
You must respond with a 200 when you record winners successfully. Here's the response body we expect:
At the end of each match, we show a screen where the users of that match can see the final winners. If you have a prize amount that you're crediting the winners with, you can pass that as the prize
value, along with an icon for your currency in the currency_icon
value. are optional. This is what the screen looks like:
Gamezop Get Match Result API
This API allows you to pull data from Gamezop's systems for any match played by your users.
Gamezop API endpoint
GET
https://api.gamezop.com/v1/match-result?match_id={your-match-id}
Headers
Authorization: Bearer*
String
You can find the Bearer token for the Gamezop Get Match Result API in the Settings section of the Gamezop Business Dashboard.
You can also ask your Gamezop Account Manager to share it with you.
Query parameters
match_id*
String
HTTP response codes
Expected response body:
Understanding the response
The table below explains all the fields that we send to you when you receive a 200: OK response from us on the Gamezop Get Match Result API.
data.property_id
Your Gamezop Property ID associated with the bearer token that you sent in the ad request
data.game_code
data.room_id
data.match_id
The match_id
that you're requesting data for.
data.scores
Array of player score objects. These are all the players that participated in the match_id
you are requesting data for, and their scores. Within each object, you receive 4 attributes: sub
, is_bot
, rank
and score
.
is_bot
is a boolean that helps you identify if that particular player was a bot.rank
identifies that player's rank within the match. The player with rank1
is the winner of the match.score
represents that player's latest score within that match.
data.match_status
You can receive one of 2 values: COMPLETED
or IN_PROGESS
. This is also self-explanatory.
data.match_start_time
This is the UTC timestamp representing the time at which the match started.
success
Boolean value that is always true
, unless there is an error in the API response
message
String value that is always empty, unless there is an error in the API response
Last updated
Was this helpful?