mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-11 00:05:49 +00:00
* Fix `getOrderbook` (Fix #766) * Add `formatBidsAndAsks` as a recommended alternative to `getOrderbook` * Add `renameCounterpartyToIssuer`
35 lines
1.3 KiB
Plaintext
35 lines
1.3 KiB
Plaintext
## getOrderbook
|
|
|
|
`getOrderbook(address: string, orderbook: object, options: object): Promise<object>`
|
|
|
|
Returns open orders for the specified account. Open orders are orders that have not yet been fully executed and are still in the order book.
|
|
|
|
**Breaking change:** In ripple-lib 1.1.0 and earlier, orders returned by this method were not sorted correctly. Orders are now sorted correctly, from best to worst.
|
|
|
|
**See also:** An alternative way to get orderbooks is with `request` and [`formatBidsAndAsks`](#formatbidsandasks).
|
|
|
|
### Parameters
|
|
|
|
<%- renderSchema('input/get-orderbook.json') %>
|
|
|
|
### Return Value
|
|
|
|
This method returns a promise that resolves with an object with the following structure (Note: the structures of `bids` and `asks` are identical):
|
|
|
|
<%- renderSchema('output/get-orderbook.json') %>
|
|
|
|
**Raw order data:** The response includes a `data` property containing the raw order data. This may include `owner_funds`, `Flags`, and other fields.
|
|
|
|
For details, see the rippled method [book_offers](https://ripple.com/build/rippled-apis/#book-offers).
|
|
|
|
### Example
|
|
|
|
```javascript
|
|
const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';
|
|
const orderbook = <%- importFile('test/fixtures/requests/get-orderbook.json') %>;
|
|
return api.getOrderbook(address, orderbook)
|
|
.then(orderbook => {/* ... */});
|
|
```
|
|
|
|
<%- renderFixture('responses/get-orderbook.json') %>
|