Building a Crypto Price Feed for the Web

How I built a user-facing crypto tracker using Python, REST APIs, and dynamic frontend rendering

Continue reading...

Featured Project
case study

What Happens If AI Handles Customer Support? ServiceNow Found Out

May 03, 2025

See how ServiceNow use smart AI agents to answer 80% of customer questions quickly, saving time and making customers happier.

Project
case study

Why AI Chatbots Fail

May 03, 2025

I explore how AI chatbots can improve customer support for businesses, while also highlighting their common problems and how to make them better.

From the Firehose

About

I built a smart tool that helps anyone interested in cryptocurrency track the latest prices and data without the hassle of checking daily.

Imagine you're really excited about cryptocurrency, but keeping track of all the price changes, market caps, and volumes can feel like trying to juggle while riding a unicycle. It's a bit tricky, right? That's where this code comes in—it helps automate the process of gathering and updating cryptocurrency data, making it easier for you to keep your finger on the pulse of the crypto market.

So, how does this code solve the problem of managing crypto data? It connects to a crypto data API (like CoinGecko) to fetch the latest information, stores it in a database, and updates it regularly. This way, you don’t need to manually check prices every day. Instead, the code does the heavy lifting for you!

Key Parts of the Code

Let’s break down a few interesting parts of this code that make it so effective:


# Helper function: Get crypto data if there's none
def get_crypto_data(coin_name, coin_id):
    # ... (code omitted for brevity)
    coin_in_db = db.session.query(CryptoMarketData).filter(CryptoMarketData.name == coin_name)

    # Clears previous data before adding new one
    if coin_in_db.all():
        coin_in_db.delete()
        db.session.commit()

This function, get_crypto_data, is like your best friend who cleans your room before bringing in new stuff. It checks if there’s any existing data for a cryptocurrency. If it finds any, it clears it out before bringing in the latest data. This ensures that you always have the most accurate and up-to-date information!


# Helper function: checks if timestamp is in a date list
def ts_in_date_list(ts, dates_: list):
    ts_date = dt.datetime.fromtimestamp(ts // 1000, dt.timezone.utc).date()
    return ts_date in dates_

Next up is the ts_in_date_list function. It’s like having a calendar that tells you if a specific date is on your schedule. It takes a timestamp and checks if that date is part of the dates you’re interested in. This is super helpful when the code needs to figure out if it has the right data for the days it wants to update.


# Helper function: Update crypto data rows
def update_crypto_data():
    # ... (code omitted for brevity)
    missing_dates = [date_ for date_ in date_range_required if date_ not in date_range_in_db]
    
    if missing_dates:
        # Get historical data in one API call instead of multiple
        params = {"vs_currency": "usd", "days": history_range, "interval": "daily"}
        # ... (code continues)

Finally, we have the update_crypto_data function. This is where the magic happens! It checks if there are any dates missing from the database. If it finds some, it fetches all the historical data in one go rather than in bits and pieces. It’s like going to the grocery store and buying everything you need for a week in one trip instead of going every day!

Wrapping It Up

In summary, this code is a handy tool that automates the process of tracking cryptocurrency data, making life a lot easier for anyone interested in the crypto market. By regularly fetching and updating data, it ensures that you’re always informed without the hassle of manual checking. Plus, it’s a great example of how coding can simplify complex tasks and help us stay on top of the latest trends. How cool is that?

You can try it out here:

Try it out

Hungry for more? Let me introduce you to my exciting project that makes social media management easy and fun for small businesses! I created an AI-powered tool that helps businesses automatically post on social media. This tool is smart enough to know the day of the week, the current season, and even holidays! This means every post is special and connects with customers in a fresh way.

This project not only saves time but also keeps businesses looking good online. Imagine having unique and colorful posts made just for your brand without lifting a finger! If you want to learn how this magic works and see how it can change your social media game, stick around for the details. You're going to love it!

Learn More

About

I built a smart tool that helps anyone interested in cryptocurrency track the latest prices and data without the hassle of checking daily.