DEV Community 👩‍💻👨‍💻

Cover image for Magically import Moonbirds NFT sales into Google Sheets using Sort
Sort
Sort

Posted on

Magically import Moonbirds NFT sales into Google Sheets using Sort

Using the Sort API, we can get any Ethereum transaction data into Google Sheets. Specifically for Moonbirds, we can create a Google Sheet of nesting birds, sales, transfers, or any event that occurred on the blockchain for Moonbirds. For this tutorial, we'll focus on sales (across OpenSea, LooksRare, and Rarible exchanges, Coinbase coming soon).

The Sort API allows us to look at individual blockchain transactions, or even perform millisecond aggregations (average, sum, etc, useful for charting). We'll focus on the individual transactions, and to simplify the tutorial, we'll use a Google Sheets plugin called SyncWith, useful for sending API calls and storing the result in a Google Sheet.

Install SyncWith Google Sheets Add-on

  1. Open a new Google Sheet, in the menu bar, click "Extensions" -> "Add-ons" -> "Get add-ons", search for "SyncWith" and install.

  2. After the plugin is installed, visit the plugin via "Extensions" -> "SyncWith" -> "Manage Connections"

  3. Scroll to the very bottom of the "SyncWith" app and click "Custom"

  4. Create a POST request with a JSON body

Image description

Create a Sort API Request

Let's formulate our API request for Moonbirds data

API endpoint:

https://api.sort.xyz/v0/transaction

POST body:

{
  "nft_event": "sale",
  "nft_address": "0x23581767a106ae21c074b2276D25e5C3e136a68b",
  "limit" : 50,
  "fields" : { "nft" : 1 }
}
Enter fullscreen mode Exit fullscreen mode
  • nft_event: only look for sales
  • nft_address: contract address of NFT
  • limit: number of results to return from API request (max is 250, to go further back for historical data, use the "timestamp" field)
  • fields: the responses will be large, let's only return the "nft" field (which includes all useful NFT data), and leave out other data such as logs and function parameters. To also include a timestamp, change this value to { "timestamp" : 1, "nft" : 1 }

(if you're familiar with Dune Analytics, think of Sort as an API-first version of Dune)

Now put the API request in "SyncWith"

Image description

Click Preview

Shape the data result

There is a list of results in the "result" field.

Delete the "id", "status", and "object" fields (by clicking the trash can icon), click "expand" on the "result" field

Image description

Next, "expand" the "nft" field, click "Update".

Image description

All done! You should have a list of the latest Moonbirds sales in Google Sheets!

Image description

You can continue further to expand the "attributes" column, specify different dates to get historical data (using the "timestamp" API field), or perform more detailed analysis.

More to come

We can do other things too, such as looking for blockchain transactions that have executed the "toggleNesting" function (executed when a bird nests/un-nests):

{
  "contract_address": 
  "0x23581767a106ae21c074b2276d25e5c3e136a68b",
  "contract_function": "toggleNesting",
  "limit" : 50
}
Enter fullscreen mode Exit fullscreen mode

Hopefully this has been a good primer on using the Sort API to get data into Google Sheets. Please visit us in Discord to ask any questions, or stay tuned for more tutorials using Moonbirds transaction data.

Top comments (0)

👋 New to DEV?

Head over to our Welcome Thread and tell us a bit about yourself!