THE LAB #9: Scraping OpenSea NFT’s data

Excerpt

Getting winners and losers of the Bored Ape Yacht Club collection transactions


The NFT hype cycle

Welcome back to The Web Scraping Club for a new episode of The Lab. In the past week, a scandal that involves the famous influencer Logan Paul and his crypto project called “Criptozoo” exploded, thanks to the Cofeezilla investigations (you can see the full story here). Basically, it seems that this crypto game has never been delivered for multiple factors but people, trusting the public profile of Logan, put several million USD into it, hoping to have some return, a thing that never happened. It’s nothing new under the Crypto sun, Ponzi schemes promising impossible returns on investments are discovered every day, and surprisingly there’s always someone who got caught in the fishnet.

But this is not a post about scams, only this story reminded me of an ancient word, coming from a far era from the past, called NFT. Do you remember? Funky images with some traits hardcoded in a smart contract, exchangeable like trading cards on marketplaces like OpenSea?

It was the buzzword of 2021, the year well-known for 2 plagues: Covid-19 and the explosion of Crypto gurus that have just left the ICO (another forgotten term) bandwagon, just to hop in the NFT one.

[

](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F9cdf549c-ba54-4808-9769-a51065a4ccd5_1143x386.png)

Google Trends on NFT

As you can see from this Google Trends chart, the interest is sharply fading away, but during the whole of 2021, the web was full of news and stories about NFTs and new collections launched.

The 2021 of NFT marketThe 2021 of NFT market

The 2021 of NFT marketThe 2021 of NFT market

The 2021 of NFT market

One of the most well-known NFT collections is called “Bored Ape Yacht Club”, consisting of ten thousand “Bored Monkeys” images procedurally generated by an algorithm. In May 2021 the launch price for every NFT was 0.08 ETH, approx 200$, and they went sold out in 12 hours. In October they were already exchanged for hundreds of thousands each, quickly becoming a status symbol. They give access to a Discord server where talk with other owners, even celebrities that bought them, and a private section of the collection website.

Yuga Labs, the company behind the BAYC NFTs, in March 2022 raised 450M USD in funding by venture capital firm Andreessen Horowitz, with a company evaluation of 4 Billion USD.

Bored Ape NFTs boughtBored Ape NFTs boughtBored Ape NFTs bought

Bored Ape NFTs boughtBored Ape NFTs bought

Bored Ape NFTs bought

But when the music stops…

As we have seen many times in different cases when things go up so fast, usually go down even faster. Having a look at the Google trends chart, now the hype is gone and the interest in NFTs, in general, is almost faded away. We can also see it from the OpenSea activity dashboard, where the number of sales for the Bored Apes NFTs went from several hundred per day in early 2021 to a few tenths of the latest months.

To make things worse, the whole crypto economy is passing through a so-called “crypto winter”, with all the major cryptos losing around 70% of their price from their highest peak.

[

Coindesk Bitcoin Chart

](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F9a39ba0d-7215-4ea2-954e-27837a0b6567_931x856.png)

Coindesk Bitcoin Chart

I’ve always been fascinated by this world and its dynamics and thanks to the transparency given by the blockchain and the web scraping techniques we’ll see later in this post, I wanted to put down some numbers.

Basically, I’ve tracked down every sale of Bored Ape NFTs that happened on OpenSea from the start to enrich the stats of the collection available on the marketplace.

2 billion USD

That’s the amount of real money moved by The Bored Ape Yacht Club, from May 2021 to the first days of December 2022.

Yes, 2 Billion USD, like the yearly GDP of the whole Central African Republic. Summing up the USD value (at the time of the transaction) of all the sales that happened, you get $2,121,310,433 USD, with an astonishing peak of 283 Million USD traded during only January 2022.

[

](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F3c4d71b2-b4d7-415b-b54e-69c241c02cd8_1240x840.png)

Total transactions of Bored Ape Yacht Club

Winners and losers

In a market that had such a hyped start and a sharp decline, who entered first and had the right timing when selling, had a huge advantage.

