33Welcome to the tip.cc API Client npm package!
44
55# Installation
6+
67Simply create an npm project if you don't have an already, and install the package.
8+
79```
810npm init
911npm i tipcc.js
1012```
1113
1214# Getting Started
15+
1316> Tip: Want to get started without an introduction? Check out our [ documentation] ( https://tipccjs.org/ ) .
1417
1518You can create a simple TipccClient like this:
19+
1620``` js
1721import { TipccClient } from ' tipcc.js' ;
1822
1923const client = TipccClient (myToken);
2024
2125client .on (' ready' , () => {
22- console .log (' TipccClient is ready!' )
26+ console .log (' TipccClient is ready!' );
2327});
2428```
29+
2530` myToken ` is your tip.cc API key.
2631
2732## A note on API values
33+
2834The tip.cc API uses the smallest denomination of currencies, giving values in atomic units.
2935For an explanation of how this works, use [ Ethereum's wei] ( https://www.investopedia.com/terms/w/wei.asp ) as an example.
3036
@@ -33,6 +39,7 @@ tipcc.js uses the bignumber.js package to handle these numbers, and our API will
3339For a in-depth explanation of BigNumbers and available features, check their own [ documentation] ( https://mikemcl.github.io/bignumber.js/ ) .
3440
3541## Wallets
42+
3643To get your balance on tip.cc, use the [ WalletManager] ( https://tipccjs.org/classes/WalletManager ) :
3744
3845``` js
@@ -42,13 +49,16 @@ client.on('ready', async () => {
4249 return console .log (' No BNB wallet found. Have you received any BNB?' );
4350 }
4451
45- console .log (` We've got ${ wallet .balance .value } ${ wallet .code } on our BNB wallet` );
52+ console .log (
53+ ` We've got ${ wallet .balance .value } ${ wallet .code } on our BNB wallet` ,
54+ );
4655
4756 console .log (` This is approximately ${ wallet .balance .usdValue } USD` );
4857});
4958```
5059
5160## Transactions
61+
5262To receive transactions as events, use [ TransactionManager] ( https://tipccjs.org/classes/TransactionManager ) 's events:
5363
5464``` js
@@ -62,14 +72,19 @@ client.transactions.on('tip', (transaction) => {
6272```
6373
6474You can also get a single or many transactions by id:
75+
6576``` js
6677client .on (' ready' , async () => {
6778 const oneTransaction = await client .transactions .fetch (' one-id' );
68- const manyTransactions = await client .transactions .fetchMany ([' this-id' , ' another-id' ]);
79+ const manyTransactions = await client .transactions .fetchMany ([
80+ ' this-id' ,
81+ ' another-id' ,
82+ ]);
6983});
7084```
7185
7286Getting transactions based on a filter is also possible:
87+
7388``` js
7489client .on (' ready' , async () => {
7590 const transactionsByFilter = await client .transactions .fetchAll ({
@@ -83,6 +98,7 @@ Using no filter will get all transactions for the bot/user.
8398This is not recommended, unless you know what you're doing.
8499
85100## Exchange rates
101+
86102Use the [ ExchangeRateCache] ( https://tipccjs.org/classes/ExchangeRateCache ) to get exchange rates:
87103
88104``` js
@@ -97,6 +113,7 @@ client.on('ready', async () => {
97113` ` `
98114
99115This is also accessible on other structures, such as wallets:
116+
100117` ` ` js
101118client.on('ready', async () => {
102119 const wallet = await client.wallets.fetch('BTC');
@@ -109,11 +126,13 @@ client.on('ready', async () => {
109126` ` `
110127
111128## Currencies
129+
112130The client provides caches for cryptocurrencies ([CryptocurrencyCache](https: // tipccjs.org/classes/CryptocurrencyCache)) and fiats ([FiatCache](https://tipccjs.org/classes/FiatCache)).
113131
114132This may be useful when you need some basic information about a currency.
115133
116134Getting a cryptocurrency:
135+
117136` ` ` js
118137client.on('ready', async () => {
119138 const btc = client.cryptos.get('BTC');
@@ -127,6 +146,7 @@ client.on('ready', async () => {
127146` ` `
128147
129148Getting a fiat:
149+
130150` ` ` js
131151client.on('ready', async () => {
132152 const usd = client.fiats.get('USD');
@@ -140,14 +160,17 @@ client.on('ready', async () => {
140160```
141161
142162## Exploring
163+
143164Feel free to check out our [documentation](https://tipccjs.org/) to learn about our API and how you can use it.
144165
145166Notice that the examples above are bits of code separated from each other.
146167You can often use provided properties to get your task done with fewer lines of code by combining the structures explained.
147168
148169# License
170+
149171This project is licensed under the [MIT License](https://github.com/tipccjs/tipcc.js/blob/main/LICENSE).
150172
151173# Disclaimer
174+
152175The authors of this package are not the authors of [tip.cc](https://tip.cc).
153176We are not responsible for any loss of funds caused by incorrect usage, bugs, exploits, or other causes when using this package.
0 commit comments