Magically import Moonbirds NFT sales into Google Sheets using Sort
Published: 2022-04-28 22:55:11

Using the [Sort API](https://docs.sort.xyz), we can get any Ethereum transaction data into Google Sheets. Specifically for [Moonbirds](https://etherscan.io/address/0x23581767a106ae21c074b2276d25e5c3e136a68b), 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](https://docs.sort.xyz) 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](https://syncwith.com/), 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ll96kbt9k1niv6yv0bsu.png)


## 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 }
}
```
- 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"](https://docs.sort.xyz/api-docs/reference/api-reference/transaction#parameters) 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/26egfz6ouovxlsd6dwqn.png)


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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bhqimyqxmyclo9yb5ci4.png)


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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5alvo7npnpzh8poo87qm.png)


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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/puayzqlxn9fzbbhpblhl.png)


You can continue further to expand the "attributes" column, specify different dates to get historical data (using the ["timestamp" API field](https://docs.sort.xyz/api-docs/reference/api-reference/transaction#parameters)), 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
}
```

Hopefully this has been a good primer on using the [Sort API](https://docs.sort.xyz) to get data into Google Sheets. Please visit us in [Discord](https://discord.gg/sort) to ask any questions, or stay tuned for more tutorials using Moonbirds transaction data.