Skip to content

Seamless Wallet Mode

In this mode, OP needs to provide certain interfaces to 2J, so that 2J can obtain OP player's balance information in real-time and complete operations such as betting and payouts.

See Flow Overview for interaction flow.

Interfaces Provided by 2J

Interface NameDescriptionPath
Common APIsCommon APIs provided by 2J
Balance Change NotificationNotify 2J to update user balance

1. Balance Change Notification

Method: POST

URI: /open2j/w/seamless/balance_change

Description: Notify 2J about user balance changes to update the user's balance in 2J games in near real-time.

Request Body:

Content-Type: application/json

json
{
    "op_id": "xxx-xxx-aaa", // Unique identifier of the OP user, required
    "changed_amount": 123,  // Balance change value: positive for increase, negative for decrease, required
    "trans_no": "xxxxxxxx"  // Unique identifier for the transaction, required
}

Parameter description:

ParameterTypeDescriptionRequiredValue Range
op_idstringOP player IDYes
changed_amountintBalance change value: positive for increase, negative for decreaseYes[-9,223,372,036,854,775,808, 9,223,372,036,854,775,807]
trans_nostringUnique identifier for the transactionYesLength limit 6-64

Response Body:

Content-Type: application/json

json
{
    "header": {
        "code": 0, // Error code, 0 means normal, non-0 means abnormal
        "msg": "",
        "timestamp":1709716095516,
    }
}

Interfaces Provided by OP

OP needs to provide the following interface for 2J to use, the timeout time of the interface is 5 seconds, after which 2J will consider the interface call failed.

Interface NameDescriptionPathRequired
Query User BalanceQuery user balance/balance/getYes
User Profile QueryQuery user information/member/profileYes
User Bet/SettlementUser bet/settlement/order/transferNo, depends on the game
User Batch Bet/SettlementUser batch bet/settlement/order/batch_transferNo, depends on the game
Business Data PushBusiness data push/order/businessNo

Regarding the choice between /order/transfer and /order/batch_transfer, different game ID ranges use different betting and payout interfaces, specifically:

Game ID RangeApplicable Bet/Settlement Interface
1000~1999/order/transfer
2000~2999/order/batch_transfer
3000~3999/order/batch_transfer
4000~4999/order/transfer
6000~6999/order/transfer

1. Query User Balance /balance/get

Method: POST

URI: /balance/get

Description: Query user balance

Request Body:

Content-Type: application/json

json
{
    "op_id": "xxx-xxx-aaa", // OP side user unique identifier, required
    "game_id": 1006, // Game ID, indicates which game the request comes from, optional
}

Response Body:

Content-Type: application/json

json
{
    "header": {
        "code": 103, // Error code, 0 indicates normal, non-0 indicates abnormal
        "msg": "user not exist",
        "timestamp":1709716095516,
    },
    "result": {
        "op_id": "111444", // OP side user unique identifier
        "availableAmount": 998, // OP user's current available balance     
    },
}

2. User Profile Query /member/profile

Method: POST

URI: /member/profile

Description: Used to get user information in real-time

Request Body:

Content-Type: application/json

json
{
    "op_id": "xxx-xxx-aaa", // OP side user unique identifier, required
}

Parameter description:

ParameterTypeDescriptionNote
op_idstringOP player ID

Response Body:

Content-Type: application/json

json
{
    "header": {
        "code": 0, // Error code, 0 indicates normal, non-0 indicates abnormal
        "msg": "",
        "timestamp":1709716095516,
    },
    "result": 
    {
        "nickname": "player01", // OP player nickname required
        "gender": 1 , // OP player gender 0-unknown, 1-female, 2-male
    }
}

3. User Bet/Settlement /order/transfer

Method: POST

URI: /order/transfer

Description: Used for single-player game betting and payout

This interface is suitable for single-player games: used for OP user betting and payout, at least one call, OP needs to maintain this interface's idempotency.

API settle retry: 2J attempts to call this interface multiple times when there is a network error or when the returned http code is not equal to 200.

Bet cancellation occurs when the user places a bet and 2J's call to OP's interface fails (timeout, abnormal error). In this case, 2J will call this interface with action=3 to indicate bet cancellation.

Note that retrying the settle or canceling the bet should return a normal result, header.code=0, not an error, if the OP has handled it successfully.

Note⚠️: In the request parameters for bet cancellation, amount is positive, equal to the absolute value of the previous bet amount (negative); action is 3. Other parameters remain consistent with the bet request (including trans_no and draw_id).

Request Body:

Content-Type: application/json

