Add bisq.js readme.

This commit is contained in:
Miguel Medeiros 2021-08-10 12:38:33 -03:00
parent edab1ad3d5
commit efd0436851
2 changed files with 332 additions and 1 deletions

265
npm-bisq-js/README-bisq.md Normal file
View File

@ -0,0 +1,265 @@
# Bisq**JS** - Features
Interface to access the Bisq API.
[Back to home](./README.md)
---
## **Features**
- Addresses
- [Get Address](#get-address)
- Blocks
- [Get Block](#get-block)
- [Get Blocks](#get-blocks)
- [Get Block Tip Height](#get-block-tip-height)
- Markets
- [Get Currencies](#get-currencies)
- [Get Depth](#get-depth)
- [Get HLOC](#get-hloc)
- [Get Markets](#get-markets)
- [Get Offers](#get-offers)
- [Get Ticker](#get-ticker)
- [Get Trades](#get-trades)
- [Get Volumes](#get-volumes)
- Statistics
- [Get Statistics](#get-statistics)
- Transactions
- [Get Transaction](#get-transaction)
- [Get Transactions](#get-transactions)
---
### **Get Address**
Returns statistics about all Bisq transactions.
[ [NodeJS Example](../examples/nodejs/bisq-js/addresses.ts) ] [ [HTML Example](../examples/html/bisq-js/addresses.html) ] [ [Top](#features) ]
```js
const { addresses } = bisqJS();
const address = 'B1DgwRN92rdQ9xpEVCdXRfgeqGw9X4YtrZz';
const myAddress = await addresses.getAddress({ address });
console.log(myAddress);
```
### **Get Block**
Returns all Bisq transactions that exist in a Bitcoin block.
**Parameters:**
- {string} hash
[ [NodeJS Example](../examples/nodejs/bisq-js/blocks.ts) ] [ [HTML Example](../examples/html/bisq-js/blocks.html) ] [ [Top](#features) ]
```js
const { blocks } = bisqJS();
const hash = '000000000000000000079aa6bfa46eb8fc20474e8673d6e8a123b211236bf82d';
const block = await blocks.getBlock({ hash });
console.log(block);
```
### **Get Blocks**
Returns `:length` Bitcoin blocks that contain Bisq transactions, starting from `:index`.
**Parameters:**
- {number} index
- {number} length
[ [NodeJS Example](../examples/nodejs/bisq-js/blocks.ts) ] [ [HTML Example](../examples/html/bisq-js/blocks.html) ] [ [Top](#features) ]
```js
const { blocks } = bisqJS();
const hash = '000000000000000000079aa6bfa46eb8fc20474e8673d6e8a123b211236bf82d';
const myBlocks = await blocks.getBlocks({ index: 0, length: 1 });
console.log(myBlocks);
```
### **Get Blocks Tip Height**
Returns the most recently processed Bitcoin block height processed by Bisq.
[ [NodeJS Example](../examples/nodejs/bisq-js/blocks.ts) ] [ [HTML Example](../examples/html/bisq-js/blocks.html) ] [ [Top](#features) ]
```js
const { blocks } = bisqJS();
const myBlocksHeight = await blocks.getBlocksTipHeight({
index: 0,
length: 1,
});
console.log(myBlocksHeight);
```
### **Get Market Currencies**
Returns the Bisq market currencies.
[ [NodeJS Example](../examples/nodejs/bisq-js/markets.ts) ] [ [HTML Example](../examples/html/bisq-js/markets.html) ] [ [Top](#features) ]
```js
const { markets } = bisqJS();
const currencies = await markets.getCurrencies();
console.log(currencies);
```
### **Get Market Depth**
Returns the Bisq market depth.
**Parameters:**
- {string} market
[ [NodeJS Example](../examples/nodejs/bisq-js/markets.ts) ] [ [HTML Example](../examples/html/bisq-js/markets.html) ] [ [Top](#features) ]
```js
const { markets } = bisqJS();
const market = "BTC_USD";
const depth = await markets.getDepth({ market });
console.log(depth)
```
### **Get Market HLOC**
Returns the Bisq market Hloc.
**Parameters:**
- {string} market
[ [NodeJS Example](../examples/nodejs/bisq-js/markets.ts) ] [ [HTML Example](../examples/html/bisq-js/markets.html) ] [ [Top](#features) ]
```js
const { markets } = bisqJS();
const market = "BTC_USD";
const hloc = await markets.getHloc({ market });
console.log(hloc);
```
### **Get Market Offers**
Returns the Bisq market Offers.
**Parameters:**
- {string} market
[ [NodeJS Example](../examples/nodejs/bisq-js/markets.ts) ] [ [HTML Example](../examples/html/bisq-js/markets.html) ] [ [Top](#features) ]
```js
const { markets } = bisqJS();
const market = "BTC_USD";
const offers = await markets.getOffers({ market });
console.log(offers);
```
### **Get Market Ticker**
Returns the Bisq market Ticker.
**Parameters:**
- {string} market
[ [NodeJS Example](../examples/nodejs/bisq-js/markets.ts) ] [ [HTML Example](../examples/html/bisq-js/markets.html) ] [ [Top](#features) ]
```js
const { markets } = bisqJS();
const market = "BTC_USD";
const ticker = await markets.getTicker({ market });
console.log(ticker);
```
### **Get Market Trades**
Returns the Bisq market Trades.
**Parameters:**
- {string} market
[ [NodeJS Example](../examples/nodejs/bisq-js/markets.ts) ] [ [HTML Example](../examples/html/bisq-js/markets.html) ] [ [Top](#features) ]
```js
const { markets } = bisqJS();
const market = "BTC_USD";
const trades = await markets.getTrades({ market });
console.log(trades);
```
### **Get Market Volumes**
Returns the Bisq market Volumes.
**Parameters:**
- {string} market
[ [NodeJS Example](../examples/nodejs/bisq-js/markets.ts) ] [ [HTML Example](../examples/html/bisq-js/markets.html) ] [ [Top](#features) ]
```js
const { markets } = bisqJS();
const market = "BTC_USD";
const basecurrency = "BTC";
const volumes = await markets.getVolumes({ basecurrency, market });
console.log(volumes);
```
### **Get Stats**
Returns statistics about all Bisq transactions.
[ [NodeJS Example](../examples/nodejs/bisq-js/statistics.ts) ] [ [HTML Example](../examples/html/bisq-js/statistics.html) ] [ [Top](#features) ]
```js
const { statistics } = bisqJS();
const stats = await statistics.getStats();
console.log(stats);
```
### **Get Transaction**
Returns details about a Bisq transaction.
[ [NodeJS Example](../examples/nodejs/bisq-js/transactions.ts) ] [ [HTML Example](../examples/html/bisq-js/transactions.html) ] [ [Top](#features) ]
```js
const { transactions } = bisqJS();
const txid = '4b5417ec5ab6112bedf539c3b4f5a806ed539542d8b717e1c4470aa3180edce5';
const tx = await transactions.getTx({ txid });
console.log(tx);
```
### **Get Transactions**
Returns details about a Bisq transactions.
[ [NodeJS Example](../examples/nodejs/bisq-js/transactions.ts) ] [ [HTML Example](../examples/html/bisq-js/transactions.html) ] [ [Top](#features) ]
```js
const { transactions } = bisqJS();
const txs = await transactions.getTxs({ index: 0, length: 1 });
console.log(txs);
```

View File

@ -1 +1,67 @@
# Bisq JS API # Bisq**JS** API
[![npm version](https://img.shields.io/npm/v/@mempool/bisq.js.svg?style=flat-square)](https://www.npmjs.org/package/@mempool/bisq.js)
[![NPM](https://img.shields.io/david/mempool/bisq.js.svg?style=flat-square)](https://david-dm.org/mempool/bisq.js#info=dependencies)
[![Known Vulnerabilities](https://snyk.io/test/github/mempool/bisq.js/badge.svg?style=flat-square)](https://snyk.io/test/github/mempool/bisq.js)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
NPM package module for Bisq APIs.
Documentation: [https://bisq.markets/api](https://bisq.markets/api)
## **Installation**
### **ES Modules**
Install the npm module.
```bash
# npm
$ npm install @mempool/bisq.js --save
# yarn
$ yarn add @mempool/bisq.js
```
Or if you're not into package management, just [download a ZIP](https://github.com/mempool/mempool.js/archive/refs/heads/main.zip) file.
Import the module.
```js
import bisqJS from '@mempool/bisq.js';
const bisq = bisqJS();
```
### **CommonJS**
Include the line below in the `head` tag of your html file.
```html
<script type="text/javascript" src="https://bisq.markets/bisq.js"></script>
```
Call `bisqJS()` function to access the API methods.
```js
const bisq = bisqJS();
```
---
## **Features**
- [Addresses](./README-bisq.md#get-address)
- [Blocks](./README-bisq.md#get-blocks)
- [Markets](./README-bisq.md#get-markets)
- [Statistics](./README-bisq.md#get-statistics)
- [Transactions](./README-bisq.md#get-transactions)
---
## **Contributing**
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
---
## **License** [MIT](https://choosealicense.com/licenses/mit/)