# Streaks

**URL:** https://heroiclabs.com/docs/hiro/cpp/streaks/
**Keywords:** streaks, hiro
**Categories:** hiro, cpp, streaks

---


# Streaks

Read more about the Streak system in Hiro [here](../../concepts/streaks/).

## Listing streaks

You can list the current streaks for the user:

```cpp
void onStreaksList(const Hiro::StreaksList& streaksList)
{
    for (auto it = streaksList.streaks.name.begin(); it != streaksList.streaks.name.end(); it++)
    {
        std::cout << "Found streak: " << it->second.name << '\n';
    }
}

void onError(const Nakama::NError& error)
{
    std::cout << Nakama::toString(error.code) << ": " << error.message << '\n';
}

hiroClient->streaksList(session, onStreaksList, onError);
```

## Claiming Streaks Rewards

Players can claim streak rewards using the `streaksClaim` method, passing the streak IDs.

```cpp
void onStreaksClaim(const Hiro::StreaksList& streaksList)
{
    for (auto it = streaksList.streaks.name.begin(); it != streaksList.streaks.name.end(); it++)
    {
        std::cout << "Found streak: " << it->second.name << '\n';
    }
}

void onError(const Nakama::NError& error)
{
    std::cout << Nakama::toString(error.code) << ": " << error.message << '\n';
}

Hiro::StreaksClaimRequest request;
request.ids.push_back("daily_login");

hiroClient->streaksClaim(session, request, onStreaksClaim, onError);
```

## Resetting Streaks

To reset specific streaks for a player, use the `streaksReset` method:

```cpp
void onStreaksReset(const Hiro::StreaksList& streaksList)
{
    for (auto it = streaksList.streaks.name.begin(); it != streaksList.streaks.name.end(); it++)
    {
        std::cout << "Found streak: " << it->second.name << '\n';
    }
}

void onError(const Nakama::NError& error)
{
    std::cout << Nakama::toString(error.code) << ": " << error.message << '\n';
}

Hiro::StreaksResetRequest request;
request.ids.push_back("daily_login");

hiroClient->streaksReset(session, request, onStreaksReset, onError);
```

## Updating Streaks

You can manually update streaks for a player by passing a dictionary of streak names and new values:

```cpp
void onStreaksUpdate(const Hiro::StreaksList& streaksList)
{
    for (auto it = streaksList.streaks.name.begin(); it != streaksList.streaks.name.end(); it++)
    {
        std::cout << "Found streak: " << it->second.name << '\n';
    }
}

void onError(const Nakama::NError& error)
{
    std::cout << Nakama::toString(error.code) << ": " << error.message << '\n';
}

Hiro::StreaksUpdateRequest request;
request.ids.insert(std::make_pair<std::string, std::string>("daily_login", "1"));

hiroClient->streaksUpdate(session, request, onStreaksUpdate, onError);
```