json
{
    "action":1, // 1: Bet, 2: Payout, 3: Bet cancellation
    "op_id": "xxx-xxx-aaa", // OP side user unique identifier, required
    "timestamp":1709201163,// Timestamp (seconds) The creation time of this order
    "order": 
    {
        "trans_no":"101156966-1170920125564673-1006-2-1726-1709201163-0",// Unique credential for this change
        "draw_id":"1006-2-1726-1709201163-0", // Round unique identifier
        "game_id": 1006, // Game ID
        "amount": -5000, // Amount change
        "room_kind": 1, // Room type
        "extra_business": // Optional. Additional business data for different games
        {
            "win_crash_bet": 1000, // Accumulated negative win/loss amount during each settlement cycle in fishing games
            "total_bet": 5000, // Total bet amount when exiting fishing games
            "total_award": 0, // Total payout amount when exiting fishing games
            "award_type": 0, // Award type 0-normal,1-freegame,2-bonus
            "base_amount": 12000, // Total award excluding JP in base game
            "free_amount": 0, // Total winnings in feature, excluding trigger round and JP awards
            "bonus_amount": 0, // Total winnings in feature, excluding trigger round and JP awards
            "jackpot_amount": 0, // Total JP winnings in a single game (including std and feature JP)
            "extra_spins": 0, // Number of extra free games in a single game
            "is_buy": false // This round is buy or not
        }
    }
}

Parameter description:

ParameterTypeDescriptionNote
actionintRequest action1: Bet, 2: Payout, 3: Bet cancellation
op_idstringOP player ID
timestampint64The creation time of this order
orderobjectOrder structure
order.trans_nostringOrder unique credential, can be used for idempotency
order.draw_idstringRound unique identifier
order.game_idintGame ID
order.amountint64Amount changeFor fishing games, this is a pre-hold value during betting, not the actual player bet
order.extra_businessobjectAdditional business data for different gamesFor fishing games, actual player bet and payout are reflected in this field

2J will periodically update the extra_business information. Please ensure compatibility handling of the extra_business field during integration

⚠️ Note: In fishing games, the amount change is still based on the amount parameter. The extra_business field only contains statistical data for the current game session.

Additional business data description for fishing games:

ParameterTypeDescriptionNote
extra_business.win_crash_betintAccumulated negative win/loss amount during each settlement cycle in fishing games
extra_business.total_betintActual bet amount when exiting fishing games
extra_business.total_awardintActual payout amount when exiting fishing games

