
Product
Go Support Is Now Generally Available
Socket's Go support is now generally available, bringing automatic scanning and deep code analysis to all users with Go projects.
Browser and Node.js Coinswitch.co API client
Easily exchange assets with few lines of code.
npm install --save coinswitch
const Coinswitch = require('coinswitch')
;(async () => {
const cs = new Coinswitch({
apiKey: '<YOUR API KEY>',
userIP: '1.1.1.1'
})
const coinsList = await cs.getCoins()
console.log(coinsList)
/*
[
{
"symbol": "btc",
"name": "Bitcoin",
"isActive": true
},
{
"symbol": "ltc",
"name": "Litecoin",
"isActive": true
},
{
"symbol": "bch",
"name": "Bitcoin Cash",
"isActive": true
},
...
]
*/
})()
const cs = new Coinswitch({
apiKey: '<YOUR API KEY>',
userIP: '1.1.1.1'
})
const {
offerReferenceId,
depositCoinAmount,
destinationCoinAmount
} = await cs.generateOffer('btc', 'ltc', 0.03)
const {
orderId,
exchangeAddress: { address }
} = await cs.makeOrder({
depositCoin: 'btc',
destinationCoin: 'ltc',
depositCoinAmount,
offerReferenceId,
userReferenceId: 'test-user',
destinationAddress: { address: 'LXdmzmqSALB1DbJyA43b6prQCXKn1J6SdV' },
refundAddress: { address: '1KcuzqzcvkpY3K8eoNgmKbqhFvoeQXAoPa' }
})
console.log(`
=========
Order ID: ${orderId}
Deposit: BTC (${depositCoinAmount})
Receive: LTC (${destinationCoinAmount})
Exchange Address: ${address}
=========
`)
NB: Addresses must be specified as a JS Object like {address: "...", tag: "..."}
Get your api-key from the coinswitch API page.
new CoinSwitch(<Object>)
: The class constructor requires an Object like { apiKey: "...", userIP: "..."}
.Method Name | Return | Description |
---|---|---|
.version() | String | Return API version being used |
.getCoins() | Array | Get list of supported coins as obj {symbol, name, isActive} |
.isCoinActive(<symbol>) | Boolean | Given a symbol (ex. btc ) return true /false wether the coin is active or not |
.getDestinationCoins(<symbol>) | Array | Return list of available destination coins for the one provided |
.getDepositCoins(<symbol>) | Array | Return list of depositable coins for the one provided |
.getExchangeLimit(<symbol>, <symbol>) | Object | Get exchange limits for a depositCoin and destinationCoin |
.generateOffer(<symbol>, <symbol>, <number>) | Object | Generate an exchange offer for a coin pair |
.makeOrder(<object>*) | Object | Creates a new tx for an offer. It will return transaction object with an order_id field to track the tx status. |
.getOrder(<string>) | Object | Get status of the given Order ID string. |
*
makeOrder input object sample:
{
depositCoin: 'btc',
destinationCoin: 'ltc',
depositCoinAmount: 0.03,
offerReferenceId: "...", // get it from generateOffer(..)
userReferenceId: 'test-user',
destinationAddress: { address: 'LXdmzmqSALB1DbJyA43b6prQCXKn1J6SdV' },
refundAddress: { address: '1KcuzqzcvkpY3K8eoNgmKbqhFvoeQXAoPa' }
}
For more examples look at the unit test/
folder.
npm test
To enable debug set the env var DEBUG=coinswitch
MIT
FAQs
Coinswitch.co API javascript client
The npm package coinswitch receives a total of 8 weekly downloads. As such, coinswitch popularity was classified as not popular.
We found that coinswitch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Go support is now generally available, bringing automatic scanning and deep code analysis to all users with Go projects.
Security News
vlt adds real-time security selectors powered by Socket, enabling developers to query and analyze package risks directly in their dependency graph.
Security News
CISA extended MITRE’s CVE contract by 11 months, avoiding a shutdown but leaving long-term governance and coordination issues unresolved.