Created
April 7, 2021 19:00
-
-
Save alejoacosta74/55044445dec594f33c10c432b39f1116 to your computer and use it in GitHub Desktop.
Node.js script to query token data via GraphQL (The Graph)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const axios = require('axios'); | |
uniswapURL = "https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2" ; // https://thegraph.com/explorer/subgraph/uniswap/uniswap-v2 | |
const main = async () =>{ | |
try { | |
const result = await axios.post( | |
uniswapURL, | |
{ | |
query: ` | |
{ | |
tokens(first: 10, orderBy:tradeVolumeUSD, orderDirection: desc) | |
{ | |
symbol | |
name | |
totalLiquidity | |
} | |
} | |
` | |
} | |
); | |
console.log ("Query result: \n", result.data.data.tokens); | |
} catch (err){ | |
console.log(err); | |
} | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment