0.4.0 • Published 3 years ago
@cryptosight/api-rest-sdk v0.4.0
CRYPTOSIGHT-API-REST-SDK
The API REST SDK is an HTTP-based interface created for developers to automate cryptosight.com alerts. This library doesn't validate any parameters and data will be sent to the API server directly. It's just a simplified Promise
based HTTP API parser with axios.
Documentation
Please refer to the official documentation for API methods and parameters description.
Install
$ npm install @cryptosight/api-rest-sdk
Examples
Get Exchange Pairs:
const API_REST_SDK = require('@cryptosight/api-rest-sdk')
const api = new API_REST_SDK()
const exchangeId = 'binance'
const opt = {
// optional query parameter(s)
quoteId: 'USDT',
}
api
.getExchangePairs(exchangeId, opt)
.then((res) => {
console.log(res.data) // get list pairs with quoteId 'USDT'
})
.catch((err) => {
console.error(err.response?.data) // error message
})
Get Exchange TA:
const API_REST_SDK = require('@cryptosight/api-rest-sdk')
const api = new API_REST_SDK()
const taId = 'rsi'
const exchangeId = 'binance'
const intervalId = '1h'
const symbolId = 'BTCUSDT'
const opt = {
// optional query parameter(s)
limit: 10,
}
api
.getExchangeTA(taId, exchangeId, intervalId, symbolId, opt)
.then((res) => {
console.log(res.data) // get rsi values limit to 10
})
.catch((err) => {
console.error(err.response?.data) // error message
})
Post Exchange Condition Alert:
const API_REST_SDK = require('@cryptosight/api-rest-sdk')
const api = new API_REST_SDK({ key: 'YOUR_API_KEY' })
// Get your free API KEY @ cryptosight.com
const payload = {
exchangeId: 'binance',
symbolId: 'BTCUSDT',
conditionId: 'pgt',
conditionValue: 50500,
methodIds: ['popup', 'telegram'],
message: 'Price going up! Buy! Buy! Buy!'
}
api.
.postAlertCondition(payload)
.then((res) => {
console.log(res.data) // get posted new alert
})
.catch((err) => {
console.error(err.response?.data) // error message
})
Triggered alert message example:
BTCUSDT @ Binance - Price is 50,501 USDT and greater than 50500. -- Price going up! Buy! Buy! Buy!
You can use special {placeholder}
to override the default alert message.
API
All methods return a Promise using axios
.
Public
An API key is not required, but request rates are limited.
Server
getServerDatetime()
Exchange
getExchangeList()
getExchangePairs(exchangeId, opt)
getExchangeLastTrade(exchangeId, symbolId, opt)
getExchangeOpenInterest(exchangeId, symbolId)
getExchangeFundingRate(exchangeId, symbolId)
getExchangeTA(taId, exchangeId, intervalId, symbolId, opt)
Private
An API key is required to access. Get your free API Key @ cryptosight.com.