Play Game
POST /v1/games/playExecutes a game play for a user. Deducts points, determines the outcome using the server-side RNG, and returns the result with the reward.
Authentication
Section titled “Authentication”| Header | Required | Value |
|---|---|---|
X-API-Key | Yes | Your public key |
Content-Type | Yes | application/json |
Request Body
Section titled “Request Body”| Field | Type | Required | Description |
|---|---|---|---|
userId | string | Yes | The user’s external ID in your system |
gameType | string | Yes | One of NEON_WHEEL, COSMIC_SLOTS, ENIGMA_BOXES |
Request Examples
Section titled “Request Examples”curl -X POST https://api.gamifyhost.com/v1/games/play \ -H "X-API-Key: pk_live_your_public_key" \ -H "Content-Type: application/json" \ -d '{ "userId": "user_12345", "gameType": "NEON_WHEEL" }'const response = await fetch('https://api.gamifyhost.com/v1/games/play', { method: 'POST', headers: { 'X-API-Key': 'pk_live_your_public_key', 'Content-Type': 'application/json', }, body: JSON.stringify({ userId: 'user_12345', gameType: 'NEON_WHEEL', }),});
const data = await response.json();console.log(data.data.reward); // { tier, type, value, label }import requests
response = requests.post( "https://api.gamifyhost.com/v1/games/play", headers={ "X-API-Key": "pk_live_your_public_key", "Content-Type": "application/json", }, json={ "userId": "user_12345", "gameType": "NEON_WHEEL", },)
data = response.json()print(data["data"]["reward"])import java.net.http.HttpClient;import java.net.http.HttpRequest;import java.net.http.HttpResponse;import java.net.URI;
HttpClient client = HttpClient.newHttpClient();
String body = """ { "userId": "user_12345", "gameType": "NEON_WHEEL" } """;
HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://api.gamifyhost.com/v1/games/play")) .header("X-API-Key", "pk_live_your_public_key") .header("Content-Type", "application/json") .POST(HttpRequest.BodyPublishers.ofString(body)) .build();
HttpResponse<String> response = client.send( request, HttpResponse.BodyHandlers.ofString());System.out.println(response.body());payload := strings.NewReader(`{ "userId": "user_12345", "gameType": "NEON_WHEEL"}`)
req, _ := http.NewRequest( "POST", "https://api.gamifyhost.com/v1/games/play", payload,)req.Header.Set("X-API-Key", "pk_live_your_public_key")req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)if err != nil { log.Fatal(err)}defer resp.Body.Close()
var result map[string]interface{}json.NewDecoder(resp.Body).Decode(&result)fmt.Println(result["data"])$ch = curl_init('https://api.gamifyhost.com/v1/games/play');curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => [ 'X-API-Key: pk_live_your_public_key', 'Content-Type: application/json', ], CURLOPT_POSTFIELDS => json_encode([ 'userId' => 'user_12345', 'gameType' => 'NEON_WHEEL', ]),]);
$response = curl_exec($ch);curl_close($ch);
$data = json_decode($response, true);print_r($data['data']['reward']);require 'net/http'require 'json'
uri = URI('https://api.gamifyhost.com/v1/games/play')req = Net::HTTP::Post.new(uri)req['X-API-Key'] = 'pk_live_your_public_key'req['Content-Type'] = 'application/json'req.body = { userId: 'user_12345', gameType: 'NEON_WHEEL'}.to_json
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http| http.request(req)enddata = JSON.parse(res.body)puts data['data']['reward']using var client = new HttpClient();client.DefaultRequestHeaders.Add( "X-API-Key", "pk_live_your_public_key");
var content = new StringContent( """{"userId": "user_12345", "gameType": "NEON_WHEEL"}""", System.Text.Encoding.UTF8, "application/json");
var response = await client.PostAsync( "https://api.gamifyhost.com/v1/games/play", content);var json = await response.Content.ReadAsStringAsync();Console.WriteLine(json);import 'dart:convert';import 'package:http/http.dart' as http;
final response = await http.post( Uri.parse('https://api.gamifyhost.com/v1/games/play'), headers: { 'X-API-Key': 'pk_live_your_public_key', 'Content-Type': 'application/json', }, body: jsonEncode({ 'userId': 'user_12345', 'gameType': 'NEON_WHEEL', }),);
final data = jsonDecode(response.body);print(data['data']['reward']);Response
Section titled “Response”Status: 200 OK
{ "message": "Game played successfully", "code": 200, "status": "success", "data": { "playId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "gameType": "NEON_WHEEL", "userId": "user_12345", "pointsSpent": 100, "userBalance": 4900, "outcome": { "winningSegment": 3, "spinAngle": 247.5 }, "reward": { "tier": "rare", "type": "cashback", "value": 50, "label": "$0.50 cashback" }, "environment": "LIVE", "playedAt": "2025-07-15T10:30:00Z" }}Response Fields
Section titled “Response Fields”| Field | Type | Description |
|---|---|---|
playId | uuid | Unique play record identifier |
gameType | string | Game that was played |
userId | string | The user who played |
pointsSpent | integer | Points deducted for this play |
userBalance | integer | User’s remaining balance after deduction |
outcome | object | Game-specific outcome (segment index, reel positions, box index, etc.) |
reward.tier | string | epic, rare, or common |
reward.type | string | cashback, xp, points, item, or special |
reward.value | integer | Numeric reward value |
reward.label | string | Human-readable reward label |
environment | string | LIVE or TEST |
playedAt | datetime | ISO 8601 timestamp |
Errors
Section titled “Errors”| Code | Message |
|---|---|
400 | Invalid request body / validation error |
402 | Insufficient points |
404 | Game mechanic not found |
404 | User not found |