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

Klarna’s Customer Support Backlash — When AI Misfires

May 16, 2025

Klarna fixed its customer support by hiring humans for customer support after using AI for a while, customers were not satisfied with their AI system.

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 color extraction project! This cool tool helps you grab the best colors from any image you love, whether it’s from a URL or a file you upload. It finds the main color that stands out the most, making it super easy to discover your favorite shades!

But wait, there's more! If the link you provide doesn’t lead to a real image, no worries! The code sends a friendly message to let you know. Plus, it’s simple to use, so you don’t need to be a tech whiz to enjoy the fun of color extraction. Dive into this colorful project and see what amazing creations you can come up with!

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.