Skip to content

Instantly share code, notes, and snippets.

@supercede
Last active November 17, 2024 16:54
Show Gist options
  • Save supercede/3ad684a2526c0ffa0970f0eafe50ca85 to your computer and use it in GitHub Desktop.
Save supercede/3ad684a2526c0ffa0970f0eafe50ca85 to your computer and use it in GitHub Desktop.

API Documentation

Routes are prefixed with /api

Authentication

Get JWT Token

Endpoint: GET /auth/:telegramId

Description: Retrieves a JWT token for the user.

Parameters:

telegramId

(path) - The Telegram ID of the user.

Responses:

  • 200 OK - Returns the JWT token.

400 Bad Request

  • If something goes wrong.

Wagers

Create Wager

Endpoint: POST /wagers

Description: Creates a new wager.

Request Body:

title

(string) - The title of the wager.

description

(string, optional) - The description of the wager.

creatorId

(string) - The ID of the creator.

opponentId

(string, optional) - The ID of the opponent.

isPublic

(boolean) - Whether the wager is public.

amount

(number) - The amount of the wager.

category

(string) - The category of the wager.

currencyId

(string) - The currency ID.

expires_on

(date) - The expiry date of the wager.

Responses:

  • 201 Created - Returns the created wager.

400 Bad Request

  • If validation fails.

Get All Wagers

Endpoint: GET /wagers

Description: Retrieves all wagers.

Responses:

  • 200 OK - Returns a list of wagers.

400 Bad Request

  • If something goes wrong.

Get Wager By ID

Endpoint: GET /wagers/:wagerId

Description: Retrieves a wager by its ID.

Parameters:

wagerId

(path) - The ID of the wager.

Responses:

  • 200 OK - Returns the wager.

400 Bad Request

  • If something goes wrong.

Join Wager

Endpoint: PATCH /wagers/:code/join

Description: Joins a wager using a code.

Parameters:

code

(path) - The code of the wager.

Responses:

  • 200 OK - Returns the joined wager.

400 Bad Request

  • If something goes wrong.

Get Wager Categories

Endpoint: GET /wagers/categories

Description: Retrieves all wager categories.

Responses:

  • 200 OK - Returns a list of wager categories.

Get Wagers By User ID

Endpoint: GET /wagers/user

Description: Retrieves all wagers for a user.

Responses:

  • 200 OK - Returns a list of wagers for the user.

400 Bad Request

  • If something goes wrong.

Wager Templates

Create Wager Template

Endpoint: POST /wager-template

Description: Creates a new wager template.

Request Body:

title

(string) - The title of the template.

description

(string) - The description of the template.

image

(file) - The image for the template.

creatorId

(string) - The ID of the creator.

wagerData

(object) - The wager data.

Responses:

  • 201 Created - Returns the created template.

400 Bad Request

  • If validation fails.

Get All Wager Templates

Endpoint: GET /wager-template

Description: Retrieves all wager templates.

Responses:

  • 200 OK - Returns a list of wager templates.

400 Bad Request

  • If something goes wrong.

Payments

Handle Deposit

Endpoint: POST /payments/deposit

Description: Handles a deposit.

Request Body:

amount

(number) - The amount to deposit.

asset

(string) - The asset to deposit.

Responses:

  • 201 Created - Returns the created invoice.

400 Bad Request

  • If validation fails.

Crypto Bot Webhook

Endpoint: POST /payments/crypto-bot-webhook

Description: Handles Crypto Bot webhook events.

Responses:

  • 200 OK - If the webhook is handled successfully.

400 Bad Request

  • If something goes wrong.

Wallets

Create Wallet

Endpoint: POST /wallets

Description: Creates a new wallet.

Request Body:

currencyId

(string) - The currency ID.

Responses:

  • 201 Created - Returns the created wallet.

400 Bad Request

  • If validation fails.

Get User Wallets

Endpoint: GET /wallets

Description: Retrieves all wallets for a user.

Responses:

  • 200 OK - Returns a list of wallets for the user.

400 Bad Request

  • If something goes wrong.

Get User Currency Wallet

Endpoint: GET /wallets/:currencyId

Description: Retrieves a wallet for a user by currency ID.

Parameters:

currencyId

(path) - The currency ID.

Responses:

  • 200 OK - Returns the wallet.

400 Bad Request

  • If something goes wrong.

Results

Create Result

Endpoint: POST /result

Description: Creates a new result.

Request Body:

wagerId

(string) - The ID of the wager.

winnerId

(string, optional) - The ID of the winner.

creatorConfirmed

(boolean) - Whether the creator confirmed.

joinerConfirmed

(boolean) - Whether the joiner confirmed.

status

(string) - The status of the result.

evidenceFiles

(array) - The evidence files.

evidenceLinks

(array) - The evidence links.

disputedBy

(string, optional) - The ID of the user who disputed.

disputeReason

(string, optional) - The reason for the dispute.

adminNotes

(string, optional) - The admin notes.

Responses:

  • 201 Created - Returns the created result.

400 Bad Request

  • If validation fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment