Help

Re: Is it possible to get LIVE market data from multiple crypto exchanges imported to my Airtable?

1448 0
cancel
Showing results for 
Search instead for 
Did you mean: 
joerazor
5 - Automation Enthusiast
5 - Automation Enthusiast

Is it possible to have live market data from multiple crypto exchanges imported into my Airtable via API? (Binance, KuCoin, Coinbase, etc..)

I am trying to create an app that utilizes this data. Unfortunately, I failed to get this done myself.

The data I need to have live data for are "Symbol," "Ask Price," "Bid Price," and "Trade Volume."

I would appreciate if anyone could provide any guidance.

 

4 Replies 4

If you can find a website that provides a REST API for cryptocurrency prices, then you can tap into that REST API by using one of 3 methods:

1. High-code: Writing your own custom Javascript scripts in Airtable.
2. Medium-code: Using DataFetcher.com
3. Low-code: Using Make's HTTP Module. There is a small learning curve with Make, which is why I created this basic navigation video to help.

joerazor
5 - Automation Enthusiast
5 - Automation Enthusiast

Thank you so much for your prompt reply.

I think the High-code solution would be ideal in my case, especially if it will push live data to my Airtable.

Unfortunately, I am not tech-savvy when it comes to coding scripts. Are there any readily available scripts to play around with?

As I mentioned above, I only want to import a couple of values for each currency pair from an exchange API to my Airtable and have them updated in real-time. (I am even fine if they get updated in 1-minute intervals if real-time is not an option)

Thanks again.

Unfortunately, I am not aware of any scripts that are available for these purposes. Perhaps other people will chime in below with examples of scripts for you.

However, if you've already found an exchange API and you just want to poll it every 1 minute, you don't even need to worry about writing a script. You can just setup a 1-minute repeating schedule with Make's HTTP module, and then use the Airtable modules to "upsert" the records in your Airtable base.

p.s. If you need help with piecing all of this together in Airtable using Make, I am available for hire as an expert Airtable consultant, although my rates are not structured for small/quick projects like this. My pricing is structured for developing a long-term consulting relationship, where you pre-purchase a block of hours from me and then you can always feel free to turn to me whenever you need help with any of your Airtable projects. If you'd like to chat more about this, please feel free to reach out to me through my website: Airtable Consulting — ScottWorld

Ian_Shaw
5 - Automation Enthusiast
5 - Automation Enthusiast

I just figured this out so I thought I would share it with you and all people who want to do this. 

First, follow this guide to get your Base/Table set up correctly.  You name them what is shown in this. (If you want to change the name, you can, and then find in the code where it references the old name and update it). 

https://scotthemmeter.com/2021/10/18/scripting-to-the-coinmarketcap-api

If you have less than 50 coins in your database, the code he gives you works great.  Big shout out to Scott for that.  

If you have more than 50, follow these steps, simply replace the code in Scott's tutorial with this code.  Be sure (in either code) to replace your API key from CoinMarketCap. 

Cheers! 

 

let batchSize = 50; // Number of records to process in each batch
let offset = 0; // Initial offset

let cmcTickerArray = [];
let recordIdArray = [];
let table = base.getTable("Coins");

// Fetch all records in a single query
let query = await table.selectRecordsAsync({
    sorts: [{ field: "Latest Price (As Of)", direction: "asc" }],
    fields: ["Ticker", "Name", "Latest Price (As Of)", "Latest Price", "Price % Change (24h)", "Price % Change (7d)", "Rank"]
});

for (let record of query.records) {
    cmcTickerArray.push(record.getCellValueAsString("Ticker"));
    recordIdArray.push(record.id);
}

while (offset < cmcTickerArray.length) {
    let updateArray = [];

    // Get a slice of the cmcTickerArray and recordIdArray based on the offset and batchSize
    let cmcTickerSlice = cmcTickerArray.slice(offset, offset + batchSize);
    let recordIdSlice = recordIdArray.slice(offset, offset + batchSize);

    let response = await fetch('https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?symbol=' + cmcTickerSlice.join() + '&skip_invalid=true', {
        headers: {
            "X-CMC_PRO_API_KEY": "YOUR_KEY_HERE"
        }
    });

    if (response.status === 200) {
        let data = await response.json();

        for (let i = 0; i < cmcTickerSlice.length; i++) {
            let coinData = data.data[cmcTickerSlice[i]];
            if (coinData && coinData.quote && coinData.quote.USD) {
                if (coinData.quote.USD.price && !isNaN(Number(coinData.quote.USD.price))) {
                    let updateObject = {};
                    updateObject["id"] = recordIdSlice[i];
                    updateObject["fields"] = {};
                    updateObject["fields"]["Latest Price"] = Number(coinData.quote.USD.price);
                    if (coinData.quote.USD.percent_change_24h && !isNaN(Number(coinData.quote.USD.percent_change_24h))) {
                        updateObject["fields"]["Price % Change (24h)"] = Number(coinData.quote.USD.percent_change_24h) / 100;
                    }
                    if (coinData.quote.USD.percent_change_7d && !isNaN(Number(coinData.quote.USD.percent_change_7d))) {
                        updateObject["fields"]["Price % Change (7d)"] = Number(coinData.quote.USD.percent_change_7d) / 100;
                    }
                    if (coinData.cmc_rank && !isNaN(Number(coinData.cmc_rank))) {
                        updateObject["fields"]["Rank"] = Number(coinData.cmc_rank);
                    }
                    updateObject["fields"]["Latest Price (As Of)"] = new Date();
                    updateArray.push(updateObject);
                }
            }
        }

        await table.updateRecordsAsync(updateArray);
    }

    offset += batchSize;
}