C# Windows System Tray Current ETC Price App


#1

Hello! Just checking in to see if there is an interest in this? Today I started messing with Regex as I needed to use it for my work development and realized pretty fast that it is powerful. So I check on a couple API’s and found one that allows me to make a simple GET request to gather the current price of ETC, then I use Regex to trim it down to a decimal, and can manipulate it however I want!

This gave me several ideas and I figured if there was enough interest, I could develop an application that displays the current ETC price, and updates every handful of seconds in the system tray, and in the application. (See attached private youtube video to check it out) With donations, or an overwhelming amount of interest, (I consider that 20+) I will for sure add the ability for the user to enter a preferred update time, their ETC address, to pull the current amount they have, and calculate their approximate current value in real time, as well as displaying the current price! And after that, if it takes off, I will introduce the same logic to be able to use it for several other major currencies. Please let me know any and ALL ideas you may have or if your interest is peaked! I would love to be able to contribute something nice to this community but you got to let me know! Please select in the poll below whether you think I should or shouldn’t!

Donations welcome always :heart: :
0x050075df2589bA7ea2B6D39EE5659b528d5CD8E1

  • Do this!
  • Don’t Bother!

0 voters


#2

You probably don’t want to use RegEx for this. Most likely you want a JSON parsing library since that’s very likely the result you get back from your API queries.

A JSON parsing library would turn something like this:

[
    {
        "id": "bitcoin", 
        "name": "Bitcoin", 
        "symbol": "BTC", 
        "rank": "1", 
        "price_usd": "15749.4", 
        "price_btc": "1.0", 
        "24h_volume_usd": "12310500000.0", 
        "market_cap_usd": "264067039920", 
        "available_supply": "16766800.0", 
    }
]

^From CoinMarketCap

Into an object you could address like this:

print("Price: " + array[0]["price_btc"])
print("Volume: " + array[0]["24h_volume_usd"])

If you want to see a working example you can check out the repo for my cryptopricebot here, which basically does the same thing: https://github.com/pyskell/discord_cryptocurrency_price_bot


#3

Ooooo that looks fancy. I’m gonna take a look into that! Currently I just make the request, store it, strip it with Regex then use it. Haha I will take a look into this as this seems to be a far more elegant solution. I think the best idea for this app still is mostly just just displaying the price down in the system tray, and probably allow for most of the functionality to be done through that.

But out of curiosity, for the sake of just gathering up decimals like I am now, why wouldn’t Regex be ideal? I already have my expression wrote to be able to strip multiple variables from the request at the same time to spit them out formatted for me, all for the appropriate variables.

I’m still very new to working with data manipulation like this so you’ll have to bear with me here. Haha My work mostly consists of pulling data, using it in some logic, then spitting out reports… typically not much like this, but it has peaked my interest. :sunglasses:

Any suggestions for functionality you’d like to see?


#4

It’s mostly not ideal because there’s a better approach. RegEx is better for situations where whatever you’re parsing is very domain specific. For something as common as JSON it’s simply best to use what’s available for it.

Also didn’t realize you said C# earlier. You’ll probably want to use Newtonsoft’s JSON.Net. basically what you’re doing is “deserializing” the JSON data you have.

See some examples here: https://stackoverflow.com/questions/6620165/how-can-i-parse-json-with-c