ZooGames API Guide
  • Introduction
  • Quick Start
  • Wallet Concept
  • Game Settlement Concept
  • API Endpoint
  • Platform Fee
  • Faucet
  • API reference
    • Authentication
      • By ZooGamesID
      • By Instant PlayPass
    • Users
    • Users Status
    • Game Settlement
    • Game Trade
    • In-Game Chips Tokens (ERC20)
    • In-game NFTs (ERC721)
    • NFT Data
    • RNG Service
    • Oracle Service
    • Official NFTs
    • API change log
  • OPENSOURCE PROJECTS
    • ZooGames AUTH webapp for Telegram
    • 3D ZooGenes pack
Powered by GitBook
On this page
  • Please check out our Github:
  • Example of use case
  • Prerequisite
  • Flow of Authentication
  • BOT Code
  • ENV Structure of TESTNET
  • ENV Structure of MAINNET
Export as PDF
  1. OPENSOURCE PROJECTS

ZooGames AUTH webapp for Telegram

ZooGames’ revolutionary system simplifies gaming authentication

PreviousAPI change logNext3D ZooGenes pack

Last updated 1 year ago

The ZooGames WebApp code is also completely free and open-source, so developers can customize and integrate it into their games and apps without any extra cost or hassle.

In short, ZooGames’ revolutionary system simplifies gaming authentication and offers a secure and easy way to access your gaming data. So, why not give it a try and experience the future of web3 gaming authentication?

Please check out our Github:

Example of use case

Prerequisite

  1. The Vercel service can be used to host your WebAPP.

Flow of Authentication

The authentication flow involves the display of a login form on the WebApp. Upon successful connection to the right MongoDB and input of the user's Telegram ID, a JWT Token will be recorded as the following structure:

_id: 123456abcdefg
network: "testnet"
telegram_id: 123456789
dm_id: 123456789
mirror_address: "0x0000..."
primary_address: "0x0000..."
user_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImdlbnNoaW1hcm8iL…"
zoo_games_id: "myZooGamesID"

The user will also receive a direct message from the bot, containing their logged in Zoo.Games ID, Primary Address, and Mirror Address. If there are any errors, an alert will be displayed to prompt the user to fix it.

You can continue writing your BOT code to get TG user id, username and ZooGames JWT for further gameplay.

BOT Code

To call the Telegram Webapp, the sendMessage and sendPhoto APIs can be used with a reply markup of inline_keyboard. It is important to note that the Bot Menu should not be used to call the WebAPP, as it will not send a query of User Data to the WebAPP. The following environment variables structure can be used:

bot.sendMessage(msg.chat.id, 'Please click button below to login', {
    reply_markup: {
        one_time_keyboard: true,
        inline_keyboard: [
            [
                { text: "LOGIN", web_app: { url: process.env.WEBAPP + "/login" } },
            ],
        ]
    }
}

ENV Structure of TESTNET

#BOT AND DATABASE
BOT_TOKEN=
DB_URI = mongodb+srv://[Your Mongo crential and endpoint]/?retryWrites=true&w=majority
DB_NAME=MYGame
DB_COLLECTION_USERS=users

#ZOOGAMES
ZG_API_KEY=
ZG_SEC_KEY=
ZG_API_SERVER=https://api-test-serverless.vercel.app
ZG_GAME_ADDRESS=
ZG_APPROVE_AMOUNT=

#NETWORK CONFIGURATION
NETWORK=testnet
EXPLORER=https://testnet.wanscan.org/tx/

ENV Structure of MAINNET

#BOT AND DATABASE
BOT_TOKEN=
DB_URI = mongodb+srv://[Your Mongo crential and endpoint]/?retryWrites=true&w=majority
DB_NAME=MYGame
DB_COLLECTION_USERS=users

#ZOOGAMES
ZG_API_KEY=
ZG_SEC_KEY=
ZG_API_SERVER=https://api-beta.zoo.games
ZG_GAME_ADDRESS=
ZG_APPROVE_AMOUNT=

#NETWORK CONFIGURATION
NETWORK=mainnet
EXPLORER=https://www.wanscan.org/tx/

You can try accessing the ZooQuiz bot by going to and typing "/register" followed by clicking on "Login". This will bring up the Login WebAPP. You can then provide your ZooGamesID and 2FA token to log in and link your Telegram ID with your ZooGamesID.

MongoDB can be used to store session records for your game. You can sign up for a free account at to test your game.

For bot development using NodeJS stack, you can utilize "node-telegram-bot-api", which can be accessed at . ()

It is recommended to have some knowledge of Telegram BOT API, which can be found at , () as well as Telegram WebAPP at . ()

To obtain ZooGames API KEY and SECRET, you can request it through Telegram at (Zoo.Games Sub Topic).

https://t.me/ZooQuiz_bot
https://mongodb.com/
https://github.com/yagop/node-telegram-bot-api
https://github.com/yagop/node-telegram-bot-api
https://core.telegram.org/bots/api
https://core.telegram.org/bots/api
https://core.telegram.org/bots/webapps
https://core.telegram.org/bots/webapps
https://t.me/ZooEcosystem
GitHub - zoo-games/Generic-TG-WebAPP: WebAPP Authentication for Telegram BotGitHub
Logo