If we do not consider the first-movers, who got their prize in pre-sale, around ten thousand accounts on Opensea are involved in trading these BAYC NFTs. Around 70% of them lost some money, accumulating a loss of 1.2 Bn USD. On the other hand, the remaining 30% cumulated a gain of 380 Mn USD.

[

Cumulate loss and gains

](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F2ad37688-4852-4b50-ba9a-889277e96df3_1240x840.png)

Cumulate loss and gains

But if we consider only the accounts that sold more NFTs than bought, if they bought any, they made around 900Mn USD in gains.

As a result, we have a massive shift of wealth (around 1.2 Bn USD) from 7k accounts to another 7k, and half of the latest probably bought the NFTs during pre-sale.

130 vs 127

Another interesting fact that emerges from the transaction data is that 130 accounts made more than 1 Mn USD in trading, while 127 lost more than 1 Mn USD.

One of the top performers is the famous NFT collector Pransky who made alone 5.5 Mn USD by selling 1155 NFTs and buying only one for 1.5 Mn.

With all the buzz and noise around the NFTs, and in particular around The Bored Ape Yacht Club NFTs, it surprises me I haven’t seen these numbers in any article I’ve read. The main reason I suppose is that getting them requires a simple but not effortless job of web scraping, both on OpenSea and on Etherscan to get the USD value of the transaction at that time.

And that’s what we’ll see in the next chapters, the scrapers I’ve created to get this data.

As we said before, the Bored Ape Yacht Club is a collection of 10000 NFTs we can find on Opensea. Each item is numbered from 0 to 9999 and can be found adding its number after the URL https://opensea.io/assets/ethereum/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d/.

[

NFT page

](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F9e7951f7-4725-47af-be43-78a262d759e1_1159x932.png)

NFT page

The website is protected by Cloudflare, so we need a headful browser to scrape it. We are going to collect all the Sale transactions in the Item Activity section.

[

NFT Transactions

](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F74dd5e39-9d7d-460f-a9e4-7ea5d0cc8a99_1733x579.png)

NFT Transactions

In particular, what matters to us is the account name of the seller and the buyer and the link to the transaction on Etherscan, so we can have more details on the price actually paid for the sale.

I acknowledge a more complete analysis should involve also the transfers between accounts and their re-mapping, but it would be too much effort for this article and doesn’t add too much to the global outcome.

Basically, we’re setting up a python script that, using Playwright, opens a Firefox window for every NFT, reads the table, and saves the sale rows on a CSV file.

We open and close the window for every NFT since I’ve found that this helps avoid being blocked or getting the execution stuck for too much memory used after several requests.

[

Playwright scraper for Opensea

](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F78215abc-d00a-48dd-8fe0-2756c65a786e_970x924.png)

Playwright scraper for Opensea

As usual, you can find the code on the GitHub repository for paying readers.

After the execution of the first script ends, we’ll set up a similar one for reading the transaction details from Etherscan.

[

Etherscan page

](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F95f075bf-cd6d-482e-bdeb-73af50bc09bd_1403x792.png)

Etherscan page

What’s important here is the estimated value of the transaction on the day of transfer, so we can approximately have the amount of USD people have spent during the last year and a half on these NFTs. Depending on the token used for paying, if ETH or WETH, the price is located in different places on the page so we had to handle these variants. On top, a few links to the transactions scraped from Opensea seemed not correct and I needed to add an exception handling.

Even Etherscan is protected by Cloudflare so again we used Playwright to scrape the transactions that came out from the previous script.

[

](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fc938d1be-100d-43cb-b40c-c0d529739749_1420x766.png)

Etherscan Playwright scraper

In both cases, Cloudflare was not an issue. Using Playwright with a slow_mo value for the browser was enough to avoid being blocked. Probably a more massive approach with hundreds of thousands of URLs to requests would have been harder to scrape and would have required some proxies.

Putting both the results on a Google spreadsheet and with some formulas and magic, we’ve got all the numbers we need to create an analysis like the ones we’ve seen before.

They could be useful to find NFT collector whales (people like Pransky that collect a great amount of NFTs), traders, or make a sort of due diligence on a collection before entering it.

The Lab - premium content with real-world cases