Skip to content

Update V3 API #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file modified .DS_Store
Binary file not shown.
Binary file added node.js/.DS_Store
Binary file not shown.
33 changes: 13 additions & 20 deletions node.js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,24 @@ npm install
## RESTful APIs

```javascript
const Future = require('../../src/future')

const Spot = require('../src/spot')
const apiKey = ''
const apiSecret = ''
const client = new Future(apiKey, apiSecret, { baseURL: 'https://contract.mexc.com' })

client.PlaceNewOrder({
symbol:'IMX_USDT',
price: 0.1,
vol: 10,
side:1,
type:1,
openType:2
}).then(response => client.logger.log(response.data))
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })


client.CancelWithdraw().then(response => client.logger.log(response.data))
.catch(error => client.logger.error(error))
```

```javascript
const Spot = require('../src/spot')
const apiKey = ''
const apiSecret = ''
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })

const Future = require('../../src/future')

const client = new Future()

client.Ticker({symbol:'BTC_USDT'}).then(response => client.logger.log(response.data))
client.AccountInformation().then(response => client.logger.log(response.data))
.catch(error => client.logger.error(error))

```
Expand All @@ -40,11 +35,9 @@ Please find `modules` folder to check for more endpoints.


### Base URL
# V1
# Contract
`https://contract.mexc.com`
# V2
`https://www.mexc.com`
# V3
# spot
`https://api.mexc.com`

### Optional Parameters
Expand Down
Binary file added node.js/run/.DS_Store
Binary file not shown.
8 changes: 8 additions & 0 deletions node.js/run/Capital/ TransferInternalHistory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const Spot = require('../src/spot')
const apiKey = ''
const apiSecret = ''
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })


client.TransferInternalHistory().then(response => client.logger.log(response.data))
.catch(error => client.logger.error(error))
8 changes: 8 additions & 0 deletions node.js/run/Capital/CapitalConvert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const Spot = require('../src/spot')
const apiKey = ''
const apiSecret = ''
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })


client.CapitalConvert().then(response => client.logger.log(response.data))
.catch(error => client.logger.error(error))
8 changes: 8 additions & 0 deletions node.js/run/Capital/CapitalHistory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const Spot = require('../src/spot')
const apiKey = ''
const apiSecret = ''
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })


client.CapitalHistory().then(response => client.logger.log(response.data))
.catch(error => client.logger.error(error))
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const Spot = require('../src/spot')
const apiKey = ''
const apiSecret = ''
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })


client.Etfinfo().then(response => client.logger.log(response.data))
client.Capital().then(response => client.logger.log(response.data))
.catch(error => client.logger.error(error))
File renamed without changes.
8 changes: 8 additions & 0 deletions node.js/run/Capital/TransferHistoryId.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const Spot = require('../src/spot')
const apiKey = ''
const apiSecret = ''
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })


client.TransferHistoryId().then(response => client.logger.log(response.data))
.catch(error => client.logger.error(error))
8 changes: 8 additions & 0 deletions node.js/run/Capital/TransferInternal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const Spot = require('../src/spot')
const apiKey = ''
const apiSecret = ''
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })


client.TransferInternal().then(response => client.logger.log(response.data))
.catch(error => client.logger.error(error))
File renamed without changes.
4 changes: 2 additions & 2 deletions node.js/test/Market/24hr.js → node.js/run/Market/24hr.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Spot = require('../src/spot')
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })
const Spot = require('../../src/spot')
const client = new Spot({ baseURL: 'https://api.mexc.com' })


client.TickerPriceChange().then(response => client.logger.log(response.data))
Expand Down
6 changes: 6 additions & 0 deletions node.js/run/Market/AggTrades.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const Spot = require('../src/spot')
const client = new Spot({ baseURL: 'https://api.mexc.com' })


client.CompressedTradesList().then(response => client.logger.log(response.data))
.catch(error => client.logger.error(error))
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Spot = require('../src/spot')
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })
const client = new Spot( { baseURL: 'https://api.mexc.com' })


client.CurrentAveragePrice().then(response => client.logger.log(response.data))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Spot = require('../src/spot')
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })
const client = new Spot({ baseURL: 'https://api.mexc.com' })


client.SymbolOrderBook().then(response => client.logger.log(response.data))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Spot = require('../src/spot')
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })
const client = new Spot( { baseURL: 'https://api.mexc.com' })


client.ApiDefault().then(response => client.logger.log(response.data))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Spot = require('../src/spot')
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })
const client = new Spot( { baseURL: 'https://api.mexc.com' })


client.Depth().then(response => client.logger.log(response.data))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Spot = require('../src/spot')
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })
const client = new Spot({ baseURL: 'https://api.mexc.com' })


client.ExchangeInformation().then(response => client.logger.log(response.data))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Spot = require('../src/spot')
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })
const client = new Spot({ baseURL: 'https://api.mexc.com' })


