Inventory
Inventory
The inventory module facilitates the management of game and gamer inventory items within a gaming system. Game inventory items are created and configured through the dashboard by administrators or developers. These items are then accessible to the players within the game environment, where they can acquire, use, and interact with them as part of their gamer inventory.
This module ensures seamless tracking and utilization of in-game assets, enhancing the overall gaming experience for players.
Available Endpoints
1. Get Own List of Inventory Items
- Method & Path:
GET /inventory
- Description: Facilitates the retrieval of inventory items owned by a gamer within the game. These items are configured by game developers through the game's play dashboard.
- Headers:
Authorization
— Bearer token for user authentication.
- Response Body: An array of inventory items, each containing —
id
: Unique identifier of the inventory item.name
: Name of the inventory item.quantity
: Quantity of the inventory item owned by the gamer.
cURL Command
curl --request GET \
--url https://api.yarsaplay.com/api/v1/inventory \
--header 'Authorization: Bearer YOUR_SECRET_TOKEN'
Response Body
{
"inventory": [
{
"id": "item1",
"name": "Sword of Valor",
"quantity": 1
},
{
"id": "item2",
"name": "Potion of Healing",
"quantity": 5
}
]
}
::: note
-
Ensure that the endpoint's implementation and documentation are clear to developers integrating with the API.
-
Regular updates to inventory items should be synchronized with changes made via the game's play dashboard. :::
2. Get Application’s Inventory
- Method & Path:
GET :applicationId/inventory
- Description: Allows retrieval of inventory items that are configured for a specific application within the game. These items are created and managed by game developers through the game's play dashboard, allowing customization and management of game assets.
- Headers:
Authorization
— Bearer token for user authentication.
- Query Parameters:
applicationId
— Determines the game ID.
- Response Body: An array of inventory items, each containing —
id
: Unique identifier of the inventory item.name
: Name of the inventory item.quantity
: Quantity of the inventory item owned by the gamer**.**
cURL Command:
curl --request GET \
--url https://api.yarsaplay.com/api/v1/__APPLICATIONID__/inventory
Response Body
[
{
"assets": [
{
"description": "string",
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "string",
"type": "IMAGE",
"uri": "https://example.com/"
}
],
"category": {
"description": "coins for game",
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "coins"
},
"description": "gold coins",
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"label": "coins",
"maxOwnableQuantity": -1,
"name": "gold coins",
"thumbnail": {
"description": "image of coins",
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "coin-image",
"uri": "https://example.com/"
}
}
]
-
Ensure clear documentation and communication regarding the
{applicationId}
parameter to developers using the API. -
Regular synchronization of inventory data with changes made through the game's play dashboard is essential for accurate inventory management.
3. Deduct Quantity From Gamer Inventory
- Method & Path:
PATCH /inventory/:id/deduct
- Description: Facilitates the reduction of the quantity of a specific inventory item that a gamer owns. It is typically used when a gamer spends or uses an inventory item, such as purchasing items from a shop within the game.
- Headers:
Authorization
— Bearer token for user authentication.
- Query Parameters:
id
— Unique Identifier of gamer inventory item.
- Request Body:
quantity
— Number of quantity that should be deducted.
- Response Body: An array of inventory items, each containing —
id
: Unique identifier for the transaction or event.quantity
: The deducted quantity of the inventory item.itemId
: The identifier of the inventory item for which the deduction was performed.
cURL Command
curl --request PATCH \
--url https://api.yarsaplay.com/api/v1/inventory/__ID__/deduct \
--header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
--header 'Content-Type: application/json'
Response Body
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"itemId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"quantity": 1
}
4. Increase Quantity From Gamer Inventory
- Method & Path:
PATCH /inventory/:id/increase
- Description: Facilitates the increment of the quantity of a specific inventory item that a gamer owns. It is typically used when a gamer spends or uses an inventory item, such as purchasing items from a shop within the game.
- Headers:
Authorization
— Bearer token for user authentication.
- Query Parameters:
id
— Unique Identifier of gamer inventory item.
- Request Body:
quantity
— number of quantity that should be increased.
- Response Body: An array of inventory items, each containing —
id
: Unique identifier for the transaction or event.quantity
: The increased quantity of the inventory item.itemId
: The identifier of the inventory item for which the increment was performed.
cURL Command
curl --request PATCH \
--url https://api.yarsaplay.com/api/v1/inventory/__ID__/increase \
--header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
--header 'Content-Type: application/json'
Response Body
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"itemId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"quantity": 1
}