SHARE
TWEET

Untitled

a guest Feb 18th, 2020 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const express = require('express');
  2. const request = require('request');
  3.  
  4. const app = express();
  5.  
  6. app.use((req, res, next) => {
  7.   res.header('Access-Control-Allow-Origin', '*');
  8.   next();
  9. });
  10.  
  11. app.get('/chainz/balance/:coinname/:address', (req, res) => {
  12. console.log(req.params.coinname);
  13. console.log(req.params.address);
  14.   request(
  15.     { url: 'https://chainz.cryptoid.info/' + req.params.coinname +'/api.dws?q=getbalance&a='+ req.params.address+ ''},
  16.     (error, response, body) => {
  17.       if (error || response.statusCode !== 200) {
  18.         return res.status(500).json({ type: 'error', message: error });
  19.       }
  20.  
  21.       res.send(body);
  22.       }
  23.     )
  24.   });
  25.   app.get('/chainz/listunspent/:coinname/:address', (req, res) => {
  26.   console.log(req.params.coinname);
  27.   console.log(req.params.address);
  28.     request(
  29.       { url: 'https://chainz.cryptoid.info/' + req.params.coinname +'/api.dws?q=unspent&key=1a9c92c7492b&active='+ req.params.address+ ''},
  30.       (error, response, body) => {
  31.         if (error || response.statusCode !== 200) {
  32.           return res.status(500).json({ type: 'error', message: error });
  33.         }
  34.  
  35.         res.send(body);
  36.         }
  37.       )
  38.     });
  39.     app.get('/coinexplorer/balance/:coinname/:address', (req, res) => {
  40.     console.log(req.params.coinname);
  41.     console.log(req.params.address);
  42.       request(
  43.         { url: 'https://www.coinexplorer.net/api/v1/' + req.params.coinname +'/address/balance?address='+ req.params.address+ ''},
  44.         (error, response, body) => {
  45.           if (error || response.statusCode !== 200) {
  46.             return res.status(500).json({ type: 'error', message: error });
  47.           }
  48.    
  49.           res.send(body);
  50.           }
  51.         )
  52.       });
  53.     app.get('/coinexplorer/listunspent/:coinname/:address', (req, res) => {
  54.     console.log(req.params.coinname);
  55.     console.log(req.params.address);
  56.       request(
  57.         { url: 'https://chainz.cryptoid.info/' + req.params.coinname +'/api.dws?q=unspent&key=1a9c92c7492b&active='+ req.params.address+ ''},
  58.         (error, response, body) => {
  59.           if (error || response.statusCode !== 200) {
  60.             return res.status(500).json({ type: 'error', message: error });
  61.           }
  62.    
  63.           res.send(body);
  64.           }
  65.         )
  66.       });
  67.   const PORT = process.env.PORT || 5555;
  68.   app.listen(PORT, () => console.log(`listening on ${PORT}`));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top