Overview #

This quickstart guides you through:

It is intended for developers who want to integrate the Hiro Python client into their applications. It assumes that you have basic knowledge of:

  • Python programming
  • Dependency management with pip
  • Environment variables

Installation #

Requirements #

  • Python 3.8+ (tested on Python 3.8.1 and 3.12.4)
  • pip package manager
  • Obtain access to the Python client from Heroic Labs. Contact us if you don’t have access yet.

Install Dependencies #

Install the required dependencies using pip in the directory that contains pyproject.toml:

1
pip install .

Usage #

Once you have the client and have followed the installation steps, you can import the Hiro and Nakama libraries to the project:

1
2
from hiro_gdk.nakama_client import NakamaClient, NakamaError
from hiro_gdk.hiro_client import HiroClient

For this guide we will also be using:

1
2
3
4
5
6
7
import os
import sys
import asyncio
import logging
import uuid

from dotenv import load_dotenv

Set up the Nakama client:

1
2
3
4
server_key = os.environ.get("NAKAMA_SERVER_KEY", "defaultkey")
host = os.environ.get("NAKAMA_HOST", "127.0.0.1")
port = int(os.environ.get("NAKAMA_PORT", "7350"))
nakama_client = NakamaClient(host=host, port=port, ssl=False, server_key=server_key)

Authenticate the user:

1
2
3
4
first_device_id = f"basic_usage-first-device-{uuid.uuid4().hex[:8]}"
first_username = f"basic_usage-first_user-{uuid.uuid4().hex[:8]}"
print(f"🔑 Authenticating second device ID: {first_device_id}...")
session1 = await nakama_client.authenticate_device(first_device_id, create=True, username=first_username)

Create the Hiro client:

1
hiro_client = HiroClient(nakama_client)

Next Steps #

Now that you’ve completed this getting started, explore these resources to learn more about the Hiro Python client and Nakama server integration: