118 lines
1.9 KiB
Markdown
118 lines
1.9 KiB
Markdown
## Web2 Client (through HTTP API)
|
||
|
||
### API Public Endpoints
|
||
|
||
```text
|
||
https://music-gateway.letsw.app
|
||
– /api/v1
|
||
```
|
||
|
||
### Telegram WebApp Authorization
|
||
|
||
[Implementation](../app/api/routes/auth.py)
|
||
|
||
#### Request (POST, /api/v1/auth.twa, JSON)
|
||
|
||
```javascript
|
||
{
|
||
twa_data: window.Telegram.WebApp.initData
|
||
}
|
||
```
|
||
|
||
#### Response (JSON)
|
||
|
||
```javascript
|
||
{
|
||
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](../app/api/routes/node_storage.py)
|
||
|
||
#### Request (POST, /api/v1/storage, FormData)
|
||
|
||
```javascript
|
||
{
|
||
file: File
|
||
}
|
||
```
|
||
|
||
#### Response (JSON)
|
||
|
||
```javascript
|
||
{
|
||
content_sha256: string,
|
||
content_id_v1: string,
|
||
content_url: string
|
||
}
|
||
```
|
||
|
||
### Download file
|
||
|
||
[Implementation](../app/api/routes/node_storage.py)
|
||
|
||
#### Request (GET, /api/v1/storage/:content_id)
|
||
|
||
#### Response (File)
|
||
|
||
### Create new content
|
||
|
||
[Implementation](../app/api/routes/blockchain.py)
|
||
|
||
#### Request (POST, /api/v1/blockchain.sendNewContentMessage, JSON)
|
||
|
||
```javascript
|
||
{
|
||
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)
|
||
|
||
```javascript
|
||
{
|
||
message: "Transaction requested"
|
||
}
|
||
```
|
||
|
||
### Purchase content
|
||
|
||
[Implementation](../app/api/routes/blockchain.py)
|
||
|
||
#### Request (POST, /api/v1/blockchain.sendPurchaseContentMessage, JSON)
|
||
|
||
```javascript
|
||
{
|
||
content_address: string,
|
||
price: string // nanoTON bignum
|
||
}
|
||
```
|
||
|
||
#### Response (JSON)
|
||
|
||
```javascript
|
||
{
|
||
message: "Transaction requested"
|
||
}
|
||
``` |