Last Updated: 6/15/2022, 1:51:10 AM

# Python SDK Getting Started Guide

# Overview

You can use the AccelByte Python SDK to implement our backend services within your game. The SDK acts as a bridge between your game and our services. Follow the tutorials below to learn how to set up our Python SDK.

# Prerequisites

# Additional Resources

# Tutorials

# Install the AccelByte Python SDK

You can install the SDK with pip directly from the GitHub repository, as seen below:

pip install git+ssh://git@github.com/AccelByte/accelbyte-python-sdk.git@master#egg=accelbyte_py_sdk

# Log in as a Client using the SDK

To log in as the client you created earlier, import the accelbyte_py_sdk, MyConfigRepository, and list the client’s Base URL, Client ID, Client Secret, and Namespace.

Next, initialize the python SDK and call token_grant_v3 with the grant type set as "client_credentials".

import accelbyte_py_sdk
from accelbyte_py_sdk.core import MyConfigRepository
from accelbyte_py_sdk.api.iam import token_grant_v3

config = MyConfigRepository(
    base_url="<your-base-url>",
    client_id="<your-client-id>",
    client_secret="<your-client-secret>",
    namespace="<your-namespace>",
)

accelbyte_py_sdk.initialize(
    options={
        "config":config,
    },
)

_, error = token_grant_v3(grant_type="client_credentials")
if error:
    print(error)

NOTE

You can also paste in configuration by replacing MyConfigRepository(...) with the following value.

  • If your configuration data is in a JSON file, replace it with JsonFileConfigRepository("path/to/the/config/file.json")
  • If your configuration data is set as Environment Variables (AB_BASE_URL, AB_CLIENT_ID, AB_CLIENT_SECRET, AB_NAMESPACE, etc.), replace it with EnvironmentConfigRepository(...)

# Import AccelByte Services

Now you can start using any of the following AccelByte services in your application, by importing the following syntax to your code. See the model for each service below or in the how-to (opens new window) folder inside the accelbyte-python-sdk (opens new window) repository.

# SDK Examples

See our Python SDK example repo (opens new window) for a selection of test cases you can use to customize your game.

IAM

API Docs (opens new window)

SDK reference (opens new window)

from accel_py_sdk.api.iam import *
from accelbyte_py_sdk.services.auth import *
Basic

API Docs (opens new window)

SDK reference (opens new window)

from accel_py_sdk.api.basic import *
Social

API Docs (opens new window)

SDK reference (opens new window)

from accel_py_sdk.api.social import *
Platform

API Docs (opens new window)

SDK reference (opens new window)

from accel_py_sdk.api.platform import *
Group

API Docs (opens new window)

SDK reference (opens new window)

from accel_py_sdk.api.group import *
Cloud Save

API Docs (opens new window)

SDK reference (opens new window)

from accel_py_sdk.api.cloudsave import *
DSM Controller

API Docs (opens new window)

SDK reference (opens new window)

from accel_py_sdk.api.dsm_controller import *
Session Browser

API Docs (opens new window)

SDK reference (opens new window)

from accel_py_sdk.api.session_browser import *
Lobby

API Docs (opens new window)

SDK reference (opens new window)

from accel_py_sdk.api.lobby import *
Telemetry

API Docs (opens new window)

SDK reference (opens new window)

from accel_py_sdk.api.amalgam_game_telemetry import *