# Energy

**URL:** https://heroiclabs.com/docs/hiro/python/energy/
**Summary:** Manage player energy resources including retrieval, usage, and direct grants.
**Keywords:** energy, hiro
**Categories:** hiro, python, energy

---


# Energy

*The Energy system manages player energy resources used to perform actions within your game.* Learn more in the [Energy concept guide](../../concepts/energy/_index.md).

## Overview

The Energy system allows your game to:

* Retrieve current energy levels and timers.
* Spend energy to perform specific actions.
* Grant energy directly to players.

## Before You Start

Make sure you have:

* Unity project configured with Hiro SDK.
* Nakama system integrated ([guide](../getting-started/_index.md)).

## Working with Energy

### Retrieving Player Energies

Get all available energies and their timers for the player:

```py
energy_list = await hiro_client.energy_get()
print(energy_list)
```

### Spending Energy

Spend player energy to complete actions:

```py
request = EnergySpendRequest()
request.amounts = {
    "power": 10,
    "tickets": 1
}

energy_spend_rewards = await hiro_client.energy_spend(request)
print(energy_spend_rewards)
```

### Spending energy with a custom refill start time

Spend energy and control when the refill timer starts for each energy.

```py
import time

request = EnergySpendWithRefillStartTimeRequest()
request.spends = {
    "power": EnergySpendWithTime(amount=10, refill_start_time=int(time.time())),
    "tickets": EnergySpendWithTime(amount=1, refill_start_time=int(time.time()) - 300)
}

energy_spend_reward = await hiro_client.energy_spend_with_refill_start_time(session, request)
print(energy_spend_reward)
```

### Granting Energy

Directly grant energy resources to a player:

```py
request = EnergyGrantRequest()
request.amounts = {
    "power": 10,
    "tickets": 1
}

energy_list = await hiro_client.energy_grant(request)
print(energy_list)
```

## Next Steps
- [Level-Based Stats](../../guides/personalizer/level-based-stats/)