- Calls this month
- 0
- Errors
- 0
- Error rate
- No calls yet
- Avg response
- No calls yet
This month, UTC.
Definition preview
Read-only outline of the saved source. Edit it under the Edit tab.
Input fields
item_id- string
Pipeline (4)
playerread collection inventory_stateitemlookup table inventory_consumablesowns_itemconditionconsumewrite collection inventory_state
Response
- Status
- 200
- Body
- keys: success, used
Full source
sourceVersion: 1
kind: endpoint
id: inventory_consume
name: Consume item
description: Removes an owned consumable and applies its effect. Fails when the item is unknown or not owned.
method: POST
enabled: true
input:
type: object
properties:
item_id:
type: string
required:
- item_id
steps:
- id: player
type: read
collection: inventory_state
key: '{{steamId}}'
- id: item
type: lookup
source: values
table: inventory_consumables
where:
field: item_id
op: ==
value: '{{input.item_id}}'
required: true
onMissing:
status: 404
errorCode: UNKNOWN_ITEM
message: '{{input.item_id}} is not a consumable.'
- id: owns_item
type: condition
check:
field: '{{pluck(player.inventory, item_id)}}'
op: contains
value: '{{input.item_id}}'
onFail:
status: 400
error: NOT_OWNED
message: You do not have {{item.name}}.
- id: consume
type: write
collection: inventory_state
key: '{{steamId}}'
ops:
- op: pull
path: inventory
match:
item_id: '{{input.item_id}}'
- op: inc
path: '{{item.stat}}'
value: '{{item.amount}}'
source: consumable
reason: Used {{item.name}}
response:
status: 200
body:
success: true
used: '{{item.name}}'
module: inventory