sushiswap-api

    1.1.1 • Public • Published

    sushiswap-api

    If you want to use the new sushi API, this package has been made for you.

    The full documentation of the API is available here : https://docs.sushipro.io

    Installation

    Use the package manager npm to install sushiswap-api.

    npm i sushiswap-api

    Blockchain available / value of chainID

    • 1 : Ethereum
    • 137 : Polygon
    • 250 : Fantom

    Functions

    • getAllPairs(chainID)
    • getAllTokens(chainID)
    • getPair(chainID,contract)
    • getPairsByToken(chainId,Token contract)
    • getHistoricalLiquidity(chainID,pair contract,from (timestamp),to (timestamp))
    • getHistoricalVolume(chainID,pair contract,from (timestamp),to (timestamp))
    • getHistoricalTransactions(chainID,pair contract,from (timestamp),to (timestamp))
    • getXSushiAPY(from (timestamp), to (timestamp))
    • getRewardsByUser(user address)
    • getTransactionsByPair(chainID, pair contract, direction ( DESC or ASC), page ( start at 0))
    • getTransactionsByUser(chainID, user address, direction ( DESC or ASC), page ( start at 0))

    Usage / Example

    var api	= require('sushiswap-api');
    
    
    /**	--	getAllPairs(chainID) return for each pair:
    	--	Pair_ID
    	--	Token_1_contract,Token_1_symbol,Token_1_name,Token_1_decimals,Token_1_price,Token_1_reserve,Token_1_derivedETH
    	--	Token_2_contract,Token_2_symbol,Token_1_name,Token_2_decimals,Token_2_price,Token_2_reserve,Token_2_derivedETH	**/
    api.getAllPairs(137).then(	function(res) {
    		res[1].forEach( function(Pair) {
    			console.log(Pair);
    			}
    		);
    	}
    );
    
    
    
    /**	--	getAllTokens(chainID) return for each pair:
    	--	Contract,Symbol,Name,Decimals				**/
    api.getAllTokens(1).then(	function(res) {
    		res[1].forEach( function(Token) {
    			console.log(Token);
    			}
    		);
    	}
    );
    
    
    
    /**	--	getPair(chainID,contract) return:
    	--	Token_1_contract,Token_1_symbol,Token_1_name,Token_1_price,Token_1_reserve,
    	--	Token_2_contract,Token_2_symbol,Token_2_name,Token_2_price,Token_2_reserve	**/
    
    api.getPair(1,'0xceff51756c56ceffca006cd410b03ffc46dd3a58').then(	function(res) {
    		res.forEach( function(Pair) {
    			console.log(Pair);
    			}
    		);
    	}
    );
    
    
    
    /**	--	getPairsByToken(chainId,Token contract) return for each pair:
    	--	Pair_ID
    	--	Token_1_contract,Token_1_symbol,Token_1_name,Token_1_price,Token_1_reserve
    	--	Token_2_contract,Token_2_symbol,Token_1_name,Token_2_price,Token_2_reserve	**/
    
    api.getPairsByToken(1,'0xe9f84de264e91529af07fa2c746e934397810334').then(	function(res) {
    		res[1].forEach( function(Pair) {
    			console.log(Pair);
    			}
    		);
    	}
    );
    
    
    
    /**	--	getHistoricalLiquidity(chainID,pair contract,from (timestamp),to (timestamp)) return for each day available:
    	--	Date
    	--	Token_1_contract,Token_2_contract,Token_1_reserve,Token_2_reserve,USD_total_liquidity **/
    
    api.getHistoricalLiquidity(1,'0xd45afa3649e57a961c001b935ded1c79d81a9d23',1625097600,1625473410).then(	function(res) {
    		res[1].forEach( function(data) {
    			console.log(data);
    			}
    		);
    	}
    );
    
    
    /**	--	getHistoricalVolume(chainID,pair contract,from (timestamp),to (timestamp)) return for each day available:
    	--	Date
    	--	Token_1_contract,Token_2_contract,Token_1_volume,Token_2_volume,USD_total_volume **/
    
    api.getHistoricalVolume(1,'0xd45afa3649e57a961c001b935ded1c79d81a9d23',1625097600,1625473410).then(	function(res) {
    		res[1].forEach( function(data) {
    			console.log(data);
    			}
    		);
    	}
    );
    
    
    
    /**	--	getHistoricalTransactions(chainID,pair contract,from (timestamp),to (timestamp)) return for each day available:
    	--	Date
    	--	Token_1_contract,Token_2_contract,Transactions **/
    
    api.getHistoricalTransactions(1,'0xd45afa3649e57a961c001b935ded1c79d81a9d23',1625097600,1925473410).then(	function(res) {
    		res[1].forEach( function(Transaction) {
    			console.log(Transaction);
    			}
    		);
    	}
    );
    
    
    
    /**	--	getXSushiAPY(from (timestamp), to (timestamp)) return for each day available:
    	--	date,apy,apr **/
    
    api.getXSushiAPY(1625097600,1925473410).then(	function(res) {
    		res[1].forEach( function(data) {
    			console.log(data);
    			}
    		);
    	}
    );
    
    
    
    /**	--	getRewardsByUser(user address) return for each day available:
    	--	week,amount **/
    
    api.getRewardsByUser('0x4086e3e1e99a563989a9390facff553a4f29b6ee').then(	function(res) {
    		var results	=	res[0].number_of_results;
    		if(results > 0) {
    			res[1].forEach( function(rewards) {
    				console.log(rewards);
    				}
    			);
    		} else { 
    			console.log('No result.');
    		}
    	}
    );
    
    
    
    /**	--	getTransactionsByPair(chainID, pair contract, direction ( DESC or ASC), page ( start at 0)) return for each day available:
    	--	timestamp,side,priceBase,priceUSD,volumeUSD,txHash,receiver,maker,amountBase,amountQuote,tokenBase,tokenQuote **/
    
    api.getTransactionsByPair(1,'0xd45afa3649e57a961c001b935ded1c79d81a9d23','DESC',0).then(	function(res) {
    		var results	=	res[0].number_of_results;
    		if(results > 0) {
    			res[1].forEach( function(Trade) {
    				console.log(Trade);
    				}
    			);
    		} else { 
    			console.log('No result.');
    		}
    	}
    );
    
    
    
    
    /**	--	getTransactionsByUser(chainID, user address, direction ( DESC or ASC), page ( start at 0)) return for each day available:
    	--	timestamp,side,pairID,priceBase,priceUSD,volumeUSD,txHash,receiver,maker,amountBase,amountQuote,tokenBase,tokenQuote **/
    
    api.getTransactionsByUser(1,'0x4086e3e1e99a563989a9390facff553a4f29b6ee','DESC',0).then(	function(res) {
    		var results	=	res[0].number_of_results;
    		if(results > 0) {
    			res[1].forEach( function(Trade) {
    				console.log(Trade);
    				}
    			);
    		} else { 
    			console.log('No result.');
    		}
    	}
    );

    Author

    GoldenNaim - Naim Boubziz - https://twitter.com/BrutalTrade

    License

    MIT

    Install

    npm i sushiswap-api

    DownloadsWeekly Downloads

    8

    Version

    1.1.1

    License

    MIT

    Unpacked Size

    10.4 kB

    Total Files

    3

    Last publish

    Collaborators

    • naim_boubziz