An API Client to interact with the api at https://vitamin.tips
TypeScript
Client
import{Client}from"vitabot-api"constclient=newClient("Your api key from vitamin.tips")consttoken1=awaitclient.getToken("VITC")consttoken2=awaitclient.getToken("VITC-000")consttoken3=awaitclient.getToken("BAN-001")constamount1=awaitclient.parseAmount("1 vitc")constamount2=awaitclient.parseAmount("$10 vitc")constamount3=awaitclient.parseAmount("129k VITE")// in a discord botconstrecipient=awaitclient.getDiscordUserAddress(message.author.id)constuser_id=awaitclient.resolveDiscordUserFromAddress(recipient)// Bank APIconstaddresses=awaitclient.getAddresses()constbalances=awaitclient.getBalances()constbalance1=awaitclient.getBalance(index)constbalance1=awaitclient.getBalance("vite_xxxxxx")constaddress=awaitclient.newAddress()consttransaction=awaitclient.sendTransaction({from: addresses[0].address,to: recipient,amount: amount1.amount,token_id: amount1.token_id})
Discord Faucet Example
importDiscordfrom"discord.js"importVitaBotfrom"vitabot-api"constclient=newDiscord.Client()constvitabot=newVitaBot.Client("Your api key from vitamin.tips")constamount=awaitvitabot.parseAmount("1 vite")client.on("message",asyncmessage=>{if(message.content==="!faucet"){constaddresses=awaitvitabot.getAddresses()constrecipient=awaitvitabot.getDiscordUserAddress(message.author.id)consttransaction=awaitvitabot.sendTransaction({from: addresses[0].address,to: recipient,amount: amount.amount,token_id: amount.token_id})awaitmessage.reply(`Sent ${amount.amount_display}${amount.currency} to ${recipient}`)}})awaitclient.login("Your discord bot token")
WebHooks
importexpressfrom"express"import{makeWebhookMiddleware}from"vitabot-api"express().post("/",makeWebhookMiddleware(data=>{// save data.nonce somewhere// verify it hasn't been used before// if it has, return// this prevents replay attacksconsole.log(data)// do something with it})).listen(1337)