Skip to content

Commit

Permalink
feat: remove old state endpoint add getTicker method
Browse files Browse the repository at this point in the history
  • Loading branch information
vafanassieff committed Dec 8, 2021
1 parent ca40e41 commit 44118c0
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 19 deletions.
35 changes: 24 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ All you have to do now is to instanciate a `LNMarketsRest` object this way:
```JS
const { LNMarketsRest } = require('@ln-markets/api')
const lnm = new LNMarketsRest()
const info = await lnm.nodeState()
const info = await lnm.appNode()
```

After this, you'll be able to use all the documented `API` methods below.
Expand All @@ -195,6 +195,7 @@ These methods are designed to fill the gaps if the API evolves and the future bu

### Methods

- [`futuresGetTicker`](#futuresGetTicker)
- [`futuresNewPosition`](#futuresNewPosition)
- [`futuresGetPositions`](#futuresGetPositions)
- [`futuresUpdatePosition`](#futuresUpdatePosition)
Expand All @@ -214,12 +215,24 @@ These methods are designed to fill the gaps if the API evolves and the future bu
- [`getAnnouncements`](#getAnnouncements)
- [`getLeaderboard`](#getLeaderboard)
- [`getUser`](#getUser)
- [`apiState`](#apiState)
- [`nodeState`](#nodeState)
- [`appConfiguration`](#appConfiguration)
- [`appNode`](#appNode)
- [`updateUser`](#updateUser)
- [`withdraw`](#withdraw)
- [`withdrawHistory`](#withdrawHistory)

#### futuresGetTicker

Get the ticker of LN Markets

Example:

```JS
await lnm.futuresGetTicker()
```

[`GET /futures/ticker`](https://docs.lnmarkets.com/api/v1/#ticker) documentation for more details.

#### futuresNewPosition

Open a new position on the market.
Expand Down Expand Up @@ -640,7 +653,7 @@ Example:
await lnm.getAnnouncements()
```

[`GET /state/announcemenets`](https://docs.lnmarkets.com/api/v1/#get-the-ln-markets-announcements) documentation for more details.
[`GET /app/announcemenets`](https://docs.lnmarkets.com/api/v1/#get-the-ln-markets-announcements) documentation for more details.

#### getLeaderboard

Expand Down Expand Up @@ -674,9 +687,9 @@ Example:

[`GET /user`](https://docs.lnmarkets.com/api/v1/#informations) documentation for more details.

#### apiState
#### appConfiguration

Retrieve informations related to LN Markets lnm.
Retrieve informations related to LN Markets.

```yaml
# No parameters
Expand All @@ -685,12 +698,12 @@ Retrieve informations related to LN Markets lnm.
Example:

```JS
await lnm.apiState()
await lnm.appConfiguration()
```

[`GET /state`](https://docs.lnmarkets.com/api/v1/#api-informations) documentation for more details.
[`GET /app/configuration`](https://docs.lnmarkets.com/api/v1/#api-informations) documentation for more details.

#### nodeState
#### appNode

Show informations about LN Markets lightning node.

Expand All @@ -701,10 +714,10 @@ Show informations about LN Markets lightning node.
Example:

```JS
await lnm.nodeState()
await lnm.appNode()
```

[`GET /state/node`](https://docs.lnmarkets.com/api/v1/#node-informations) documentation for more details.
[`GET /app/node`](https://docs.lnmarkets.com/api/v1/#node-informations) documentation for more details.

#### updateUser

Expand Down
2 changes: 1 addition & 1 deletion examples/rest/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ const { LNMarketsRest } = require('../../index.js')

;(async () => {
const lnm = new LNMarketsRest()
const info = await lnm.nodeState()
const info = await lnm.futuresGetTicker()
console.log(info)
})()
20 changes: 15 additions & 5 deletions src/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,16 @@ module.exports = class LNMarketsRest {
return this.requestAPI(options)
}

futuresGetTicker(params = {}) {
const options = {
method: 'GET',
path: '/futures/ticker',
params,
}

return this.beforeRequestApi(options)
}

futuresNewPosition(params) {
const options = {
method: 'POST',
Expand Down Expand Up @@ -378,19 +388,19 @@ module.exports = class LNMarketsRest {
return this.beforeRequestApi(options)
}

apiState() {
appConfiguration() {
const options = {
method: 'GET',
path: '/state',
path: '/app/configuration',
}

return this.beforeRequestApi(options)
}

nodeState() {
appNode() {
const options = {
method: 'GET',
path: '/state/node',
path: '/app/node',
}

return this.beforeRequestApi(options)
Expand All @@ -408,7 +418,7 @@ module.exports = class LNMarketsRest {
getAnnouncements() {
const options = {
method: 'GET',
path: '/state/announcements',
path: '/app/announcements',
}

return this.beforeRequestApi(options)
Expand Down
4 changes: 2 additions & 2 deletions test/rest/basics.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = () => {

const lnm = new LNMarketsRest()

lnm.nodeState().catch((error) => {
lnm.appNode().catch((error) => {
expect(error).to.be.instanceOf(Error)
expect(error.message).to.be.equal(
'getaddrinfo ENOTFOUND api.lnmarkets.lol'
Expand Down Expand Up @@ -74,7 +74,7 @@ module.exports = () => {

it('Good request', async () => {
const lnm = new LNMarketsRest()
const info = await lnm.nodeState()
const info = await lnm.appNode()
expect(info).to.be.an('object')
})

Expand Down

0 comments on commit 44118c0

Please sign in to comment.