API Royale
API Royale allows ROY ecosystem apps and games to interact with Crypto Royale in-game wallets, bypassing
the Blockchain. This has several advantages:
- Reduces development time for ecosystem developers.
- Minimizes impact of blockchain changes, like going multi-chain or moving chains.
-
Provides better UX and fraud protection for users, through a permission and chargeback system.
To use API Royale, ecosystem devs need to:
-
Set-up Discord authentication on their end, (CR uses Discord IDs as reference)
- Set-up an API account (done manually at the moment, contact us)
- Direct users to https://cryptoroyale.one/apps where they
can give your app permission to access their wallet.
Info needed to set-up an API account:
- Name of app
- Thumbnail for app
- URL of app, to direct users
- List of permissions needed (increment, decrement, userbalance, skins)
- Maximum decrement size (default: 100)
- Maximum increment size (default: 100)
- Rate-limit (default: 200ms)
In return you will receive a key that is needed for all API calls. This key must
be held securely at all times. Make sure to not share it with anyone. If your key is
compromised, please contact us immediately.
API Endpoints
POST /api/royale/decrement
Description: Transfer funds from user wallet to API wallet. Only possible if your API has been given the
decrement
permission by the user. Decrement calls are taxed by Crypto Royale at 0.5%. e.g. a 100 ROY decrement will result in 99.5 ROY showing up in your API balance.
Body parameters:
- key [String]: API key
- amount [Number]: Amount of ROY to deduct from user
- discordid [String]: Discord ID of user
- reason [String]: Reason for deduction. Shows up in transactions prefixed by your app's initials.
- nonce [String]: One-time ID. Store on your end. Must be unique across all transactions for your
app.
Prevents duplicates and used for
cross database references.
-
data [JSON, optional]: Optional data bundle to store on CR servers. Can be used to display
additional info in transactions UI.
Return Messages and HTTP codes:
- 'Rate-limited. Slow down.',403
- 'Missing body parameters',403
- 'Incorrect or missing API key',403
- 'Missing permission',403
- 'Missing amount, or decrement too large ',403
- 'Missing discord id',403
- 'Unauthorized user',403
- 'User balance too low',403
- 'Missing reason or nonce',403
- 'Decrement Failed', 403, {error: internal_decrement_fail_reason}
- 'Decrement succeeded', 200, {balance: your_api_balance}
Body Example:
{
"key": "d7e60d03-5121-4d37-926e-daaa9a1ef5ca",
"amount": 100,
"discordid": "85405022041071626",
"reason": "test-decrement",
"data": {"howdy": "sir"},
"nonce": "7"
}
POST /api/royale/increment
Description: Transfer funds from API wallet to user wallet. Only possible if your API has been given the
increment
permission by the user.
Body parameters:
- key [String]: API key
- amount [Number]: Amount of ROY to give user
- discordid [String]: Discord ID of user
- reason [String]: Reason for increment. Shows up in transactions prefixed by your app's initials.
- nonce [String]: One-time ID. Store on your end. Must be unique across all transactions for your
app.
Prevents duplicates and used for
cross database references.
-
data [JSON, optional]: Optional data bundle to store on CR servers. Can be used to display
additional info in transactions UI.
Return Messages and HTTP codes:
- 'Rate-limited. Slow down.',403
- 'Missing body parameters',403
- 'Incorrect or missing API key',403
- 'Missing permission',403
- 'Missing amount, or increment larger than permitted or larger than your API
balance',403
- 'Missing discord id',403
- 'Unauthorized user',403
- 'Missing reason or nonce',403
- 'API balance went negative. Reverting.',403
- 'Increment Failed. Reverting API balance', 403, {error: internal_increment_fail_reason}
- 'Increment succeeded', 200, {balance: your_api_balance}
Body Example:
{
"key": "d7e60d03-5121-4d37-926e-daaa9a1ef5ca",
"amount": 50,
"discordid": "85405022041071626",
"reason": "test-incremenent",
"data": {"howdy": "sir"},
"nonce": "332"
}
POST /api/royale/balance
Body parameters:
Return Messages and HTTP codes:
- 'Rate-limited. Slow down.',403
- 'Missing body parameters',403
- 'Incorrect or missing API key',403
- 'Your API balance is _', 200, {balance: your_api_balance}
Body Example:
{
"key": "d7e60d03-5121-4d37-926e-daaa9a1ef5ca",
}
POST /api/royale/userbalance
Description: Check how much ROY is in a user's wallet. Only possible if your API has been given the
userbalance
permission by the user.
Body parameters:
- key [String]: API key
-
discordid [String]: Discord ID of user
Return Messages and HTTP codes:
- 'Rate-limited. Slow down.',403
- 'Missing body parameters',403
- 'Missing discord id',403
- 'Incorrect or missing API key',403
- 'User Balance is __', 200, {balance: user_balance}
Body Example:
{
"key": "d7e60d03-5121-4d37-926e-daaa9a1ef5ca",
"discordid": "85405022041071626"
}
POST /api/royale/userpermissions
Description: Check which permissions your app has been given, by a specific user. Ideally your app should
degrade its UX gracefully, if less permissions are given than expected. For example, do not show a user's
balance in your own app if the balance
permission is not available.
Body parameters:
- key [String]: API key
-
discordid [String]: Discord ID of user
Return Messages and HTTP codes:
- 'Rate-limited. Slow down.',403
- 'Missing body parameters',403
- 'Missing discord id',403
- 'Incorrect or missing API key',403
- 'User Permissions retrieved __', 200, {permissions: json_object}
Body Example:
{
"key": "d7e60d03-5121-4d37-926e-daaa9a1ef5ca",
"discordid": "85405022041071626"
}
Response Example:
{
"msg": "User Permissions retrieved",
"data": {
"permissions": [
{
"type": "balance",
"value": false
},
{
"type": "decrement",
"value": false
},
{
"type": "increment",
"value": false
}
]
}
}
POST /api/royale/incrementVP
Description: Give user Victory Points. Uses ROY from your API Balance at the
current VP:ROY conversion rate. Only possible if your API has been given the
skin
AND increment
permissions by the
user.
Body parameters:
- key [String]: API key
- amount [Number]: Amount of VP to give user
- discordid [String]: Discord ID of user
- skin [String]: Clan to give VPs on. Must match the user's currently equipped skin IF no skin_id is
provided.
- skin_id [Integer,optional]: ID of skin to give VPs on. If not provided, currently equipped skin is
tried.
- gid [Integer,optional]: Optional metadata. Shows up in user wallet.
- clan [Number,optional]: Optional metadata. Shows up in user wallet.
- sp [Number,optional]: Optional metadata. Shows up in user wallet.
- enemies [Integer,optional]:Optional metadata. Shows up in user wallet.
- mode [Integer,optional]: Optional metadata. Shows up in user wallet.
Return Messages and HTTP codes:
- 'Rate-limited. Slow down.',403
- 'Missing body parameters',403
- 'Incorrect or missing API key',403
- 'Missing permission',403
- 'Missing amount, or increment larger than permitted or larger than your API
balance',403
- 'Missing discord id or skin',403
- 'Unauthorized user',403
- 'Skin clan does not match equipped skin or can not find skin for some other reason',403
- 'API balance went negative. Reverting.',403
- 'VP Increment Failed. Reverting API balance', 403, {error: internal_increment_fail_reason}
- 'VP Increment succeeded', 200, {balance: your_api_balance}
Body Example:
{
"key": "d7e60d03-5121-4d37-926e-daaa9a1ef5ca",
"amount": 100,
"discordid": "85405022041071626",
"skin": "cherry",
"enemies": 4000,
}
POST /api/royale/userequippedskin
Description: Check which skin a user has currently equipped. Only possible if your API has been given the
skin
permission by the user.
Body parameters:
- key [String]: API key
-
discordid [String]: Discord ID of user
Return Messages and HTTP codes:
- 'Rate-limited. Slow down.',403
- 'Missing body parameters',403
- 'Missing discord id',403
- 'Incorrect or missing API key',403
- 'User equipped skin is _', 200, {equippedskin: '_', skin_id: '_', skinpower:'_' }
Body Example:
{
"key": "d7e60d03-5121-4d37-926e-daaa9a1ef5ca",
"discordid": "85405022041071626"
}
POST /api/royale/incrementVP
Description: Give user Victory Points. Make sure to give a reasonable amount compared to other ecosystem games and the main game. Rough guideline: Do not exceed 1K VP per minute of playtime on average.. Only possible if your API has been given the
skin
AND increment
permissions by the
user.
Body parameters:
- key [String]: API key
- amount [Number]: Amount of VP to give user
- discordid [String]: Discord ID of user
- skin [String]: Clan to give VPs on. Must match the user's currently equipped skin IF no skin_id is
provided.
- skin_id [Integer,optional]: ID of skin to give VPs on. If not provided, currently equipped skin is
tried.
- gid [Integer,optional]: Optional metadata. Shows up in user wallet.
- clan [Number,optional]: Optional metadata. Shows up in user wallet.
- sp [Number,optional]: Optional metadata. Shows up in user wallet.
- enemies [Integer,optional]:Optional metadata. Shows up in user wallet.
- mode [Integer,optional]: Optional metadata. Shows up in user wallet.
Return Messages and HTTP codes:
- 'Rate-limited. Slow down.',403
- 'Missing body parameters',403
- 'Incorrect or missing API key',403
- 'Missing permission',403
- 'Missing amount, or increment larger than permitted or larger than your API
balance',403
- 'Missing discord id or skin',403
- 'Unauthorized user',403
- 'Skin clan does not match equipped skin or can not find skin for some other reason',403
- 'API balance went negative. Reverting.',403
- 'VP Increment Failed. Reverting API balance', 403, {error: internal_increment_fail_reason}
- 'VP Increment succeeded', 200, {balance: your_api_balance}
Body Example:
{
"key": "d7e60d03-5121-4d37-926e-daaa9a1ef5ca",
"amount": 100,
"discordid": "85405022041071626",
"skin": "cherry",
"enemies": 4000,
}
POST /api/royale/incrementZone
Description: Transfer ROY from your API account to your app's Skin Wars Zone, if you have one. Increasing
your Skin Wars Zone will make it more attractive to players, as well as move it up the Zone leaderboard for
additional exposure. Your zone's prize pool will be reset to its starting amount every day when the war
resets.
Body parameters:
- key [String]: API key
- amount [Number]: Amount of ROY to add to zone
- nonce [String]: One-time ID. Store on your end. Must be unique across all transactions for your
app.
Prevents duplicates and used for
cross database references.
Return Messages and HTTP codes:
- 'Rate-limited. Slow down.',403
- 'Missing body parameters',403
- 'Incorrect or missing API key',403
- 'Negative amount',403
- 'API balance too low',403
- 'CR database error. Did you use a unique nonce?',403
- 'This API account does not have an associated warzone',403
- 'Increment Zone Successful', 200, {prize: the_new_prize_pool_level}
Body Example:
{
"key": "d7e60d03-5121-4d37-926e-daaa9a1ef5ca",
"amount": 100,
"nonce": "5032",
}
POST /api/royale/mintSkin
Description: Mint a skin managed by your app directly into a user's account. This does not charge the user
any ROY, so make sure to do so seperately beforehand, if the mint is not meant to be free.
Body parameters:
- key [String]: API key
-
discordid [String]: Discord ID of user
- nft_id [Number]: The id of skin you want to mint
- nonce [String]: One-time ID. Store on your end. Must be unique across all transactions for your
app.
Prevents duplicates and used for
cross database references.
Return Messages and HTTP codes:
- 'Rate-limited. Slow down.',403
- 'Missing body parameters',403
- 'Incorrect or missing API key',403
- 'Missing NFT id or discord id',403
- 'Could not find skin or it's not mintable by your app',403
- 'Max supply reached',403
- 'Could not find user. Did you use the correct discord id?',403
- 'Skin Mint Successful', 200, {}
Body Example:
{
"key": "d7e60d03-5121-4d37-926e-daaa9a1ef5ca",
"discordid": "85405022041071626",
"nft_id": 134,
"nonce": "5032",
}