Skip to content

Instantly share code, notes, and snippets.

@dougg0k
Last active February 17, 2026 18:36
Show Gist options
  • Select an option

  • Save dougg0k/b4782cfb9f2589bd19e6c18c3c5e4cd4 to your computer and use it in GitHub Desktop.

Select an option

Save dougg0k/b4782cfb9f2589bd19e6c18c3c5e4cd4 to your computer and use it in GitHub Desktop.
const puppeteer = require("puppeteer");
const Xvfb = require("xvfb");
async function getOpenseaData({ operationName, query, variables }) {
const xvfb = new Xvfb({
silent: true,
xvfb_args: ["-screen", "0", "1280x720x24", "-ac"],
});
xvfb.start((err) => {
if (err) {
console.error(err);
}
});
const browser = await puppeteer.launch({
headless: false,
args: [
"--no-sandbox",
"--disable-setuid-sandbox",
"--disable-gpu",
"--disable-dev-shm-usage",
"--enable-features=NetworkService",
"--display=" + xvfb._display,
],
ignoreHTTPSErrors: true,
dumpio: false,
defaultViewport: null,
});
const page = await browser.newPage();
await page.setRequestInterception(true);
page.on("request", (interceptedRequest) => {
interceptedRequest.continue({
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
method: "GET",
postData: JSON.stringify({
operationName,
query,
variables,
}),
});
});
const response = await page.goto("https://api.opensea.io/graphql", {
waitUntil: "networkidle0",
});
await page.content();
const data = await response.json();
await browser.close();
xvfb.stop();
return data;
}
const GET_NFT_INFORMATION = `
query getNFTPriceAndOwners($contractId: AddressScalar!, $tokenId: String!) {
archetype(
archetype: { assetContractAddress: $contractId, tokenId: $tokenId }
) {
quantity
asset {
creator {
displayName
}
assetEventData {
lastSale {
unitPriceQuantity {
quantityInEth
}
}
}
}
}
}
`;
(async () => {
const data = await getOpenseaData({
operationName: "getNFTPriceAndOwners",
query: GET_NFT_INFORMATION,
variables: {
contractId: "0xb932a70a57673d89f4acffbe830e8ed7f75fb9e0",
tokenId: "7188",
},
});
console.log("DATA = ", data);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment