Twitch Stream Cache keeps one Twitch streamer’s live status in memory. On a 10-second timer it asks Twitch’s API about the configured user and stores the answer, and a JSON endpoint hands that stored answer to anyone who asks. A website can poll it as often as it likes, while the app only goes to Twitch on its timer. The README states the goal: cache the response “to prevent throttling from twitch”.
All four commits are from February 7, 2018. The request it makes to Twitch no longer works as written (see below).
How it works
The application’s supervisor starts two workers:
- TwitchStatusStore, an Agent holding a map from a Twitch user ID to the latest response.
- TwitchCrawler, a GenServer that fetches once when it starts, then sends itself a
:workmessage every 10 seconds withProcess.send_afterand stores each new response.
The fetch itself is TwitchFetch. It calls the streams endpoint of Twitch’s Helix API with HTTPoison, sending the app’s Client-ID, and decodes the JSON with Poison. The request also carries the Accept header of Twitch’s older v5 API.

lib/integrations/twitch/twitch_fetch.ex.The HTTP side is a Maru router on port 8080. GET /twitch/:twitch_id reads the store and returns {"status": "ok", "data": [...]}, passing along the data list from Twitch, which is empty while the streamer is offline. A user ID the crawler isn’t tracking gets a 404 with "user doesn't exist in memory". The last commit added the Corsica plug, so pages on any origin can call it.

lib/api/router.ex.Configuration is two environment variables, TWITCH_USER_ID and TWITCH_CLIENT_ID. The README has you copy sample.env to .env, source it, and start the app with iex -S mix.
How it’s built
It’s Elixir 1.6 with Maru 0.12, a REST-style framework built on Plug and Cowboy, plus HTTPoison 1.0, Poison 3.1 and Corsica 1.1. There’s no database: the cache lives in the Agent and starts empty on every boot. The parts are the same ones PiperBot, a Slack bot from the year before, was built from: a Maru router, an Agent for state, HTTPoison and Poison for API calls, and dotenv for keys.
Running it today
It won’t work against Twitch as written. Since spring 2020, every Helix request needs an OAuth access token along with the Client-ID (Twitch’s announcement), and this code only sends the Client-ID. The fetch only handles a 200 response or a connection error, so it has no branch for the 401 it would get back. The v5 API named in its Accept header was shut down in February 2022. Bringing it back would mean requesting an app access token and sending it as a Bearer token with each call.
The creation date shown here is the GitHub repository’s UTC creation date. The code cards on this page are rendered from the repository’s source.