Exploring Decentraland Marketplace Sales with TheGraph and GraphQL | by Nikita Goldovsky | Towards Data Science

NFTs are all the rage these days. Or are they?
I wanted to find out by exploring sales of wearable items within the game Decentraland.
Decentraland is a blockchain-based virtual world, in which players can buy land, create scenes, hold virtual events, and buy and sell wearable goods within a peer-to-peer marketplace.
In particular I was curious about how popular the marketplace was for selling wearable items.
Wearable items are simply items you can dress your in-game avatar in and look like this in the marketplace.
Luckily, Decentraland offers a convenient way to access data about the marketplace via their GraphQL API on TheGraph.com.
Using this API, you can access information about what the item was, who purchased it, at what price, and when.
The first step in accessing the data is to use the playground environment on TheGraph.com to figure out the formatting of which data you want to return.
The playground looks like this and has three windows which I labeled below:
The first window (labeled 1) is your query editor, where you structure your query based on how you want the data to return.
The second window (labeled 2) is your output pane where you can view the results of the query.
The third window (labeled 3) is your reference guide to what fields you can request and their datatypes.
By default, the query returns 100 items, which poses a bit of a constraint if you want to collect a comprehensive dataset.
To get around this, I needed to find a way to query iteratively by feeding some last value as a starting point for retrieving the next results. I did this by ordering the query based on the update date and dynamically populating the starting point of the update date through the updatedAt_gt parameter.
My GraphQL query ultimately looked like this:
{orders (first: 1000 orderBy: updatedAt, orderDirection: asc where: { status:sold category:wearable updatedAt_gt:1}) {  category nftAddress price  status id updatedAt blockNumber nft { owner { id } name tokenURI  owner { id } }  } }
I’m not going to cover the specifics of filtering or windowing in GraphQL but provide a few links below that serve as good references for formatting your query.
You can view specific syntax examples on querying TheGraph on this page and learn the GraphQL query language here.
Once I had my query formatted, it was time to utilize python in order to iterate through the results and combine them in a pandas dataframe for further analysis.
To do this, it is helpful to install the Graphene library as per the official documentation on the GraphQL.org website.
Below were the libraries I had to import and the setup steps necessary to query the Decentraland API endpoint using python.
One word of caution to fellow noobs such as myself is that the GraphQL query format is heavy on curly brackets ({}), which creates some issues when you want to pass a dynamic variable. In order to avoid \n errors, I had to double-up all curly brackets, and use the syntax of “{0}” for my date variable inside the string.
My query string ultimately looked like this:
The next step was to setup a loop to query the first 1000 sales and then pass the last sale date of my first 1000 sales as the starting point to fetch the next 1000 sales. The full query loop looks like so:
With the data fully loaded into a dataframe we can now explore the data.
Looking at sales-by-month, we can see that sales were highest around the launch of the game in Feb 2020 but have since tapered off. There’s now about 100-sales-per-month.
How about the average selling price? I couldn’t find a description of what the price field in the API was being quoted in so I’m making a bit of an assumption that the price was given in MANA, the native token currency.
I plotted the mean price of goods sold by month. At the time of writing, 1 MANA was worth roughly 30 cents USD so the average price of a sold wearable in February 2021 was somewhere between $600–1200!
Wow, perhaps the surging currency and the sky-high prices of goods is why sales are declining.
There were 8,435 total sales in my data from Feb 2020 — Feb 2021. The total number of unique products sold was 281, of which 231 had more than 1 sale.
The top 15 sold products were as follows:
Decentraland is definitely still in the pioneer phase of its development and has work to do in order to drive growth in wearable sales. Perhaps a lower price point for items would help drive growth in monthly sales.
If you’re a blockchain and data enthusiast and reached other conclusions about Decentraland or NFTs in general, I would love to hear from you in the comments.