1.2.0 • Published 2 years ago

tonrocket-api-sdk v1.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

SDK для работы с TON Rocket

⚙️ Установка

npm install tonrocket-api-sdk --save

🔐 Авторизация

Как получить токен написано тут.

const { RocketApi, Assets } = require('tonrocket-api-sdk')

const api = new RocketApi('токен')

Вы так же можете использовать testnet

const api = new RocketApi('токен', {
    testnet: true
})

⬇️ Навигация

🚀 Методы

- getAppInfo
- transfer
- withdrawal
- createCheque
- getCheques
- getCheque
- editCheque
- deleteCheque
- createInvoice
- getInvoices
- getInvoice
- deleteInvoice
- getCoins
- getCurrencies

💬 Вебхуки

🌴 Константы

- Assets

🚀 Методы

Параметры отмеченные знаком * являются обзательными

getAppInfo

Документация | Параметр | Информация | |---------|-------------| | Не принимает параметров |

Пример:

const appInfo = await api.getAppInfo()

transfer

Документация | Параметр | Информация | |---------|-------------| | tgUserId | ID получателя перевода | | amount | Сумма перевода | | currency | Валюта перевода. По умолчанию: "TONCOIN" | | transferId | По умолчанию: "12345" | | description | По умолчанию: "" |

Пример:

const transfer = await api.transfer({
  "tgUserId": 87209764,
  "currency": "TONCOIN",
  "amount": 1.23,
  "transferId": "abc-def",
  "description": "You are awesome!"
})

withdrawal

Документация | Параметр | Информация | |---------|-------------| | address | TON кошелек, на который нужно отправить монеты | | amount | Сумма перевода | | currency | Валюта для вывода. По умолчанию: "TONCOIN" | | withdrawalId | По умолчанию: "12345" | | comment | По умолчанию: "" |

Пример:

const withdrawal = await api.withdrawal({
  "address": "EQB1cmpxb3R-YLA3HLDV01Rx6OHpMQA_7MOglhqL2CwJx_dz",
  "currency": "TONCOIN",
  "amount": 1.23,
  "withdrawalId": "abc-def",
  "comment": "You are awesome!"
})

createCheque

Документация Все параметры как в документации

Пример:

const cheque = await api.createCheque({
  "chequePerUser": 0.005,
  "usersNumber": 100,
  "refProgram": 50,
  "password": "pwd",
  "description": "This cheque is the best",
  "sendNotifications": true,
  "enableCaptcha": true,
  "telegramResourcesIds": [
    "-1001799549067"
  ]
})

getCheques

Документация | Параметр | Информация | |---------|-------------| | Не принимает параметров |

Пример:

const cheques = await api.getCheques()

getCheque

Документация | Параметр | Информация | |---------|-------------| | id* | ID чека |

Пример:

const cheques = await api.getCheque({
  id: 1234
})

editCheque

Документация | Параметр | Информация | |---------|-------------| | id* | ID чека | | Всё остальное как в документации |

Пример:

const cheque = await api.editCheque({
  "id": 1234
  "password": "pwd",
  "description": "This cheque is the best",
  "sendNotifications": true,
  "enableCaptcha": true,
  "telegramResourcesIds": [
    "-1001799549067"
  ]
})

deleteCheque

Документация | Параметр | Информация | |---------|-------------| | id* | ID чека |

Пример:

const cheque = await api.deleteCheque({
  id: 1234
})

createInvoice

Документация Все параметры как в документации

Пример:

const invoice = await api.createInvoice({
  "amount": 1.23,
  "description": "best thing in the world, 1 item",
  "hiddenMessage": "thank you",
  "callbackUrl": "https://t.me/ton_rocket",
  "payload": "some custom payload I want to see in webhook or when I request invoice",
  "expiredIn": 10
})

getInvoices

Документация | Параметр | Информация | |---------|-------------| | Не принимает параметров |

Пример:

const invoices= await api.getInvoices()

getInvoice

Документация | Параметр | Информация | |---------|-------------| | id* | ID счёта |

Пример:

const invoice = await api.getInvoice({
  id: 1234
})

deleteInvoice

Документация | Параметр | Информация | |---------|-------------| | id* | ID счёта |

Пример:

const invoice = await api.deleteInvoice({
  id: 1234
})

getCoins

Документация | Параметр | Информация | |---------|-------------| | Не принимает параметров |

Пример:

const coins = await api.getCoins()

getCurrencies

Документация | Параметр | Информация | |---------|-------------| | coinFrom | ID токена | | coinTo | ID токена |

Пример:

const currencies = await api.getCurrencies({
  coinFrom: Assets.TON,
  coinTo: Assets.SCALE
})

💬 Вебхуки

С помощью нашей библиотеки вы можете установить вебхуки и получать уведомления о платежах.

ВНИМАНИЕ!!! Установить URL вебхука вам необходимо самостоятельно, в боте TON Rocket

Пример:

const { RocketApi, Assets } = require('tonrocket-api-sdk')

const api = new RocketApi('токен')

api.onTransfer((data) => console.log(data))
api.start({
    port: 3000,
    path: '/my-secret-path'
})

🌴 Константы

Assets

КонстантаЗначение
Assets.TON1
Assets.SCALE4
Assets.BOLT5
Assets.TEGRO6
Assets.SCAM7
1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago