owned this note
owned this note
Published
Linked with GitHub
{%hackmd @themes/orangeheart %}
# Game engine API
## Header
| Key | Value |
| ---- | ----------- |
| Content-Type | application/json |
| Accept | \*/* |
| Authorization | copy game's JWT token |
## Http Status Code
| Code | Description |
| ---- | ----------- |
| 200 | Ok. Further status in response body refer Status Code below |
| 400 | Incomplete Request Info |
| 401 | Unauthorized Access |
| 500 | Internal Error |
## Response Common Fields
| Fields | Type | Description |
| ---- | ---- | ----------- |
| Status | number | Refer to Status Code below |
| Ts | number | Unix Timestamp |
## Status Code
| Code | Description |
| ---- | ----------- |
| 200 | Ok |
| 400 | InsufficientBalance |
| 401 | Invalid Game Id |
## Authentication
Clients must input JWT in the Authorization header as Bearer Token.
## API - Login
### endpoint: {GAME URL}/Game/Login
### method: POST
### Request:
```json
{
"GameCode": "120021"
}
```
### Response:
```json
{
"Player": {
"Balance": 1000,
"Rate": 1,
"Currency": "MYR",
"CoinRate": 100
},
"GameInfo": {
"Line": 9,
"BetValue": [
1
],
"LineBet": [
0.01,
0.02,
0.03,
0.04,
...
]
},
"Current": { ... } // optional
"Next": {
"Type": 1 -- Next Transact put in type here
},
"Status": 200,
"Ts": 1714038486
}
```
Current Bet = Bet Value(Almost always is 1) * Line * LineBet
```json
{
"BuyFeature": [
{
"RoundType": 2,
"Rate": 100,
"Total": 12
},{
"RoundType": 3,
"Rate": 200,
"Total": 12
}
]
}
```
Buy Feature is an Array, there might have RoundType 3 and different rate.
## API - Transact
### endpoint: {GAME URL}/Game/Transact
### method: POST
### Request:
```json
{
"Type": 1, -- Get from Login's Next Type
"BetValue": 1, --- Normal game always 1
"RoundType": 1, -- Normal is 1, Buy Free Spin is 2
"Index": null,
"LineBet": 0.01, Base on current user selected bet range
"Line": 9, --- Get from Login's GameInfo
"Mode": 1 -- Current Mode is always 1
}
```
### Response:
```json
{
"Player": {
"Balance": 1000
},
"Current": {
"Type": 1,
"TotalWin": 0,
"AccWin": 0,
"Result": {
"R": "201,104,103|101,103,203|104,103,201|101,101,101|104,204,1"
},
"Round": {
"RoundType": 1,
"Bet": 0.09,
"ActualBet": 0.09,
"BetValue": 1,
"Line": 9,
"LineBet": 0.01,
"Payout": 0,
"Items": []
},
"WBId": "349503958",
"RId": 70987558,
"ReId": 2
},
"Next": {
"Type": 1
},
"Status": 200,
"Ts": 1714038686
}
```
## API - KeepAlive
### endpoint: {GAME URL}/Game/KeepAlive
### method: POST
### Request:
```json
{
"GameCode": "120021"
}
```
### Response:
```json
{
"Jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ3bW15eHVhbjMxNEB3bW15IiwidWlkIjoiMyIsImdpZCI6IjEiLCJvaWQiOiIxIiwicG9pZCI6IjEiLCJjdXJyIjoiTVlSIiwiZXhwIjoxNjQ1NjEwMDg1LCJpc3MiOiJHUzEiLCJhdWQiOiJHUzEifQ.9tnNKAIME6oGyJhGwalDDEzg-25_nAhCaWYF-Sc_Pjo",
"Status": 200,
"Ts": 1641443474
}
```