Additional business data description for slots games(If you don't need the following list information, please ignore the extra_business field for slots type games):

ParameterTypeDescriptionNote
extra_business.award_typeintAward type0-normal,1-freegame,2-bonus
extra_business.base_amountintTotal award excluding JP in base game
extra_business.free_amountintTotal winnings in feature, excluding trigger round and JP awards
extra_business.bonus_amountintTotal winnings in feature, excluding trigger round and JP awards
extra_business.jackpot_amountintTotal JP winnings in a single game (including std and feature JP)
extra_business.extra_spinsintNumber of extra free games in a single game
extra_business.is_buyboolThis round is buy or not

Response Body:

Content-Type: application/json

json
{
    "header": {
        "code": 0, // Error code, 0 indicates normal, non-0 indicates abnormal
        "msg": "",
        "timestamp":1709716095516,
    },
    "result": 
    {
        "op_id": "111444", // required OP side user unique identifier
        "availableAmount": 998, // required OP user's current available balance     
    },
}

4. User Batch Bet/Settlement /order/batch_transfer

Method: POST

URI: /order/batch_transfer

Description: Used for multiplayer game betting and payout

This interface is suitable for multiplayer and battle games: used for multiple OP users betting and payout, at least one call, OP needs to maintain this interface's idempotency.

API settle retry: 2J attempts to call this interface multiple times when there is a network error or when the returned http code is not equal to 200.

Bet cancellation occurs when the user places a bet and 2J's call to OP's interface fails (timeout, abnormal error). In this case, 2J will call this interface with action=3 to indicate bet cancellation.

Note that retrying the settle or canceling the bet should return a normal result, header.code=0, not an error, if the OP has handled it successfully.

Note⚠️: In the request parameters for bet cancellation, amount is positive, equal to the absolute value of the previous bet amount (negative); action is 3. Other parameters remain consistent with the bet request (including trans_no and draw_id).

Batch processing: When there are more than 100 bets placed in a single round, the betting and payout processes will be divided into multiple concurrent requests, with each request containing up to 100 betting or payout transactions.

Request Body:

Content-Type: application/json

json
{
    "action": 1, // 1: Bet, 2: Payout, 3: Bet cancellation
    "trans_no": "xxxxx-001",// Unique credential for this change
    "draw_id": "1006-2-1726-1709201163-0", // Round unique identifier
    "game_id": 1006, // Game ID
    "room_kind": 0, // Room type
    "timestamp":1709201163,// Timestamp (seconds) The creation time of these orders
    "orders": [
        {
        "trans_no": "xxxxx-001",
        "op_id": "xxx-xxx-aaa", // OP side user unique identifier, required
        "amount": -5000, // Amount change
        "extra_business": {"total_bet":6000,"total_award":1000},
        },
        {
        "trans_no": "xxxxx-002",
        "op_id": "xxx-xxx-bbb", // OP side user unique identifier, required
        "amount": 5000, // Amount change
        "extra_business": {"total_bet":1000,"total_award":5000},
        }
    ]
}

Parameter description:

ParameterTypeDescriptionNote
actionintRequest action1: Bet, 2: Payout, 3: Bet cancellation
trans_nostringUnique identifier for these orders
draw_idstringRound unique identifier
game_idintGame ID
room_kindintRoom type
timestampint64Timestamp (seconds) The creation time of this order
ordersobjectOrder structure
order.trans_nostringOrder unique credential, can be used for idempotency
order.op_idstringOP user unique identifier
order.amountint64Amount changeNot the player's actual bet and reward
order.extra_businessobjectAdditional business data for different gamesContains actual bet and reward business information for this round

2J will periodically update the extra_business information. Please ensure compatibility handling of the extra_business field during integration

Note⚠️: order.amount is a flow record, not the actual bet and payout. For battle games and multiplayer games where losses may exceed the bet amount, order.amount includes additional pre-hold amount and pre-hold return amount.

Pre-hold: The action of pledging a portion of the player's balance in advance to handle issues of insufficient balance during rapid betting and unknown win/loss amounts. It will be returned after the round ends. Currently, fishing games, battle games, and multiplayer games all use pre-hold.

For example: In the game Mythical Animals, when a player bets $100, the order.amount at betting time is -$1300. If the player loses an additional $300 at the end of the round, the order.amount at payout time is $900.

Effective Bet: In multiplayer games, when players place bets, the effective bet is calculated according to different game rules, and this value will be reflected in the settlement request.

For example: In the multiplayer game Dragon Tiger , if a player bets 100 in the Dragon area and simultaneously bets 100 in the Tiger area, since these two areas are opposing betting areas, the effective bet becomes 0. Additional business data description for multiplayer and battle games:

ParameterTypeDescription
extra_business.total_betintPlayer's actual bet in this game round
extra_business.total_awardintPlayer's actual reward in this game round
extra_business.valid_betintThe effective bet of multiplayer game players, this field is currently only valid for multiplayer games.

Response Body:

Content-Type: application/json

json
{
    "header": {
        "code": 0, // Error code, 0 means normal, and can be set to anything other than 0 unless all users fail(Or code can always be 0 as long as the code in data is correct)
        "msg": "not allowed bet",
        "reason":"not allowed bet",
    },
    "result": 
    {
        "data":[
            {
                "code": 0, // Error code, 0 indicates normal, non-0 indicates abnormal
                "op_id": "111444", // required OP side user unique identifier
                "availableAmount": 998, // required OP user's current available balance   
            },
            {
                "code": 0, // Error code, 0 indicates normal, non-0 indicates abnormal
                "op_id": "111445", // required OP side user unique identifier
                "availableAmount": 998, // required OP user's current available balance   
            }
        ]  
    }
}

Note⚠️header.code can only be set to non-0 if all users failed. If it is set to non-0, 2J will assume that all users failed in this request.

5. Business Data Push /order/business

Method: POST

URI: /order/business

Description: This interface is optional, used to push game business information to the OP side in real-time, such as firing and kill data for players in fishing games.

Request Body:

Content-Type: application/json

json
{
    "game_id": 4001, // Game ID
    "room_kind": 1, // Room type number
    "businesses":Object // Business data specific to different games
}

Parameter description:

ParameterTypeDescriptionNote
game_idintGame ID
room_kindintRoom type number
businessesObjectGame business dataFishdom

Response Body:

Content-Type: application/json

json
{
    "header": {
        "code": 0, // Error code, 0 indicates normal, non-0 indicates abnormal
        "msg": "",
        "timestamp":1709716095516,
    }
}

2J Game Inc.