Skip to content

Instantly share code, notes, and snippets.

@coopermaruyama
Last active August 19, 2017 14:37
Show Gist options
  • Save coopermaruyama/6941d5e3f7fddab6584d8f2ca68896d2 to your computer and use it in GitHub Desktop.
Save coopermaruyama/6941d5e3f7fddab6584d8f2ca68896d2 to your computer and use it in GitHub Desktop.
ICO Stats CSV Script
#!/usr/bin/env node
const { createApolloFetch } = require('apollo-fetch');
const fs = require('fs');
const uri = 'https://icostats.com/graphql';
const apolloFetch = createApolloFetch({ uri });
const query = `
query icos {
icos {
id,
name,
symbol,
price_usd,
price_btc,
implied_token_price,
roi_since_ico,
roi_since_ico_eth,
roi_since_ico_btc,
start_date,
icon_ext,
ticker,
eth_price_at_launch,
btc_price_at_launch,
roi_per_week,
roi_per_day,
roi_per_month,
eth_roi_during_period,
btc_roi_during_period,
roi_vs_eth,
roi_vs_btc,
roi_vs_eth_abs,
roi_vs_btc_abs,
is_erc20,
eth_price_usd,
btc_price_usd,
supported_changelly,
raise,
amount_sold_in_ico,
supported_shapeshift
}
recentPrices {
symbol
recent_prices {
day
week
month
}
}
}
`;
apolloFetch({ query })
.then(result => {
const headers = 'name,price,ico price,start date,ROI since ICO';
const icos = result.data.icos;
const formatted = icos.map(ico =>
`${ico.name},${ico.price_usd},${ico.implied_token_price},${ico.start_date},${ico.roi_since_ico}`
);
const joined = formatted.join('\n');
const text = `${headers}\n${joined}`;
fs.writeFileSync('./out.csv', text, 'utf8');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment