PricingBlog

3 API's - no idea how to do it?

  • xoracio-1212379010051604491

    Goran

    1 year ago

    I am creating an app for Crypto/Stock portfolio, where you can follow the progress of your investments.

    I am struggling with one problem for a few days now. But wasn't able to get a good result.

    Can you help me with how I can, in Toddle: 1. call the Get Portfolio API (get all crypto in the database), then 2. call the Update current price API to get the latest crypto prices, and then call the third API to update the prices in the database? And I should repeat that multiple times to do it for every crypto in the DB. What's the best way to do that in Toddle?
    I have all 3 API's working correctly.
  • xoracio-1212379289018966017

    Goran

    1 year ago

    here is the link to it with demo data. It all started by following Day 5 - dashboard, so I am using dashboard to show values, but can't get the data the way I want it 🙂
  • xoracio-1212385021642412082

    Goran

    1 year ago

    Is there a way to change a response I get from API? Maybe the questions sound stupid, but I do not have much experience.
    1212385021319454790-Screenshot_2024-02-26_at_21.31.38.png
  • rscott-1212569506916991048

    Bishop

    1 year ago

    You will need to create variables and then on 'success' (scroll down) you can assign values from the returned results into those variables.

    Some elements in your page will get their data from your variables.
  • Hope that helps. There's a learning curve if you haven't done a lot of javascript programming.
  • stuster-1212747709086179368

    StuartM

    1 year ago

    I think @GiantGuf has done exactly this...
  • giantguf-1212890077861257267

    GiantGuf

    1 year ago

    @Goran Yes, I've done something like this. If you want the prices to be updated on a schedule even when you are not logged in to your app you need a backend. I use Comnoco for that. I also use Supabase as database and Toddle as frontend.
    I read all the coins in my database and then loop through them to get each coins latest price. I then write back the price to Supabase. Toddle will get the data from Supabase when I log in to my app. I use a free API so I need to have short pauses between the readings so I don't exceed the free tier limit restrictions.
  • xoracio-1213139024391438357

    Goran

    1 year ago

    @GiantGuf You use comnoco I read somewhere? Free tier? Anyway for me is totally ok to update prices once I open my page, no need for permanent updates.
  • So if I can do it through toddle without comnoco that would be ideal for me
  • xoracio-1213139665931214848

    Goran

    1 year ago

    I tried using (Lifecycle) On attribute change in my component but it does not do anything
  • So I guess the purpose of that is not what I thought it is
  • giantguf-1213141156330737714

    GiantGuf

    1 year ago

    I was in the Beta group so I have a different tier than what's available now. I don't know what databases the free tier can handle. you have to ask StuartM about that.
    If you want the price fetch function to run in an interval while you are logged in you could use the Interval function. You set it in milliseconds and then on every tick you call the API for updated prices.
  • You then also need to refresh the page so the new values get updated on screen.