client.Kline().then(response => client.logger.log(response.data))
Expand Down
6 changes: 6 additions & 0 deletions node.js/run/Market/Ping.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const Spot = require('../src/spot')
const client = new Spot({ baseURL: 'https://api.mexc.com' })


client.TestConnectivity().then(response => client.logger.log(response.data))
.catch(error => client.logger.error(error))
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Spot = require('../src/spot')
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })
const client = new Spot( { baseURL: 'https://api.mexc.com' })


client.SymbolPriceTicker().then(response => client.logger.log(response.data))
Expand Down
2 changes: 1 addition & 1 deletion node.js/test/Market/time.js → node.js/run/Market/Time.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Spot = require('../src/spot')
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })
const client = new Spot({ baseURL: 'https://api.mexc.com' })


client.Servertime().then(response => client.logger.log(response.data))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Spot = require('../src/spot')
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })
const client = new Spot({ baseURL: 'https://api.mexc.com' })


client.RecentTradesList().then(response => client.logger.log(response.data))
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions node.js/run/Subaccount/QueryAsset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const Spot = require('../src/spot')
const apiKey = ''
const apiSecret = ''
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })


client.GetAsset().then(response => client.logger.log(response.data))
.catch(error => client.logger.error(error))
File renamed without changes.
8 changes: 8 additions & 0 deletions node.js/run/Trade/ MxDeduct.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const Spot = require('../src/spot')
const apiKey = ''
const apiSecret = ''
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })


client.MxDeduct().then(response => client.logger.log(response.data))
.catch(error => client.logger.error(error))
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Spot = require('../src/spot')
const Spot = require('../../src/spot')
const apiKey = ''
const apiSecret = ''
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions node.js/run/Trade/Kycstatus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const Spot = require('../src/spot')
const apiKey = ''
const apiSecret = ''
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })


client.KycStatus().then(response => client.logger.log(response.data))
.catch(error => client.logger.error(error))
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions node.js/run/Trade/QueryMxDeduct.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const Spot = require('../src/spot')
const apiKey = ''
const apiSecret = ''
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })


client.MxDeducth().then(response => client.logger.log(response.data))
.catch(error => client.logger.error(error))
File renamed without changes.
8 changes: 8 additions & 0 deletions node.js/run/Trade/SelfSymbol.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const Spot = require('../src/spot')
const apiKey = ''
const apiSecret = ''
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })


client.SelfSymbol().then(response => client.logger.log(response.data))
.catch(error => client.logger.error(error))
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const Spot = require('../src/spot')
const apiKey = ''
const apiSecret = ''
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })


Expand Down
8 changes: 8 additions & 0 deletions node.js/run/Trade/TradeFee.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const Spot = require('../src/spot')
const apiKey = ''
const apiSecret = ''
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://api.mexc.com' })


client.TradeFee().then(response => client.logger.log(response.data))
.catch(error => client.logger.error(error))
File renamed without changes.
48 changes: 3 additions & 45 deletions node.js/src/APIbase.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const CryptoJS = require('crypto-js')
const HmacSHA256 = require('crypto-js/hmac-sha256')
const { removeEmptyValue, buildQueryString, createRequest, CreateRequest, pubRequest, defaultLogger } = require('./helpers/utils')
const { removeEmptyValue, buildQueryString, createRequest, defaultLogger } = require('./helpers/utils')

class APIBase {
constructor(options) {
Expand All @@ -10,7 +10,7 @@ class APIBase {
this.baseURL = baseURL
this.logger = logger || defaultLogger
}
//V3

publicRequest(method, path, params = {}) {
params = removeEmptyValue(params)
params = buildQueryString(params)
Expand All @@ -37,49 +37,7 @@ class APIBase {
url: `${path}?${queryString}&signature=${signature}`,
apiKey: this.apiKey
})
}

//V2
PublicRequest(method, path, params = {}) {
params = removeEmptyValue(params)
params = buildQueryString(params)
if (params !== '') {
path = `${path}?${params}`
}
return pubRequest({
method: method,
baseURL: this.baseURL,
url: path,
apiKey: this.apiKey
})
}

SignRequest(method, path, params = {}) {
params = removeEmptyValue(params)
const timestamp = Date.now()
const apiKey = this.apiKey
let objectString = apiKey + timestamp

if (method === 'POST') {
path = `${path}`
objectString += JSON.stringify(params)
} else {
let queryString = buildQueryString({ ...params })
path = `${path}?${queryString}`
objectString += queryString
}
const Signature = CryptoJS.enc.Hex.stringify(CryptoJS.HmacSHA256(objectString, this.apiSecret))
return CreateRequest({
method: method,
baseURL: this.baseURL,
url: path,
apiKey: this.apiKey,
timestamp: timestamp,
Signature: Signature,
params: params
})

}
}
}

module.exports = APIBase
16 changes: 0 additions & 16 deletions node.js/src/future.js

This file was deleted.

Loading