├── .editorconfig ├── .gitignore ├── .travis.yml ├── Gulpfile.js ├── LICENSE ├── README.md ├── demo.js ├── index.js ├── package.json └── test └── index.js /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # http://editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | indent_style = space 9 | indent_size = 2 10 | end_of_line = lf 11 | charset = utf-8 12 | trim_trailing_whitespace = true 13 | insert_final_newline = true 14 | 15 | [*.md] 16 | indent_style = space 17 | indent_size = 4 18 | trim_trailing_whitespace = false 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | node_modules 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "4" 4 | - "5" 5 | - "6" 6 | deploy: 7 | provider: npm 8 | email: anthony@chovy.com 9 | api-key: 10 | secure: nUunVDGEvFJTNkaaxy1YZO8qztD/ZnnQH5H3SQthQ9IpaDRqEWv861eiqVZqxB9n0Ncnv/aSR//FDcPm/phGu2AALitr3IB8zFMyWrxuYwrvC+BNnEfKRQhgZ9LOneZBamKm/7gu3c0+oVPnmA4HNGYSrxyzb/ezydTWdKz7oZ0= 11 | on: 12 | tags: true 13 | repo: chovy/shapeshift 14 | -------------------------------------------------------------------------------- /Gulpfile.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ralyodio/shapeshift/f6699fc7df74e10bf8fe79ee81bce5d72a47df54/Gulpfile.js -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Anthony Ettinger 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | shapeshift 2 | ========== 3 | 4 | [![NPM](https://nodei.co/npm/shapeshift.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/shapeshift/) 5 | 6 | [![Build Status](https://travis-ci.org/chovy/shapeshift.svg?branch=master)](https://travis-ci.org/chovy/shapeshift) [![Requirements Status](https://requires.io/github/chovy/shapeshift/requirements.svg?branch=master)](https://requires.io/github/chovy/shapeshift/requirements/?branch=master) 7 | 8 | shapeshift.io api for node.js 9 | 10 | ## What is shapeshift.io? 11 | 12 | ShapeShift is an instant exchange for Litecoin, Bitcoin, Peercoin, Dogecoin, Darkcoin, and other crypto-currencies. 13 | 14 | ShapeShift is the fastest way to exchange these digital currencies for one another. 15 | An exchange between crypto-currencies on ShapeShift takes only a few seconds, and no account is needed. 16 | 17 | The benefit of this is an application or site could send a payout to a content provider paid out in a different currency than 18 | what the consumer paid with. 19 | 20 | For example, Joe wants to be paid in Bitcoin, while Sally wants to pay him in Litecoin. 21 | ShapeShift allows you to convert the currency on behalf of the user. 22 | 23 | ## Install 24 | 25 | npm install --save shapeshift 26 | 27 | const shapeshift = require('shapeshift'); 28 | const pair = 'btc_ltc'; 29 | 30 | shapeshift.getRate(pair) 31 | .then(function(data){ 32 | //do something w/ data 33 | }); 34 | 35 | ## Usage 36 | 37 | Get the current rate offered by Shapeshift. 38 | 39 | const shapeshift = require('shapeshift'); 40 | const pair = 'btc_ltc'; 41 | 42 | shapeshift.getRate(pair) 43 | .then(function(data){ 44 | const body = data.body; 45 | 46 | //{"pair":"btc_ltc","rate":"93.83852691"} 47 | }; 48 | 49 | Get the current deposit limit set by Shapeshift. 50 | 51 | const shapeshift = require('shapeshift'); 52 | const pair = 'btc_ltc'; 53 | 54 | shapeshift.getLimit(pair) 55 | .then(function(data){ 56 | const body = data.body; 57 | 58 | //{"pair":"btc_ltc","limit":"1.98046131"} 59 | }); 60 | 61 | Get the current list of coins supported by Shapeshift. 62 | 63 | const shapeshift = require('shapeshift'); 64 | 65 | shapeshift.getCoins() 66 | .then(data => { 67 | const coins = data.body; 68 | //{BTC:..., ETH: ...} 69 | }); 70 | 71 | ## Current pairs supported 72 | 73 | btc, eth, ltc, ppc, drk, doge and more. Full list is available at: https://shapeshift.io/#/coins 74 | 75 | Note: use an underscore to seperate currencies in a pair (ie: `ltc_doge` or `doge_ltc`) 76 | 77 | ## API 78 | 79 | https://info.shapeshift.io/api 80 | 81 | License MIT 82 | -------------------------------------------------------------------------------- /demo.js: -------------------------------------------------------------------------------- 1 | const shapeshift = require('./index'); 2 | 3 | shapeshift.getRate('btc_ltc') 4 | .then(function(data){ 5 | console.log(arguments); 6 | }) 7 | .catch(function(err){ 8 | console.error(err); 9 | }); 10 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const _ = require('lodash'); 2 | const requestp = require('request-promise'); 3 | 4 | const shapeshift = module.exports = {}; 5 | const url = 'https://shapeshift.io'; 6 | const defaults = { 7 | json: true, 8 | resolveWithFullResponse: true 9 | }; 10 | 11 | //todo add support for callbacks instead of promises with options arg 12 | 13 | function get(url, opts){ 14 | opts = opts || {}; 15 | 16 | return requestp(_.extend(defaults, opts, { 17 | url: url 18 | })); 19 | } 20 | 21 | shapeshift.getRate = function(pair){ 22 | return get(url + '/rate/' + pair); 23 | }; 24 | 25 | shapeshift.getLimit = function(pair){ 26 | return get(url + '/limit/' + pair); 27 | }; 28 | 29 | shapeshift.getCoins = function(){ 30 | return get(url + '/getcoins'); 31 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shapeshift", 3 | "version": "1.0.2", 4 | "description": "shapeshift.io api for node.js", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "mocha" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git@github.com:chovy/shapeshift.git" 12 | }, 13 | "keywords": [ 14 | "btc", 15 | "ltc", 16 | "ppc", 17 | "drk", 18 | "doge", 19 | "bitcoin", 20 | "litecoin", 21 | "dogecoin", 22 | "darkcoin", 23 | "peercoin", 24 | "cryptocurrency", 25 | "exchange", 26 | "shapeshift" 27 | ], 28 | "author": "Anthony Ettinger (chovy)", 29 | "license": "MIT", 30 | "dependencies": { 31 | "lodash": "^4.x", 32 | "q": "^1.x", 33 | "request": "^2.x", 34 | "request-promise": "^3.x" 35 | }, 36 | "devDependencies": { 37 | "chai": "^3.x", 38 | "chai-as-promised": "^5.x", 39 | "mocha": "^2.x" 40 | }, 41 | "bugs": { 42 | "url": "https://github.com/chovy/shapeshift/issues" 43 | }, 44 | "homepage": "https://github.com/chovy/shapeshift", 45 | "directories": { 46 | "test": "test" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | const chai = require('chai'); 2 | //const chaiAsPromised = require("chai-as-promised"); 3 | const expect = chai.expect; 4 | const shapeshift = require('..'); 5 | 6 | //chai.use(chaiAsPromised); 7 | 8 | // `describe` makes a "suite" of tests; think of them as a group. 9 | describe('Get rates', function() { 10 | 11 | it('Should return the exchange rates for btc_ltc', function(done) { 12 | const pair = 'btc_ltc'; 13 | 14 | shapeshift.getRate(pair) 15 | .then(function(data){ 16 | const body = data.body; 17 | 18 | expect(body.pair).to.equal(pair); 19 | expect(body.rate).to.be.above(0); 20 | done(); 21 | }, function(err){ 22 | done(err); 23 | }) 24 | //note: this is not the getRate catch, its used by chai/mocha errors 25 | .catch(function(err){ 26 | done(err); 27 | }); 28 | }); 29 | 30 | it('Should return the exchange rates for ltc_btc', function(done) { 31 | const pair = 'ltc_btc'; 32 | 33 | shapeshift.getRate(pair) 34 | .then(function(data){ 35 | const body = data.body; 36 | 37 | expect(body.pair).to.equal(pair); 38 | expect(body.rate).to.be.above(0); 39 | done(); 40 | }, function(err){ 41 | done(err); 42 | }) 43 | .catch(function(err){ 44 | done(err); 45 | }); 46 | }); 47 | 48 | }); 49 | 50 | describe('Get limits', function() { 51 | it('Should return the limit for btc_ltc', function(done) { 52 | const pair = 'btc_ltc'; 53 | 54 | shapeshift.getLimit(pair) 55 | .then(function(data){ 56 | const body = data.body; 57 | 58 | expect(body.pair).to.equal(pair); 59 | expect(body.limit).to.be.above(0); 60 | done(); 61 | }, function(err){ 62 | done(err); 63 | }) 64 | .catch(function(err){ 65 | done(err); 66 | }); 67 | }); 68 | 69 | it('Should return the limit for ltc_btc', function(done) { 70 | var pair = 'ltc_btc'; 71 | 72 | shapeshift.getLimit(pair) 73 | .then(function(data){ 74 | const body = data.body; 75 | 76 | expect(body.pair).to.equal(pair); 77 | expect(body.limit).to.be.above(0); 78 | done(); 79 | }, function(err){ 80 | done(err); 81 | }) 82 | .catch(function(err){ 83 | done(err); 84 | }); 85 | }); 86 | }); 87 | 88 | describe('Get coins', function() { 89 | it('Should return the list of available coins', function(done) { 90 | shapeshift.getCoins() 91 | .then(function(data){ 92 | const coins = data.body; 93 | 94 | expect(Object.keys(coins).length).to.be.above(0); 95 | done(); 96 | }, function(err){ 97 | done(err); 98 | }) 99 | .catch(function(err){ 100 | done(err); 101 | }); 102 | }); 103 | 104 | }); 105 | --------------------------------------------------------------------------------