An unofficial Blockman GO API wrapper for Python.
Install · Quick start · Common calls · Docs · Discord
BGApi is an unofficial Blockman GO API wrapper for Python, also written Blockmango. It handles login and request signing, then gives you typed helpers for profiles, clans, games, leaderboards, social snapshots, and RongCloud group chat. Sync and async variants are included. It is built for scripts, bots, and small tools that want a predictable Python client instead of copied request code.
Targets Blockman GO 3.31.1. The API is private and can change without notice. This project is not affiliated with Sandbox Network or GVERSE.
The import package is bgapi_client and the PyPI distribution is
bgapi-client. Both use the qualified name because bgapi is already used by
an unrelated PyPI package and Python module.
From a checkout:
git clone https://github.com/quefeps/bgapi.git
cd bgapi
python -m pip install -e ".[all]"Optional features stay out of the base install:
python -m pip install -e ".[async]" # httpx, for async_* methods
python -m pip install -e ".[social]" # websocket-client, for RongCloud chatWhen a PyPI release is available, the same extras apply to that distribution:
python -m pip install bgapi-client
python -m pip install "bgapi-client[all]"BGApi reads the same BMG_* variables as the original wrapper. Copy the
example file and fill in the device values from your own app installation:
cp .env.example .env
python tools/get_device_values.py --waydroid --output-env .envThen log in:
from bgapi_client import BmgAccount
account = BmgAccount.from_env()
try:
if not account.login():
raise SystemExit(f"login failed (code {account.last_login_code})")
print(account.uid, account.region)
print(account.get_own_profile())
finally:
account.close()login() only signs in. It does not fetch friends or groups and does not
start a background thread. That keeps profile and leaderboard scripts cheap.
Using the account from the quick start:
rows = account.ranking.get_game_leaderboard_entries(
"g1019", period="week", page=0, size=10
)
for row in rows:
print(row.rank, row.nick_name, row.score, row.display_value)
player = account.user.lookup(123456789)
if player:
print(player.nick_name, player.clan_name)
clan = account.clan.get_info(clan_id=12345)Use account.request() for an endpoint that does not have a typed helper:
response = account.request(
"GET",
"/game/api/v1/games/g1019/rank",
params={"type": "all", "pageNo": 0, "pageSize": 10},
)Friend and group snapshots are opt-in. Load them when you need them:
account.login()
account.initialize_social(start=True, interval=60)
print(account.social.groups)
print(account.social.friends)For a one-shot snapshot with no polling thread:
account.initialize_social(start=False)Group chat uses RongCloud and needs the social extra:
group = account.group.list_all_groups()[0]
result = account.group.send_text(group.group_id, "Hello group!")
print(result.message_uid)Incoming messages are supported through account.group.listen(...). See
Social and chat for filters, async callbacks, and
transport details.
Install the async extra and use the async_* methods:
import asyncio
from bgapi_client import BmgAccount
async def main():
account = BmgAccount.from_env()
try:
if not await account.async_login():
raise SystemExit("login failed")
rows = await account.ranking.async_get_game_leaderboard_entries(
"g1019", period="all", page=0, size=5
)
print(len(rows))
finally:
await account.async_close()
asyncio.run(main())Typed modules cover the wrapped parts of the Blockman GO API.
| Module | What it covers |
|---|---|
account.user |
Profiles, settings, VIP, feedback |
account.friends |
Friends, requests, aliases, blocklist |
account.clan |
Clans, members, applications, donations |
account.ranking |
Global, game, gold, diamond, and clan leaderboards |
account.game |
Catalogue, details, auth, rooms, revisions |
account.group |
Group discovery, membership, sending, listening |
account.social |
Cached friend and group snapshots with diffs |
account.mailbox |
Mail and CD-key redemption |
account.shop |
Shop data |
account.backpack |
Backpack and mining balances |
account.pay |
Payment and Xsolla data |
account.activity |
Home page, events, ads, red packets |
account.remote_config |
Remote configuration resources |
account.extended |
Additional 3.31.x endpoints |
The full method index is in API reference.
| Guide | Use it for |
|---|---|
| Authentication | Device values, signing, tokens, sessions |
| API overview | Module map, raw requests, errors |
| API reference | Generated method and endpoint index |
| Leaderboards | Periods, pagination, score handling |
| Social and chat | Snapshots, polling, RongCloud transport |
| Game IDs | Known IDs and lookup tips |
- Keep
.env,.sessions.json, tokens, and device values private. - The repository ignores local config, session files, and the
local/worktree. python tools/check_pii.pychecks the current commit identity and scans tracked text for personal data before you push.- Use
account.close()or a context manager so sessions are released. - Only call mutating methods such as
buy,claim,send_text,join, ordelete_*when you understand their effect on a live account.
Questions, update posts, and examples: Discord. For bugs and feature requests, open an issue on GitHub.
Read CONTRIBUTING.md for the tone, personal-data, and review rules. Run the checks before opening a pull request:
python -m unittest discover -s tests -v
ruff check .
python tools/check_pii.pymake check runs the same commands if make is installed.
MIT. See LICENSE.
