How to get stream length and build version from Twitch API

I’m trying to extract specific information from a Twitch channel using their API. I need to pull two main pieces of data from the official stream.

First, I want to get the total broadcast time. In my case, it shows as 1 hour and 45 minutes. Second, I need to retrieve the current version identifier, which appears as “Luna 1” in my example.

I’ve been looking through the Twitch API documentation but I’m not sure which endpoints would give me this information. Has anyone worked with similar data extraction from Twitch streams before? What’s the best approach to get both the stream duration and version details reliably?

Stream duration through the API has some gotchas beyond timestamp calculation. The started_at field resets every time a streamer stops and restarts, so you might think a stream’s only 10 minutes old when they’ve been live for hours with brief interruptions. Learned this the hard way tracking uptime for several channels. For version extraction, check the stream tags along with titles. Some streamers use tags like “v1.0” or “beta” instead of putting version info in titles. The Get Channel Information endpoint gives you access to these tags. Also worth monitoring chat through IRC if streamers announce version changes there - many don’t update titles immediately but mention it in chat first.

You’ll need to hit a few Twitch API endpoints for this. Stream duration comes from the Get Streams endpoint - it gives you a started_at timestamp that you can use to calculate runtime.

For version identifiers like “Luna 1”, check the stream title or game category. Get Streams endpoint has this info, or use Get Channel Information for more details.

The annoying part is repeatedly parsing and calculating this stuff when monitoring multiple streams. I’ve automated similar setups where I’m pulling from various APIs and transforming the data.

Instead of writing custom scripts for API calls, rate limits, and data processing, I built the whole pipeline in Latenode. It handles Twitch API authentication, makes scheduled calls, calculates stream duration automatically, and extracts version info through text parsing.

Best part? Set it to run every few minutes and dump results wherever you want. No servers to manage or complex coding.

The stream duration calculation everyone mentioned works, but handling edge cases gets messy fast.

Streams restart, disconnect, or streamers take breaks - that started_at timestamp becomes unreliable. You get inflated duration numbers that don’t match actual broadcast time.

Parsing titles for version tracking works until streamers get creative with formatting. I hit this exact problem building monitoring for our gaming division.

Setting up the entire flow in Latenode saved me tons of headache. It pulls from Twitch API every few minutes, handles timezone math automatically, and uses smart text extraction to catch version patterns even when streamers change format.

The real win is how it deals with stream interruptions. Instead of basic timestamp math, I configured it to track actual broadcast segments and sum them properly. Plus it stores historical data so you can see version progression over time.

No wrestling with rate limits, authentication refresh, or parsing logic. Configure the workflow once and let it run.

The key with broadcast time is nailing timezone conversions. Twitch gives you started_at in UTC, so double-check your math against your local timezone needs. I’ve seen tons of duration calculations that were off by hours because of this.

For version extraction from titles - regex works great if streamers stick to consistent formatting. Try something like /Luna\s+(\d+)/ to catch ‘Luna 1’ variations. But streamers switch up their naming all the time, so you might want fuzzy matching or keyword detection instead of strict parsing.

One thing that got me: API rate limits will destroy you if you’re polling too much. Standard limit is 800 requests per minute, but checking multiple channels every few seconds hits that wall fast. Use exponential backoff and cache responses when nothing’s changed.

the version thing will be your biggest headache. streamers put that info everywhere - titles, overlays, chat commands, you name it. I’ve seen “luna 1” become “v1.0 luna” or just “l1” the next week. check the game category too since some streamers update that instead of their titles.

Getting stream duration is pretty simple once you know the API. Hit the Get Streams endpoint and grab the started_at timestamp (it’s in ISO 8601 format). Subtract that from current time and you’ve got your duration.

For version info like “Luna 1” - that’s usually buried in the stream title from the same endpoint. You’ll have to parse it out of the title string. Streamers throw it anywhere though - beginning, end, middle - so make your parsing flexible.

Heads up: Get Streams only works for live streams. Stream goes offline? All that session data disappears. Cache it if you need to track duration and version history.