-
-
Save dtmrc/1efd2b4d9e740ce280ceda01282f082a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 magicEdenURL = "https://api-mainnet.magiceden.io/rpc/getListedNFTsByQuery?q=%7B%22%24match%22%3A%7B%22collectionSymbol%22%3A%22essence_by_enigma_expanses%22%7D%2C%22%24sort%22%3A%7B%22takerAmount%22%3A1%2C%22createdAt%22%3A-1%7D%2C%22%24skip%22%3A0%2C%22%24limit%22%3A10%7D"; | |
const exchangeURL = "https://api.exchange.art/v1/public/tokens?limit=10&sort=price-asc&from=0&filters=%7B%22tokenListingTypes%22:%5B%22listed%22,%22unlisted%22%5D,%22collections%22:%5B%22Essence%22%5D%7D&view=collection"; | |
var XMLHttpRequest = require('xhr2'); | |
function floorPiecesMagicEden() { | |
var http = new XMLHttpRequest(); | |
http.open("GET", magicEdenURL); | |
http.send(); | |
http.onreadystatechange = (e) => { | |
if (http.responseText.length > 0) { | |
obj = new String(http.responseText); | |
data = JSON.parse(obj); | |
if (data.results.length != 10) throw new Error(message || "Length not 10, probably a server error, try again."); | |
var pieces = [] | |
data.results.forEach(e => { | |
pieces.push({ | |
name: e.title, | |
price: e.price, | |
mintAddress: e.mintAddress, | |
link: "https://magiceden.io/item-details/" + e.mintAddress, | |
imgUrl: e.img | |
}) | |
}); | |
return pieces; | |
} | |
}; | |
} | |
function floorPiecesExchange() { | |
var http = new XMLHttpRequest(); | |
http.open("GET", exchangeURL); | |
http.send(); | |
http.onreadystatechange = (e) => { | |
if (http.responseText.length > 0) { | |
obj = new String(http.responseText); | |
data = JSON.parse(obj); | |
if (data.tokens.length != 10) throw new Error(message || "Length not 10, probably a server error, try again."); | |
var pieces = [] | |
data.tokens.forEach(e => { | |
pieces.push({ | |
name: e.name, | |
price: e.lastListedPrice / 1000000000, | |
mintAddress: e.mintKey, | |
link: "https://exchange.art/single/" + e.mintKey, | |
imgUrl: e.image | |
}) | |
}); | |
return pieces; | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment