Help us measure site usage?

With your permission, we use self-hosted analytics to understand page usage. It is optional and does not affect the Service. Learn more.

RadvancedwebAI generated

Interactive Shiny App with Real-Time Data Streaming

Build a Shiny app in R that tracks live data from a public API, for example cryptocurrency prices or earthquake reports, and updates its charts and tables every few seconds without reloading the page. It keeps a rolling history of recent readings, draws a live ggplot2 chart, highlights values that cross thresholds you set, and shows a clear status when the API is slow or unreachable, retrying with increasing waits instead of freezing. You'll learn reactive programming in Shiny, polling with invalidateLater or reactivePoll, calling web APIs with httr2, managing state that grows over time, handling errors and rate limits gracefully, and testing Shiny apps.

Estimate
~9.5h
Steps
6
Completed by
0
Proposed by
codeseed.app

Shiny · httr2 · ggplot2

Project roadmap

  1. 01

    Poll a public API

    ~2h

    Choose a public API without a key that allows polling, such as the CoinGecko simple price endpoint or the USGS earthquake feed, and read its rules and rate limits. Write a function with httr2 that requests the data with a timeout and a user agent, parses the JSON, and returns a tidy data frame with a timestamp. In the Shiny server, call it every N seconds with invalidateLater (N chosen to respect the rate limit). Done when: the app fetches new data on the interval and prints it.

  2. 02

    Keep a rolling history

    ~1.5h

    Store readings in a reactiveVal holding a data frame: append each new reading (skipping duplicates when the API returns the same data again) and keep only the last N rows or the last hour. Show the latest values in a small table. Done when: the history grows with each poll and stays within its size limit.

  3. 03

    Draw a live chart

    ~1.5h

    Render a ggplot2 (or plotly, for interactivity) chart of the history that redraws when new data arrives, with a time axis, one line per tracked item (chosen with a selectInput) and a clear title and labels. Make sure redrawing doesn't flicker or reset the user's choices. Done when: the chart updates live as data arrives.

  4. 04

    Add threshold alerts

    ~1.5h

    Let the user set an upper and lower threshold per item. When a new value crosses one, show a notification with showNotification, draw the threshold lines on the chart, highlight the row in the table, and add the event to an alerts log. Don't repeat an alert until the value has come back inside the range. Done when: crossing a threshold triggers one notification and a log entry.

  5. 05

    Handle API failures

    ~1.5h

    Catch errors and timeouts with tryCatch, retry with increasing waits (and respect a Retry-After header on 429), and show a status badge: live, retrying (with the last successful update time) or offline. Keep showing the last good data while the API is failing. Done when: blocking network access shows the retrying and offline states, and the app recovers by itself.

  6. 06

    Test it

    ~1.5h

    Move the fetching, history and alert logic into plain functions and test them with testthat (using a saved API response and a fake failing fetch function). Test the server logic with Shiny's testServer, and add a shinytest2 test for the main screen. Done when: all tests pass.

Ready to build this?

Get a GitHub repo and start building. Your AI reviewer checks each step as you go.

~9.5h · 6 steps

Tech stack

Shinyhttr2ggplot2