Grocy API: Can't get the available_amount of a product

I am trying to create a REST sensor of a Grocy product so that I can add it in the frontend as a part of a card. Grocy is an add-on in HAOS. I don’t want the answer to require the Grocy integration since that is being depricated.

Note: I have searched through the threads, but most answers are 5+ years old and don’t exactly answer my question.

I have tried the following codes with no luck. To the right of them, they list what the result was.

- platform: rest
  name: deodorant_b
  method: GET
  resource: https://grocy.XXXXXXXXXX/api/stock/products/9
  value_template: "{{ state_attr('sensor.grocy_stock', 'products')[9]['stock_amount'] }}" #unknown
  value_template: "{{ state_attr('sensor.grocy_stock', 'products')[9]['_name'] }}: {{ state_attr('sensor.grocy_stock', 'products')[9]['available_amount'] | int }}" #unknown
  value_template: "{{ state_attr('sensor.grocy_stock', 'products')[9].stock_amount | int(0) }}" #unknown
  value_template: "{{ state_attr('sensor.grocy_stock', 'products')[1].available_amount }}" #unknown
  value_template: "{{ (state_attr('sensor.grocy_stock', 'products')|selectattr('id', 'equalto', 9)|list|first).stock_amount }}" #deletes sensor
  value_template: "{{ (state_attr('sensor.grocy_stock', 'products')|selectattr('id', 'equalto' 9)).stock_amount }}" #deletes sensor
  value_template: "{% get product = state_attr('sensor.grocy_stock', 'products')|selectattr('id', 'equalto', 9)|list|first %}" #deletes sensor
  value_template: "{% set product = state_attr('sensor.grocy_stock', 'products')|selectattr('id', 'equalto', 9)|list|first %}" #blank
  value_template: "{{ 'stock_amount' }}" #text
  json_attributes:
    - stock_amount
    - stock_amount_opened
    - last_purchased
    - id
  headers:
    Accept: application/json
    Content-Type: application/json
    GROCY-API-KEY: !secret grocy_api

Obviously I only used one value_template at a time. When I use the REST API page, I can get results. I just can’t figure out the code to get that to fill the REST Sensor state.

  "product": {
    "id": 9,
    "name": "🔵 Deodorant",
    "description": "",
    "product_group_id": 1,
    "active": 1,
    "location_id": 3,
    "shopping_location_id": 1,
    "qu_id_purchase": 5,
    "qu_id_stock": 5,
    "min_stock_amount": 1,
    "default_best_before_days": -1,
    "default_best_before_days_after_open": 0,
    "default_best_before_days_after_freezing": 0,
    "default_best_before_days_after_thawing": 0,
    "picture_file_name": "7w8ve8s5k9hjk6zzfvk629w_deodorant_dove.jpg",
    "enable_tare_weight_handling": 0,
    "tare_weight": 0,
    "not_check_stock_fulfillment_for_recipes": 0,
    "parent_product_id": null,
    "calories": 0,
    "cumulate_min_stock_amount_of_sub_products": 0,
    "due_type": 1,
    "quick_consume_amount": 0.25,
    "hide_on_stock_overview": 0,
    "default_stock_label_type": 0,
    "should_not_be_frozen": 0,
    "treat_opened_as_out_of_stock": 1,
    "no_own_stock": 0,
    "default_consume_location_id": 7,
    "move_on_open": 1,
    "row_created_timestamp": "2025-03-08 14:34:31",
    "qu_id_consume": 5,
    "auto_reprint_stock_label": 0,
    "quick_open_amount": 1,
    "qu_id_price": 5,
    "disable_open": 0,
    "default_purchase_price_type": 1
  },
  "product_barcodes": [],
  "last_purchased": "2025-05-12",
  "last_used": "2025-05-14",
  "stock_amount": 1.75,
  "stock_value": 0,
  "stock_amount_opened": 0.75,
  "stock_amount_aggregated": 1.75,
  "stock_amount_opened_aggregated": 0.75,
  "quantity_unit_stock": {
    "id": 5,
    "name": "Stick",
    "description": null,
    "row_created_timestamp": "2025-03-07 22:06:50",
    "name_plural": "Sticks",
    "plural_forms": null,
    "active": 1
  },
  "default_quantity_unit_purchase": {
    "id": 5,
    "name": "Stick",
    "description": null,
    "row_created_timestamp": "2025-03-07 22:06:50",
    "name_plural": "Sticks",
    "plural_forms": null,
    "active": 1
  },
  "default_quantity_unit_consume": {
    "id": 5,
    "name": "Stick",
    "description": null,
    "row_created_timestamp": "2025-03-07 22:06:50",
    "name_plural": "Sticks",
    "plural_forms": null,
    "active": 1
  },
  "quantity_unit_price": {
    "id": 5,
    "name": "Stick",
    "description": null,
    "row_created_timestamp": "2025-03-07 22:06:50",
    "name_plural": "Sticks",
    "plural_forms": null,
    "active": 1
  },
  "last_price": 0,
  "avg_price": null,
  "oldest_price": 0,
  "current_price": 0,
  "last_shopping_location_id": 1,
  "default_shopping_location_id": 1,
  "next_due_date": "2999-12-31",
  "location": {
    "id": 3,
    "name": "1L 🔵 - Vanity",
    "description": null,
    "row_created_timestamp": "2025-03-07 22:01:22",
    "is_freezer": 0,
    "active": 1
  },
  "average_shelf_life_days": 355979,
  "spoil_rate_percent": 0,
  "is_aggregated_amount": 0,
  "has_childs": false,
  "default_consume_location": {
    "id": 7,
    "name": "1L 🔵 - Sink",
    "description": null,
    "row_created_timestamp": "2025-03-08 14:29:03",
    "is_freezer": 0,
    "active": 1
  },
  "qu_conversion_factor_purchase_to_stock": 1,
  "qu_conversion_factor_price_to_stock": 1
}```