uploader-bot/docs/web2-client.md

1.9 KiB
Raw Blame History

Web2 Client (through HTTP API)

API Public Endpoints

https://music-gateway.letsw.app
     /api/v1

Telegram WebApp Authorization

Implementation

Request (POST, /api/v1/auth.twa, JSON)

{
    twa_data: window.Telegram.WebApp.initData
}

Response (JSON)

{
    user: { ...User },
    connected_wallet: null | {
        version: string,
        address: string,
        ton_balance: string // nanoTON bignum
    },
    auth_v1_token: string
}

Use auth_v1_token as Authorization header for all authorized requests.

Upload file

Implementation

Request (POST, /api/v1/storage, FormData)

{
    file: File
}

Response (JSON)

{
    content_sha256: string,
    content_id_v1: string,
    content_url: string
}

Download file

Implementation

Request (GET, /api/v1/storage/:content_id)

Response (File)

Create new content

Implementation

Request (POST, /api/v1/blockchain.sendNewContentMessage, JSON)

{
    title: string,
    authors: list,
    content: string, // recommended dmy://
    image: string, // recommended dmy://
    description: string,
    price: string, // nanoTON bignum
    resaleLicensePrice: string // nanoTON bignum (default = 0)
    allowResale: boolean,
    royaltyParams: [{
        address: string,
        value: number // 10000 = 100%
    }]
}

Response (JSON)

{
    message: "Transaction requested"
}

Purchase content

Implementation

Request (POST, /api/v1/blockchain.sendPurchaseContentMessage, JSON)

{
    content_address: string,
    price: string // nanoTON bignum
}

Response (JSON)

{
    message: "Transaction requested"
}